barwidth option is not working on jquery flot

I am trying to draw a line chart with bar chart. everything went well. This is my code

 $.plot(holder, [
                    { data: data[0].data, lines: { show: true }, label:"Service Level" },
                    { data: data[1].data, bars: { show: true }, yaxis: 2, label:"# Of Calls" } // set second series to use second axis
               ], {
                   yaxes: [{
                       min: 0, // options for first axis,
                       max: 100,
                       tickFormatter: function (val, axis) {
                           return val + '%';
                       }
                   }, {
                       alignTicksWithAxis: 1, // options for second axis, put it on right
                       position: "right"
                   }],
                   xaxis: {
                       min: minVal.getTime(),
                       max: maxVal.getTime(),
                       mode: "time",
                       timeformat: timeFormat,
                       //twelveHourClock: true,
                       tickSize: [tickVal, modeChart],
                       //monthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
                       tickLength: 0
                   },
                   bars: {
                        barWidth: 24 * 60 * 60,
                   },
                   grid: {
                       hoverable: true,
                       clickable: false,
                       borderWidth: 0
                   },
               });
           }

I already set the barWidth and whatever I change the value, the width of the bar is not changing. could you help me please?

I am talking about the blue one in this image

enter image description here

Answers:

Answer

barWidth is a series option, you can specify it globally or per series:

Globally:

...
series: { // you are missing this
    bars: {
        barWidth: 24 * 60 * 60,
    },
}
...

Per Series:

{ data: data[1].data, bars: { show: true, barWidth: 24 * 60 * 60 }, yaxis: 2, label:"# Of Calls" } // set second series to use second axis
Answer

Since your x-axis is time, the units are milliseconds. By specifying a bar width of 24*60*60 you're setting the width to be 1/1000th of a day, or about 1.5 minutes. For a chart that spans several months, 1.5 minutes is tiny and may not be what you want. If you want your bar widths to be a day, then you should specify a bar width of 24*60*60*1000 instead.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.