Highstock highcharts irregular data gets wrong x-scale
You will need to set the xAxis.ordinal
property to false
, this is true
by default. True
value indicates the points should be placed at fixed intervals w.r.t space (pixels), and False
changes points to be placed at fixed intervals w.r.t. time
xAxis: {
ordinal: false
}
Linear x-axis | Highstock @ jsFiddle
Putnik
AWS Certified Solutions Architect-Associate AWS Certified SysOps Administrator-Associate 10+ years with Linux etc :) Feel free to contact me via LinkedIn https://www.linkedin.com/in/alexander-lutchko-11b556b7/
Updated on July 01, 2022Comments
-
Putnik almost 2 years
I have irregular data. Chart draws well when I use highcharts:
$(function() { var chart = new Highcharts.Chart({ chart: { renderTo: 'chart' }, xAxis: { type: 'datetime' }, series: [{ name: 'Volume', data: chart_arr, }] }); });
But I have a lot of data so I need to zoom on the date and choose highstock. Then a strange thing happens: the x-axis become non-linear.
$(function() { var chart2 = new Highcharts.StockChart({ chart: { renderTo: 'chart2' }, rangeSelector: { selected: 0 }, xAxis: { type: 'datetime' }, series: [{ name: 'val', data: chart_arr, type : 'area', }] }); });
Please note that the data for half an hour range Jan 6 20:00-20:30 allocates more space than 2 days Jan 11-13. (Of course the data is the same.)
How can I force x-axis at highstock to become linear? Or How can I enable a bottom zoom tool for highcharts? Thank you.
-
Putnik over 11 yearsI know about zoom bot this is not what I want. Also perhaps there is misunderstanding: I have just went to my second example and removed "type : 'area'," line. Nothing happend except chart represents data as line (not area). Is it what you really meant?
-
Pravin over 9 yearsIs this a correct solution for this problem also? stackoverflow.com/questions/25861690/… I tried it but it's not solving the issue.
-
Vicky Chijwani about 9 yearsThis option has such an odd name. Spent hours trying to get this behaviour sigh.