Juluma
Juluma

Reputation: 41

Keeping the jQuery flotcharts yaxes max value as set in options

I just started using jQuery flot http://www.flotcharts.org/ for a project, but I can't figure out why flot yaxes wont keep the max in all cases. Do you?

With these options and data values it does what I want;

        $(function(){
        var data = [[[1342731600000,0],[1351112400000,3.17],[1358719200000,3.17],[1366318800000,3],[1373403600000,4.17],[1384639200000,2.83],[1401051600000,3.33]]];
        var options = {
             series: {
                 bars: {
                     show: true,
                     barWidth: 1209600000, // 2 weeks in milliseconds
                     align: 'center'
                 }
             },
             yaxes: {
                 min: 0,
                 max: 5,
             },
             xaxis: {
                 mode: 'time',
                 timeformat: "%d.%m.%y",
                 autoscaleMargin: 0.04, // allow space left and right
                 ticks: [1342731600000,1351112400000,1358719200000,1366318800000,1373403600000,1384639200000,1401051600000]                 }
         };
        $.plot("#placeholder", data, options);

But when the maximum y-value in data set is below 4 the max yaxis is 4 instead of 5 (that's what I want it to be in all possible cases). How do I force flot to keep the max yaxes scale up to 5?

Another little thing is also that sometimes flot doesn't show the yaxis ticks (or whatever these are called, english isn't my first language?) as float but as int. Here's an example (which produces 1,2,3,4 and 5 instead of 1.0, 2.0, ..., 5.0 as in previous code;

        $(function(){
        var data = [[[1342731600000,2.8],[1351112400000,3.8],[1358719200000,3.4],[1366318800000,4.4],[1373403600000,4.6],[1384639200000,3.4],[1401051600000,3.8]]];
        var options = {
             series: {
                 bars: {
                     show: true,
                     barWidth: 1209600000, // 2 weeks in milliseconds
                     align: 'center'
                 }
             },
             yaxes: {
                 min: 0,
                 max: 5,
             },
             xaxis: {
                 mode: 'time',
                 timeformat: "%d.%m.%y",
                 autoscaleMargin: 0.04, // allow space left and right
                 ticks: [1342731600000,1351112400000,1358719200000,1366318800000,1373403600000,1384639200000,1401051600000]                 }
         };
        $.plot("#placeholder", data, options);

What's the deal here? Couldn't find help for these two mysteries in flot api, maybe I just missed it... but thanks in advance! Too bad that I couldn't add images due to my low reputation.

Upvotes: 1

Views: 567

Answers (1)

Juluma
Juluma

Reputation: 41

Another case of typo; option name is yaxis not yaxes.

Upvotes: 1

Related Questions