简体   繁体   English

JS Highcharts无法正常工作

[英]JS Highcharts not working

I'll create a "bar" highcharts.( Fiddle ) 我将创建一个“栏”高图。( Fiddle

As you can see in there, my data comes in an array: var x = [ [ ["W",20], ["M",9] ] ];. 如您所见,我的数据位于一个数组中: var x = [ [ ["W",20], ["M",9] ] ];.

If I change the type from bar to pie, my code works fine. 如果我将类型从bar更改为pie,我的代码可以正常工作。

I would like to show one bar - 20% woman, 80% man. 我想展示一个酒吧-女人20%,男人80%。

You know what I mean? 你知道我的意思? Thank you! 谢谢!

Probably this is kind of what you are looking for: 大概这就是您要寻找的东西:

series: [{
    name: x[0][0][0],
    data: [x[0][0][1]]
}, {
    name: x[0][1][0],
    data: [x[0][1][1]]
}]

http://jsfiddle.net/4ngcswa1/5/ http://jsfiddle.net/4ngcswa1/5/

But it is a good idea to change the data format to better match what chart expects . 但是,最好更改数据格式以更好地匹配图表的预期。

You need one object in the series array for every element in the chart 图表中的每个元素都需要一个系列数组中的对象

    series: [{
        name: 'M',
        data: [80]
    }, {
        name: 'F',
        data: [20]
    }]

http://jsfiddle.net/ngazy8a2/ http://jsfiddle.net/ngazy8a2/

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

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