highcharts - 我们可以在 highcharts 中将图表的 Y 轴值显示为字符串值吗?
问题描述
在我的场景中,对于 Y 轴值显示为字符串值,如“NA”。但我的数据返回正确的数据。但图表不可见。它仍在加载。
http://jsfiddle.net/3ajw61ze/2/
$(函数(){
// Create the chart
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Basic drilldown'
},
xAxis: {
type: 'category'
},
plotOptions: {
series: {
borderWidth: 1,
dataLabels: {
enabled: true,
}
}
},
series: [{
id: 'toplevel',
name: 'Ratio',
data: [
{name: 'Income', y: 'NA',color:'Green', drilldown: null},
{name: 'Expenses', y: 'NA',color:'Red', drilldown: null},
{name: 'NetProfit', y: 'NA',color:'Orange', drilldown: null}
]
}],
drilldown: {
series: null
}
})
});
解决方案
Highcharts 要求x
和y
值是数字。要解决您的问题,您可以使用category
轴类型:
yAxis: {
categories: ['NA']
},
series: [{
...,
data: [{
y: 0,
...
},
...
]
}]
现场演示:http: //jsfiddle.net/BlackLabel/spu2gfwn/
推荐阅读
- bash - 如何在 bash 上同时运行 2 个命令
- javascript - 使用 jQuery (ajax, json) 和 Spring MVC 发送多行表单数据
- scala - 对两个列表进行元素总和的最快方法
- c# - 通过蓝牙流式传输音频
- rest - 用于获取 HDInsight 群集的性能指标的 REST API?
- purescript - 如何在 Purescript 中使用 mapWithIndex?
- java - 测试它说它终止的输出
- automation - 我们可以使用哪个自动化工具来自动化安全应用程序(我们不能在其中录制视频和屏幕截图?
- c - 这是 C 语言未定义的行为吗?clang 和 GCC 中的不同结果
- c# - 从方法外部获取到动作的路线