简体   繁体   English

如何在HighCharts中将相同的yAxis.categories值分配给series.data?

[英]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. 我试图创建一个图表上,我传递给series.data属性中的数据完全匹配,我去在y轴上的类别属性的值。 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. 我想做的就是将[0:30','0:40','1:00']分配给series.data属性。 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. 代替十进制值,使用特定yAxis类别的索引在正确的位置显示值,并修改tooltip以显示类别值。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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