[英]Issue with highCharts range selector date format?
I am trying to use the rangefilter with the HighCharts. But getting improper start and end date.我正在尝试将 rangefilter 与 HighCharts 一起使用。但开始日期和结束日期不正确。 Seems like it is not able to recognize my date.
似乎无法识别我的约会对象。
On x-axis, I have categorical values of unique dates.在 x 轴上,我有唯一日期的分类值。 On the y-axis, I have the unique count.
在 y 轴上,我有唯一计数。
My data series for y-axis is complicated and generating dynamically in the mentioned format.我的 y 轴数据系列很复杂,并且以上述格式动态生成。
Can someone please suggest me where i am going wrong?有人可以建议我哪里出错了吗?
$(document).ready(function() {
var categories = ['2010-12-30','2011-03-31','2011-06-30'];
new Highcharts.Chart({
chart: {
renderTo: 'container'
},
title: {
text: 'Sample'
},
rangeSelector: {
enabled: true
},
navigator: {
enabled: true,
xAxis: {
labels: {
/* formatter: function() {
return categories[this.pos]
} */
}
}
},
scrollbar: {
enabled: true
},
xAxis: {
reversed: true,
minRange: 1,
tickPositions: categories
},
yAxis: [{ // Primary yAxis
labels: {
format: '{value}',
style: {
color: Highcharts.getOptions().colors[1]
}
},
title: {
text: 'AVERAGE CT_HOURS',
style: {
color: Highcharts.getOptions().colors[1]
}
}
}],
series: [{
name: 'Count',
type: 'spline',
data: [
[56.6],
[46.3],
[32.8]
].reverse(),
tooltip: {
valueSuffix: ''
}
}]
});
});
Here is my sample code: http://jsfiddle.net/7x3cgf48/3/这是我的示例代码: http://jsfiddle.net/7x3cgf48/3/
The range selector is reserved for highstock charts.范围选择器是为 highstock 图表保留的。
https://api.highcharts.com/highstock/rangeSelector https://api.highcharts.com/highstock/rangeSelector
As for displaying unique values in xAxis.labels I project a value onto a two-dimensional array and display the label as a string after set xAxis.labels.useHTML to true.至于在 xAxis.labels 中显示唯一值,我将一个值投影到二维数组上,并在将 xAxis.labels.useHTML 设置为 true 后将 label 显示为字符串。
https://api.highcharts.com/highstock/xAxis.labels.useHTML https://api.highcharts.com/highstock/xAxis.labels.useHTML
xAxis: {
useHTML: true,
labels: {
formatter: function() {
var value = this.value,
string = `${categories[this.value][0]}`;
return string;
}
}
},
Demo: https://jsfiddle.net/BlackLabel/jn8bqta7/演示: https://jsfiddle.net/BlackLabel/jn8bqta7/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.