Highcharts Error#18 in - Highcharts.Chart(options)

时间:2014-02-26 09:54:27

标签: javascript highcharts

鉴于以下Highcharts.Chart(options)

{
                "chart": {
                    "type": "spline"
                },
                "title": {
                    "text": "",
                    "x": -20
                },
                "subtitle": {
                    "text": "",
                    "x": -20
                },
                "xAxis": [
                    "23 Jun",
                    "24 Jun",
                    "25 Jun",
                    "26 Jun",
                    "27 Jun",
                    "28 Jun",
                    "29 Jun"
                ],
                "yAxis": {
                    "title": {
                        "text": ""
                    },
                    "plotLines": [
                        {
                            "value": 0,
                            "width": 1,
                            "color": "#808080"
                        }
                    ]
                },
                "legend": {
                    "layout": "vertical",
                    "align": "right",
                    "verticalAlign": "middle",
                    "borderWidth": 0
                },
                "series": [
                    {
                        "name": "exposed",
                        "data": [
                            100,
                            200,
                            150,
                            130,
                            180,
                            200,
                            190
                        ],
                        "dashStyle": "longdash"
                    },
                    {
                        "name": "converted",
                        "data": [
                            90,
                            80,
                            70,
                            75,
                            70,
                            80,
                            85
                        ],
                        "dashStyle": "longdash"
                    },
                    {
                        "name": "engaged",
                        "data": [
                            30,
                            40,
                            35,
                            40,
                            48,
                            30,
                            33
                        ],
                        "dashStyle": "longdash"
                    }
                ]
            }

当我使用 - $('#container').highcharts({...}) 绘制时,它会提示错误 -

Uncaught Highcharts error #18: www.highcharts.com/errors/18  

http://www.highcharts.com/errors/18

您可以在 - jsFiddle

中看到它

options格式有什么问题?

1 个答案:

答案 0 :(得分:5)

在jsFiddle

中定义一个容器

有x轴的问题。您必须定义一个对象,而不仅仅是一个数组。前

"xAxis": {categories: [
                    '23 Jun',
                    '24 Jun',
                    '25 Jun',
                    '26 Jun',
                    '27 Jun',
                    '28 Jun',
                    '29 Jun'
                          ]}

您是否期望像http://jsfiddle.net/x4YbZ/这样的想法?