1

am trying to show data on highcharts that is comming from datatabase in code behind.

so far this is my code in javascript where the chart is drawn, testarray1,2, represents the data

  function draw(d) {

           var testarray = JSON.parse(a);
           var testarray1 = JSON.parse(a1);
           var testarray2 = JSON.parse(a2);



           $(function() {

               $('#container1').highcharts({
                   chart: {

                       type: 'column'
                   },

                   credits: {
                       enabled: false
                   },
                   title: {
                       text: 'Consumption by months'
                   },
                   xAxis: {
                       categories: array3
                   },
                   yAxis: {
                       title: {
                           text: 'kWh'
                       }
                   },
                   tooltip: {
                       valueDecimals: 2
                   },

                   plotOptions: {
                       type: 'column'
                   },

                   series: [{

                   name: '2011-2012',
                   type: 'column',
                   color: '#0000FF',
                   data: testarray
                   },

           {
               name: '2012-2013',
               type: 'column',
               color: '#92D050',
               data: testarray1


  }]
               });
           });


              }

my output just shows the same data. what i need is some logic in the function draw do it refreshes when it draws, i have something like this.

           var a = testarray
           var b = testarray1

           if (d == 1)

            {
               var c = a

          }

          else if (d == 2)
          {
              var c = b
              }


              else if (d == 1)
           {
               var d = a

           }
           else if (d == 1)
           {
               var d = b

           }

with this i call c and d in the data. but i need a logic for 3 types of data, testarray, testarray1 and testarray2.

any ideas.

4

0 回答 0