Can I use xAxis with type "datetime" and yAxis with categories?

I have a very simple example of using Highcharts that uses "datetime" on one axis and categories on another. It displays without glasses and does not display category labels at all. Now I'm wondering if you can use this combination of types. Here is the code:

var chart = new Highcharts.Chart({ chart: { renderTo: 'container' }, xAxis: { type: 'datetime' }, yAxis: { categories: ['p1', 'p2'] }, series: [{ type: 'scatter', data: [ { name: 'Deliv1', x: Date.UTC(2011,0,1), y: 'p1' }, { name: 'Deliv2', x: Date.UTC(2012,0,1), y: 'p2' } ] }] }); 
+6
source share
2 answers

The answer to my problem was given on the highcharts forum. I thought I would tell here what this solution is. I mistakenly used y: 'p1' and y: 'p2' for values ​​in points. The y values ​​are actually category indices. Here is the updated code that works:

 data: [ { name: 'Deliv1', x: Date.UTC(2011,0,1), y: 0 }, { name: 'Deliv2', x: Date.UTC(2012,0,1), y: 1 } ] 
+8
source

It is possible, but you need to pretend that the y values ​​are numeric.

Probably having an array with the actual Y value and a number (possibly an index), then the value of the y point for the number and for the y axis settings will add a formatter label to return the actual y value based on the value.

You will also need to adjust the interval min, max, interval, and if you use tooltips, add a similar formatter to get the y value.

(If I have more time, I will try to create an example).

+1
source

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


All Articles