HighCharts列上的多个系列数据 [英] Multiple series data on HighCharts column
问题描述
我在一个项目中使用HighCharts,我无法按照我想要的方式格式化数据。我目前有一些有用的东西,但它不太正确。
我有一个柱形图,一切都在一个系列。我宁愿每个数据点都在自己的系列&正确标记在图例&工具提示。下面是格式化数据的相关位的示例。
我不知道我做错了什么,我做的更改感觉他们应该工作因为他们的文档& 此演示。
工作:
series:[
{
data:[
{
y:92,
name:苹果:92ms 83,481,430请求,
color:#91cb73
},
{
y:761,
name: 58,050,877个请求,
color:#ab7053
},
{
y:774,
name:Kiwis:774ms 362,294 requests,
color:#44719c
}
]
}
]
演示: http://jsfiddle.net/b65kp/
不工作:
series:[
pre>
{
name:Apples,
data:{
y:92,
name:92ms for 83,481,430 requests,
color:#91cb73
}
},
{
name: ,
data:{
y:761,
name:761ms for 58,050,877 requests,
color:#ab7053
}
},
{
name:Kiwis,
data:{
y:774,
name:774ms for 362,294 requests,
color:#44719c
}
}
]
演示: http://jsfiddle.net/ u74Qw / 1 /
解决方案问题是
data
期望一个数组,你给它一个对象。在数组中包装每个对象。例如:data:[{
y:92,
name :92ms for 83,481,430 requests,
color:#91cb73
}]
这是您的完整修正,但它可能不会给您期望的结果,个人我更喜欢你的第一次尝试
I'm using HighCharts on a project, and I'm having trouble formatting the data in the way I'd like. I currently have something that works, but it doesn't feel quite right.
What I have is a column chart with everything in one series. I'd rather have each data point be in it's own series & properly labeled in the legend & tooltips. Below are samples of the relevant bits to format the data.
I'm not sure what I'm doing wrong, the changes I've made feel like they should work given their docs & this demo. Also, Do I need the categories if multiple series works?
Working:
"series": [ { "data": [ { "y": 92, "name": "Apples: 92ms for 83,481,430 requests", "color": "#91cb73" }, { "y": 761, "name": "Bananas: 761ms for 58,050,877 requests", "color": "#ab7053" }, { "y": 774, "name": "Kiwis: 774ms for 362,294 requests", "color": "#44719c" } ] } ]
Demo: http://jsfiddle.net/b65kp/
Not working:
"series": [ { "name": "Apples", "data": { "y": 92, "name": "92ms for 83,481,430 requests", "color": "#91cb73" } }, { "name": "Bananas", "data": { "y": 761, "name": "761ms for 58,050,877 requests", "color": "#ab7053" } }, { "name": "Kiwis", "data": { "y": 774, "name": "774ms for 362,294 requests", "color": "#44719c" } } ]
Demo: http://jsfiddle.net/u74Qw/1/
解决方案The problem is that
"data"
expects an array, and you are giving it an object. Wrap each object in an array. For example:"data": [{ "y": 92, "name": "92ms for 83,481,430 requests", "color": "#91cb73" }]
Here is your full fix, but it might not give the result you expect, personally I like your first attempt better
这篇关于HighCharts列上的多个系列数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!