我想为您的图书馆的这种类型的图画多条线:http://www.highcharts.com/stock/demo/basic-line

我在互联网上找到了以下示例:http://jsfiddle.net/yildirim_timur/Hb3Q7/

在下面您可以看到我的html文件。我试图做几件事情,但是做不到。我如何使我的图表也能够绘制多条线? (适用于ipad应用程序项目)

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <title>Senior Project Timur Aykut YILDIRIM - IH Technology</title>
        <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
        <link rel="stylesheet" type="text/css" href="/Users/ihtechnology/Desktop/chart_deneme/css/normalize.css">
        <link rel="stylesheet" type="text/css" href="/Users/ihtechnology/Desktop/chart_deneme/css/result-light.css">
        <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet"/>
        <script type='text/javascript'>
            var serviceDataURL = "http://xx.xx.xxx.xxx:83/get_item_data_ios?generic=";

            function setDictionary(x){
                return x;
            } // no need for this method

            var dict = "web service query string will be here";

            $(function() {
                $.getJSON(serviceDataURL.concat(dict), function(data) {
                    // Create the chart
                    window.chart = new Highcharts.StockChart({
                        chart : {
                            renderTo : 'container'
                        },
                        navigation: {
                            buttonOptions: {
                                enabled: false,
                                width: 60
                            }
                        },
                        rangeSelector : {
                            buttonSpacing: 20,
                            buttonTheme: { // styles for Q,Y,YTD,ALL buttons
                                fill: 'none',
                                stroke: 'none',
                                'stroke-width': 15,
                                style: {
                                    color: '#039',
                                    fontWeight: 'bold'
                                },
                                states: {
                                    hover: {},
                                    select: {
                                        fill: '#039',
                                            style: {
                                                color: 'white'
                                            }
                                    }
                                }
                            },
                            selected : 3, // 3=ALL buton at first
                            inputDateFormat: '%Y-%m-%d',
                            inputEditDateFormat: '%Y-%m-%d',
                            buttons:[
                                {
                                    type: 'month',
                                    count: 3,
                                    text: 'QQ'
                                },

                                {
                                    type: 'year',
                                    count: 1,
                                    text: 'YY'
                                },

                                {
                                    type: 'ytd',
                                    text: 'YTD'
                                },

                                {
                                    type: 'all',
                                    text: 'ALL'
                                },
                            ]
                        },
                        title : {
                            text : 'My Total Market'
                        },
                        credits: {
                            text: " ",
                            href: " ",
                        },
                        series : [{
                            name : 'Total Market',
                            data : arr,
                            tooltip: {
                                valueDecimals: 2
                            }
                        }],
                        exporting: {
                            enabled: false
                        }
                    }, function(chart){
                            // apply the date pickers
                            setTimeout(function(){
                                $('input.highcharts-range-selector').attr('readonly',1); // burda webviewı engelledik
                                $('input.highcharts-range-selector', $('#'+chart.options.chart.renderTo))
                            },0)
                        });
                });

            });

                //]]>
        </script>
    </head>
    <body>
        <div id="container" style="height: 500px; min-width: 500px;"></div>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
        <script src="http://code.highcharts.com/stock/highstock.js"></script>
        <script src="http://code.highcharts.com/stock/modules/exporting.js"></script>
    </body>
</html>

最佳答案

现在您有:

                    series : [{
                        name : 'Total Market',
                        data : arr,
                        tooltip: {
                            valueDecimals: 2
                        }
                    }]


因此,系列中只有一个对象。如果您想要多个系列,则应该是这样的:

                    series : [{
                        name : 'Total Market I',
                        data : arr_1,
                        tooltip: {
                            valueDecimals: 2
                        }
                    },{
                        name : 'Total Market II',
                        data : arr_2,
                        tooltip: {
                            valueDecimals: 2
                        }
                    }]


编辑:

要添加多个系列,请将它们推入数组:

var mySeries = [];

mySeries.push({
    name : 'Total Market I',
    data : arr_1
});
mySeries.push({
    name : 'Total Market II',
    data : arr_2
});
mySeries.push({
    name : 'Total Market III',
    data : arr_3
});


然后创建图表:

series: mySeries

08-19 14:46