Hi Team,
I am trying to bind google pie chart using below code.
I am expecting to have two options "YES" (65% with Yes option) and "NO" (35 % with No option).
However i can able to bind piechart with single color and after moving cursor over piechart it shows 65% and 35% label.
I want to display 65% in one color and 35% in another color.
Can any one help me in this? Thanks is advance.
What I have tried:
I have tried using below code.
private void BindChart()
{
DataTable dsChartData = new DataTable();
StringBuilder strScript = new StringBuilder();
try
{
dsChartData.Columns.Add("Task", typeof(int));
dsChartData.Columns.Add("Hours", typeof(int));
dsChartData.Rows.Add(65,35 );
strScript.Append(@"
google.load('visualization', '1', {packages: ['corechart']});
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Task', 'Hours of Day'],");
foreach (DataRow row in dsChartData.Rows)
{
strScript.Append("['" + row["Task"] + "'," + row["Hours"] + "],");
}
strScript.Remove(strScript.Length - 1, 1);
strScript.Append("]);");
strScript.Append(@" var options = {
title: 'My Daily Schedule',
is3D: true,
}; ");
strScript.Append(@"var chart = new google.visualization.PieChart(document.getElementById('piechart_3d'));
chart.draw(data, options);
}
google.setOnLoadCallback(drawChart);
");
strScript.Append(" ");
ltScripts.Text = strScript.ToString();
}
catch
{
}
finally
{
dsChartData.Dispose();
strScript.Clear();
}
}