I have a chart that is almost generating like I'd like it to. The only thing that is missing is the Labels for the Legend. I currently have the Legend set to display ItemLabels. I thought I set the item labels when I added the item, but apparently not. How do I go about setting these ItemLabels? Below is the code I'm using to build the Chart, and attached is an image of what the chart currently looks like.
reader.GetValue(2) will pull the label text from the database.
CODE
reader.GetValue(2) will pull the label text from the database.
CODE
protected
void
makechart()
{
RadChart invChart =
new
RadChart();
invChart.ChartTitle.Visible =
false
;
// Create a ChartSeries and assign its name and chart type
ChartSeries chartSeries =
new
ChartSeries();
chartSeries.Name =
"TotalValue"
;
chartSeries.Type = ChartSeriesType.Pie;
// Display Item Labels in the Legend
chartSeries.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;
// Open SQL Connection
SqlConnection connection =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"ConnectionString"
].ConnectionString);
connection.Open();
SqlCommand command =
new
SqlCommand(
"GetInventoryValue"
, connection);
command.CommandType = CommandType.StoredProcedure;
SqlDataReader reader = command.ExecuteReader();
while
(reader.Read())
{
// Set value and value text
chartSeries.AddItem((Double)(reader.GetValue(0)), reader.GetValue(0).ToString());
}
// Close SQL Connection
connection.Close();
// add the series to the RadChart Series collection
invChart.Series.Add(chartSeries);
// add the RadChart to the page.
this
.invChart.Controls.Add(invChart);
}
}