English 中文(简体)
a. 通过动态的json阵列,通过高潮 P
原标题:To pass dynamic json array to Highcharts Pie Chart

我通过了json encoded string(g)。 EXT2包括[“chrome”、“15”、“firefox”、“20”)从Xcode到javascript(g. arr)的阵列。 现在,我想通过这一阵列,充满活力地扼杀高潮。 超文本代码为

<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=20, user-scalable=no;" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Pie chart</title>

<!-- 1. Add these JavaScript inclusions in the head of your page -->
<script type="text/javascript" src="jquery-1.6.2.js"></script>
<script type="text/javascript" src="highcharts.js"></script>
<script type="text/javascript" src="jquery.form.js"></script>
<!-- 2. Add the JavaScript to initialize the chart on document ready -->
<script type="text/javascript">

var chart;
var arr = $TEXT2;

$(document).ready(function(){
chart = new Highcharts.Chart({
chart: {
renderTo:  container ,
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text:  Interactive Pie 
},
tooltip: {
formatter: function() {
return  <b> + this.point.name + </b>:  + this.y +  % ;
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor:  pointer ,
dataLabels: {
enabled: false
},
showInLegend: true
}
},
series: [{
type:  pie ,
name:  Browser share ,
data: []
}]
});
});
</script>
<body>
<br>
<!-- 3. Add the container -->
<div id="container" style="width: 300px; height: 350px; margin: 0 auto"></div>
<!-- 2. Add the JavaScript to initialize the chart on document ready -->
</body>
</html>

I am trying to use getjson method although m unaware of its usage. Since i want to pass my array i.e arr to data[] in Highcharts,I am doing:

$.getJSON("arr", function(json) {
chart.series = json;               
var chart = new Highcharts.Chart(chart);
     });

Can anyone help me on dis. Thanks in advance.

问题回答

我将在该文件中总结日本人的呼声。 • 准备运行,然后在成功呼吁中总结地图:

$(document).ready(function() {

  $.getJSON("arr", function(json) {

    chart = new Highcharts.Chart({
      chart: {
        renderTo:  container ,
        plotBackgroundColor: null,
        plotBorderWidth: null,
        plotShadow: false
      },
      title: {
        text:  Interactive Pie 
      },
      tooltip: {
        formatter: function() {
          return  <b> + this.point.name + </b>:  + this.y +  % ;
        }
      },
      plotOptions: {
        pie: {
          allowPointSelect: true,
          cursor:  pointer ,
          dataLabels: {
            enabled: false
          },
          showInLegend: true
      },
      series: [{
        type:  pie ,
        name:  Browser share ,
        data: json
      }]
    });
  });
});

当然,为了做到这一点,你应当修改你的背后法,以恢复高度洄游的阵列。

[["chrome",15],["firefox",20]]

你可以在联合材料中“确定”你返回的阵列,但最好在“个人支持”呼吁中这样做。

<script type="text/javascript">
    jQuery(document).ready(function () {
        alert( call pie );

        var data1 = $("#dataidd").val();
        alert( pie data  + data1);


        /*--------Pie Chart---------*/
        $( #PieChartDiv ).highcharts({
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false
            },
            title: {
                text:  Comparision and Analysis Report 
            },
            tooltip: {
                pointFormat:  {series.name}: <b>{point.percentage:.1f}%</b> 
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor:  pointer ,
                    dataLabels: {
                        enabled: true,
                        format:  <b>{point.name}</b>: {point.percentage:.1f} % ,
                        style: {
                            color: (Highcharts.theme && Highcharts.theme.contrastTextColor) ||  black 
                        }
                    }
                }
            },
            series: [{
                type:  pie ,
                name:  Issue Details ,
                // data: jQuery.parseJSON(data1)
                data: JSON.parse(data1)

            }]
        });
    });
    </script>

简单:

1. 建立焦炭阵列:

$.each(data[ values ], function(i, val) {
                    x_values_sub[ name ] = i
                    x_values_sub[ y ] = val
                    x_values.push(x_values_sub);
                    x_values_sub = {};
});

页: 1 然后把高Charts称作数据。

series: [{
                            type:  pie ,
                            name: null,
                            data: x_values
}]

/ 测试并使用简单的javascript 反对:

Object Part1Name: 25 Part2Name: 75__proto__: Object

你可以直接将图表与JSON数据挂钩。 你只是需要将json的财产名称定为高智慧标准。 Y 价值和标签名称。

阁下:

[ { name: "Chrome", y: 25 }, { name: "Firefox", y: 20 } ]




相关问题
WordPress Data Storage Efficiency

I ve been asked to review a WordPress plugin of sorts and try to find ways of making it faster. The premise of this plugin is basically to store a bunch of users and shifts and appointments and ...

Convert a 2D array index into a 1D index

I have two arrays for a chess variant I am coding in java...I have a console version so far which represents the board as a 1D array (size is 32) but I am working on making a GUI for it and I want it ...

Convert an array of integers for use in a SQL "IN" clause

Surely there is a framework method that given an array of integers, strings etc converts them into a list that can be used in a SQL "IN" clause? e.g. int[] values = {1,2,3}; would go to "(1,2,3)"

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

C++ Array Sort Me

Stuck on an array sorter. Have to sort numbers from largest to smallest. I m trying two loops (one nested in the other). Here s the code: int counter=0; // inner counter int counter2=0; // outer ...

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

Best practice of big javascript objects

sry for this imprecise topic name. I am querying a dataset a lot of times so using ajax request would end up in tons of http requests. For this reason I decided to use the json encode method to ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

热门标签