简体   繁体   中英

How can i assign the same yAxis.categories values to series.data in HighCharts?

I'm trying to create a chart where the data that I pass to the series.data property exactly match the values that I go to the categories property on the y-axis. I tried to put the data in decimal form but then the spline points did not match the various categories.

Categories for me represents a array of times.

This is my chart:

Highcharts.chart('container', {
    chart: {
        type: 'spline'
    },
    yAxis: {
        min: 0,
        max: 2,
        reversed: true,
        tickInterval: 1,
        categories: ['0:30', '0:40', '1:00'],
    },
    series: [{
        data: [1, 0.4, 0.3]
    }]
});

What I would like to do is assign the values [0:30 ',' 0:40 ',' 1:00 '] to series.data property. But unfortunately you can not assign a string type to data .

How can I get around the problem?

Instead of a decimal value, use index of the specific yAxis category to display value in the right place and modify tooltip to display a category value.

API Reference:
http://api.highcharts.com/highcharts/tooltip.formatter

Example:
http://jsfiddle.net/8wefsL70/1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM