m ali
m ali

Reputation: 646

change y axis on highcahrts

my data is comming from a datatable on the behind code. i am redrawing the graph to show new data, but is it possible to change the y axis when data is redrawed?

code:

 function draw(d) {
          var testarray = JSON.parse(a);
           var testarray1 = JSON.parse(a1);
           var testarray2 = JSON.parse(a2);


           if (d == 1)

            {
                var c = testarray


          }

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


              else if (d == 3)
           {
               var d = testarray

           }
           else if (d == 4)
           {
               var d = testarray1

           }

           else if (d == 5) {
               var d = testarray1

           }


           else if (d == 6) {
               var d = testarray1

           }


       $(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


   }]
           });
       });


          }

so what i need is something to show on the y axis on testarray when that data is being called. in this case c and d.

behind code

      Case 1
            For Each row In Year1
                testarray.Add(row("data"))
            Next row

            For Each row In Year2
                testarray1.Add(row("data"))

            Next row

            For Each row In Year3
                testarray2.Add(row("data"))

            Next row


            Dim serializer1 As New JavaScriptSerializer()

            Dim arrayJsonTest1 As String = serializer1.Serialize(testarray)
            Dim arrayJson11 As String = serializer1.Serialize(testarray1)
            Dim arrayJson12 As String = serializer1.Serialize(testarray2)

            hidden.Value = arrayJsonTest1
            hidden1.Value = arrayJson11
            hidden2.Value = arrayJson12


            ScriptManager.RegisterStartupScript(Me.Page, Me.GetType, "draw",                  "javascript:draw(1);", True)

Upvotes: 1

Views: 55

Answers (2)

user2641077
user2641077

Reputation: 159

Pass an array from code backhand code and replace it with your testarray and testarray1.. So whenever you update the database and refresh the page, it will fetch the update record from database and redraw the updated graph..

If this answer suits for your problem, then comment and i will give you the sample of data array that you need to replace.

Upvotes: 1

Sebastian Bochan
Sebastian Bochan

Reputation: 37578

You can use update() function and modify yAxis parameters.

Upvotes: 1

Related Questions