Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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();
}
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900