以变​​量-Highcharts的形式传递数据 [英] Pass data in form of variable -Highcharts

查看:87
本文介绍了以变​​量-Highcharts的形式传递数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的系统中实现高图表(pai图表),我试图从一个变量中传递数据的值,该变量包含数据所需的精确数组方式的值, alert (legend_with_values)如果我提醒这个变量,它会返回 [['agent_total_members',24],['billing_failed',0],['members_inactive',0],[ 'members_expired',0]] 我将这个值传递给数据字段,像这样

I am trying to implement high charts(pai chart) in my system where I am trying to pass the the value of data from a variable which contains the value in exact array manner that data required, alert(legend_with_values) If I am alerting this variable it returns [['agent_total_members',24],['billing_failed',0],['members_inactive',0],['members_expired',0] ] I am Passing this value to the data field like this

 legend_with_values;
 alert(legend_with_values);




此警报返回[['agent_total_members',24],['' billing_failed',0],['members_inactive',0],['members_expired',0]

this alert returns [['agent_total_members',24],['billing_failed',0],['members_inactive',0],['members_expired',0]



  options.series = [{
    type: 'pie',
    name: 'Legend',
    data: legend_with_values
  }];
  new Highcharts.Chart(options);`

但是当我通过这个变量数据是以这种方式来的。检查它将每个字符作为一个字符串的图像

But when I am passing this variable in data it is coming in this manner .Check the image it is taking each character as a string

,如果我将警报值静态地放入数据中,它会向我显示正确的图表并提示如何解决这个问题?

and if I put the alert value statically in the data it is showing me graph properly any suggestions how to fix this ?

推荐答案

我在这里编辑你的例子: http://jsfiddle.net/3rkd8/,并且全部生成正确。

I edited your example here: http://jsfiddle.net/3rkd8/ and all is generated properly.

var chart,
    legend_with_values = [['agent_total_members',24],['billing_failed',0],['members_inactive',0],['members_expired',0],['agent_total_members',45]];
$(document).ready(function() {
    chart = new Highcharts.Chart({
        chart: {
            renderTo: 'container',
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false
        },
        title: {
            text: 'Browser market shares at a specific website, 2010'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage}%</b>',
            percentageDecimals: 1
        },
        series: [{
            type: 'pie',
            name: 'Browser share',
            data: legend_with_values
        }]
    });
});

如果您有不同的源代码并且问题仍然存在,您能否更新此示例?

Could you update this example if you have different source code and problem still exist?

这篇关于以变​​量-Highcharts的形式传递数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆