Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Series sr = new Series();
- sr.Name = "A";
- sr.Points.DataBindXY(xValues, yValues);
- sr.ChartType = SeriesChartType.StackedBar;
- sr.Font = new System.Drawing.Font("Tahoma", 8, System.Drawing.FontStyle.Bold);
- for (int i = 0 ; i < xValues.Lenght; i++) //xValues.Lenght = 4 in this case where you have 4 Data number
- {
- if(i == 0) // Don't forget xValues[0] is Data4 in your case
- sr.Points[i].Color = Dr.Color.Black;
- else
- sr.Points[i].Color = Dr.Color.Yellow;
- }
- google.charts.load('current', {'packages':['corechart']});
- google.charts.setOnLoadCallback(drawVisualization);
- function drawVisualization(){
- // 0 1 2 3 4 5 6 7 8
- var ob=[
- ['Date', 'A11','A11state', 'A12','A12state', 'B12','B12state', 'B13','B13state' ],
- ['20040501', 1, 1, 1, 0, 1, 1, 1, 0],
- ['20050601', 1, 0, 1, 0, 1, 1, 1, 1],
- ['20060701', 1, 1, 1, 1, 1, 0, 1, 0],
- ['20070801', 1, 0, 1, 1, 1, 0, 1, 1],
- ['20050601', 1, 1, 1, 0, 1, 1, 1, 0],
- ['20080901', 1, 0, 1, 0, 1, 1, 1, 1]
- ];
- var data = google.visualization.arrayToDataTable(ob);
- var view = new google.visualization.DataView(data);
- view.setColumns([0, 1,
- {calc: function (dt, row) {if (dt.getValue(row, 2) == 1) {return "maroon"; }else{return "olive"; }}, type: 'string', role: 'style'}, //2
- 3,
- {calc: function (dt, row) {if (dt.getValue(row, 4) == 1) {return "maroon"; }else{return "olive"; }}, type: 'string', role: 'style'}, //4
- 5,
- {calc: function (dt, row) {if (dt.getValue(row, 6) == 1) {return "maroon"; }else{return "olive"; }}, type: 'string', role: 'style'}, //6
- 7,
- {calc: function (dt, row) {if (dt.getValue(row, 8) == 1) {return "maroon"; }else{return "olive"; }}, type: 'string', role: 'style'}
- ]);
- var options = {
- title : 'representation of On/Off PinStates',
- vAxis: {title: 'PinStates'},
- hAxis: {title: 'Month'},
- seriesType: 'bars',
- isStacked: true
- };
- var e=document.getElementById("chart_div");
- var chart = new google.visualization.ComboChart(e);
- e.style.width=ob.length * 200;
Add Comment
Please, Sign In to add comment