Guest User

Untitled

a guest
Jun 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. Series sr = new Series();
  2. sr.Name = "A";
  3. sr.Points.DataBindXY(xValues, yValues);
  4. sr.ChartType = SeriesChartType.StackedBar;
  5. sr.Font = new System.Drawing.Font("Tahoma", 8, System.Drawing.FontStyle.Bold);
  6.  
  7. for (int i = 0 ; i < xValues.Lenght; i++) //xValues.Lenght = 4 in this case where you have 4 Data number
  8. {
  9. if(i == 0) // Don't forget xValues[0] is Data4 in your case
  10. sr.Points[i].Color = Dr.Color.Black;
  11. else
  12. sr.Points[i].Color = Dr.Color.Yellow;
  13. }
  14.  
  15. google.charts.load('current', {'packages':['corechart']});
  16. google.charts.setOnLoadCallback(drawVisualization);
  17. function drawVisualization(){
  18. // 0 1 2 3 4 5 6 7 8
  19. var ob=[
  20. ['Date', 'A11','A11state', 'A12','A12state', 'B12','B12state', 'B13','B13state' ],
  21. ['20040501', 1, 1, 1, 0, 1, 1, 1, 0],
  22. ['20050601', 1, 0, 1, 0, 1, 1, 1, 1],
  23. ['20060701', 1, 1, 1, 1, 1, 0, 1, 0],
  24. ['20070801', 1, 0, 1, 1, 1, 0, 1, 1],
  25. ['20050601', 1, 1, 1, 0, 1, 1, 1, 0],
  26. ['20080901', 1, 0, 1, 0, 1, 1, 1, 1]
  27. ];
  28. var data = google.visualization.arrayToDataTable(ob);
  29. var view = new google.visualization.DataView(data);
  30. view.setColumns([0, 1,
  31. {calc: function (dt, row) {if (dt.getValue(row, 2) == 1) {return "maroon"; }else{return "olive"; }}, type: 'string', role: 'style'}, //2
  32. 3,
  33. {calc: function (dt, row) {if (dt.getValue(row, 4) == 1) {return "maroon"; }else{return "olive"; }}, type: 'string', role: 'style'}, //4
  34. 5,
  35. {calc: function (dt, row) {if (dt.getValue(row, 6) == 1) {return "maroon"; }else{return "olive"; }}, type: 'string', role: 'style'}, //6
  36. 7,
  37. {calc: function (dt, row) {if (dt.getValue(row, 8) == 1) {return "maroon"; }else{return "olive"; }}, type: 'string', role: 'style'}
  38.  
  39.  
  40. ]);
  41. var options = {
  42. title : 'representation of On/Off PinStates',
  43. vAxis: {title: 'PinStates'},
  44. hAxis: {title: 'Month'},
  45. seriesType: 'bars',
  46. isStacked: true
  47. };
  48. var e=document.getElementById("chart_div");
  49. var chart = new google.visualization.ComboChart(e);
  50. e.style.width=ob.length * 200;
Add Comment
Please, Sign In to add comment