maideen kader

maideen kader

  • NA
  • 155
  • 0

How to change color of column in column chart using asp.net?

Apr 16 2020 8:26 PM
Hi
 
Pls adviceme to change color of each column in column chart

Below code works fine in only one color. I have 12 month. How to change the color of each month

Pls advice me

Thank you.
maideen
 
this is my code
 
  1. <script>  
  2.     var chartData; // globar variable for hold chart data  
  3.     google.load("visualization""1", { packages: ["corechart"] });  
  4.     // Here We will fill chartData  
  5.     $(document).ready(function () {  
  6.         $.ajax({  
  7.             url: "Default.aspx/LoadTotalQR_Month",  
  8.             data: "",  
  9.             dataType: "json",  
  10.             type: "POST",  
  11.             contentType: "application/json; chartset=utf-8",  
  12.             success: function (data) {  
  13.                 chartData = data.d;  
  14.             },  
  15.             error: function () {  
  16.                 alert("Error loading data! Please try again.");  
  17.             }  
  18.         }).done(function () {  
  19.             // after complete loading data  
  20.             google.setOnLoadCallback(drawChart_C);  
  21.             drawChart_C();  
  22.         });  
  23.     });  
  24.     function drawChart_C() {  
  25.         var data = google.visualization.arrayToDataTable(chartData);  
  26.         var options = {  
  27.             title: "",  
  28.             pointSize: 5  
  29.         };  
  30.         var columnChart = new google.visualization.ColumnChart(document.getElementById('column-chart1'));  
  31.         columnChart.draw(data, options);  
  32.     }  
  33. </script> 
 
  1. <WebMethod()>  
  2. Public Shared Function LoadTotalQR_Month() As List(Of Object)  
  3.   
  4.     Dim query As String = "SELECT SUM(AMOUNT) AS AMOUNT,MonthName,monthno FROM [dbo].[DP_Receipt_Head] " &  
  5.                           "WHERE YEARNO =  @YearNo Group BY MonthName,monthno order by Monthno"  
  6.     Dim constr As String = ConfigurationManager.ConnectionStrings("ConnectString").ConnectionString  
  7.     Dim CharData_AREA As New List(Of Object)()  
  8.     CharData_AREA.Add(New Object() {"MonthName""AMOUNT"})  
  9.     Using con As New SqlConnection(constr)  
  10.         Using cmd As New SqlCommand(query, con)  
  11.             cmd.Parameters.AddWithValue("@YearNo"Date.Today.Year)  
  12.             con.Open()  
  13.             Using sdr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection)  
  14.                 While sdr.Read()  
  15.                     CharData_AREA.Add(New Object() {sdr("MonthName"), sdr("AMOUNT")})  
  16.                 End While  
  17.             End Using  
  18.             Return CharData_AREA  
  19.         End Using  
  20.     End Using  
  21. Function 

Answers (3)