See attached image. I would like to set the labels under each of the bars in my bar chart. They are currently just 1, 2, and 3. How would I could about manually setting them?
Here is my code for building that chart:
Here is my code for building that chart:
protected
void
makeStockChart()
{
RadChart stockChart =
new
RadChart();
stockChart.ChartTitle.Visible =
false
;
stockChart.Appearance.Border.Visible =
false
;
stockChart.Legend.Appearance.Visible =
false
;
stockChart.PlotArea.YAxis.Appearance.Visible = Telerik.Charting.Styles.ChartAxisVisibility.False;
stockChart.PlotArea.Appearance.FillStyle.MainColor = System.Drawing.Color.White;
stockChart.PlotArea.Appearance.FillStyle.SecondColor = System.Drawing.Color.White;
stockChart.PlotArea.Appearance.Border.Color = System.Drawing.Color.White;
// Create a ChartSeries and assign its name and chart type
ChartSeries chartSeries =
new
ChartSeries();
chartSeries.Name =
"Count"
;
chartSeries.Type = ChartSeriesType.Bar;
// Open SQL Connection
SqlConnection connection =
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"ConnectionString"
].ConnectionString);
connection.Open();
SqlCommand command =
new
SqlCommand(
"GetStockData"
, connection);
command.CommandType = CommandType.StoredProcedure;
SqlDataReader reader = command.ExecuteReader();
while
(reader.Read())
{
// Pretty up the value
string
value =
string
.Format(
"{0:d}"
, (reader.GetValue(1)));
// Set value and value text
ChartSeriesItem chartSeriesItem =
new
ChartSeriesItem(Convert.ToDouble(reader.GetValue(1)), value);
chartSeriesItem.Name = reader.GetValue(0).ToString();
chartSeries.AddItem(chartSeriesItem);
}
// Close SQL Connection
connection.Close();
// add the series to the RadChart Series collection
stockChart.Series.Add(chartSeries);
// add the RadChart to the page.
this
.stockChart.Controls.Add(stockChart);
}