JQuery Flot Tick / Date Alignment

the code

An example of my problem: http://jsfiddle.net/x46RQ/


goal

I want the graph to be such a column: http://jsfiddle.net/Lbd85/ , but obviously with dates like the x axis. If I add my data to this fiddle, it will go bad, as shown above, as shown here: http://jsfiddle.net/73G7Z/


Questions

  • Why aren't all 3-day data displayed in the data variable?
  • Why aren't the bars lined up with the corresponding x-axis ticks?
  • Why does changing data and mode over time completely ruin what would otherwise be a functional and accurate histogram?

Environment

  • jQuery 1.7.1
  • jQuery Mobile 1.0.1
  • Fleet 0.7

thanks

Let me know if additional information is required.

+6
source share
1 answer

Part No. 1, you indicated the minimum value 0 in your fleet parameters, and your data point No. 2 has a value of 0. So it is there, but very small, almost invisible.

Part number 2, you must compensate for your dates in the time zone of users:

Something like that:

var tzOffset = new Date(); tzOffset = tzOffset.getTimezoneOffset()*60*1000; data.push([(new Date("2012/02/20").getTime()-tzOffset), 1]); 

Part number 3. Your graph is a mess because you specified width when this parameter was barWidth , and you need to specify the width in terms of time, i.e. milliseconds. See here . Something like barWidth: 12*60*60*1000 looks fine.

So, in the end, it will look like this: http://jsfiddle.net/ncTd3/

+4
source

Source: https://habr.com/ru/post/909485/


All Articles