从.js高图获取值

时间:2013-05-13 10:53:49

标签: highcharts

我是android和java的新手。所以不要求明确的答案只是一个正确的方向。 网站正在使用高图,我得到的是高清数据。

http://webpage/javascript/city/newyork.js


new Highcharts.Chart({
chart: { renderTo: 'graph1' },
yAxis: { min: 0, max: 100 },
plotOptions: { line: { dataLabels: { y: 20 } } },
series: [{ data: [95,96,96,45,37,36,42,51,54,61,62,49,42,39,47,56,60,63,61,49,35,35,39,46,52] }]
});

new Highcharts.Chart({
chart: { renderTo: 'graph2', defaultSeriesType: 'column' },
yAxis: { min: 0, max: 3 },
plotOptions: { column: { pointPadding: 0.2, borderWidth: 0 } },
series: [{ data: [0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00] }]
});

new Highcharts.Chart({
chart: { renderTo: 'graph4' },
plotOptions: { line: { dataLabels: { formatter: function() { if(this.x != ' ') return this.y; } } } },
series: [{ data: [1015,1016,1018,1018,1017,1015,1015,1016,1017,1017,1018,1017,1015,1013,1012,1013,1011,1010,1011,1010,1008,1006,1007,1008,1009] }]
});

$(document).ready(
function($){

    $('#sevendays > li').live(
        'click hover',
        function(){
            $('#sevendays > li').removeClass('selected');
            $(this).addClass('selected');
            $('.day').hide();
            $('#chosen-day > div:nth-child(' + ($(this).index() + 1) + ')').show();
        }
    );

    $('#chonsen-city a').click(
        function(){
            icity = $(this).attr('rel');
            $('#chosen-city').load('/ajax/chosen-city.php', {ig: icity});
            return false;
        }
    );
});

我需要的是得到graph1,graph2和amp;的数字数组。 graph4数据,所以我可以绘制自己的图表。大多数教程都是关于json解析的,但由于这不是json格式,我有点迷失。 再一次,正确的方向,一些可读的材料。 谢谢。

1 个答案:

答案 0 :(得分:0)

您可以遍历每个图表的系列并构建y值的数组:

http://jsfiddle.net/jlbriggs/JVNjs/298/

var data1 = new Array();
for(var i = 0; i < chart1.series[0].data.length;i++){
    data1.push(chart1.series[0].data[i].y);
}