private void UpdateChrtZipCodes(DataSet ds)
{
chrtZipCode.Legend.Visible =
false;
chrtZipCode.PlotArea.XAxis.Clear();
EmptySeriesMessage message = chrtZipCode.PlotArea.EmptySeriesMessage;
message.TextBlock.Text =
"No Data Available.";
//if (ds.Tables[0].Rows.Count > 20)
// chrtZipCode.Height = (ds.Tables[0].Rows.Count * 20); tried this and it made it too long
chrtZipCode.AutoLayout = true;
chrtZipCode.PlotArea.XAxis.AutoScale =
false;
foreach (DataRow dbRow in ds.Tables[0].Rows)
{
chrtZipCode.PlotArea.XAxis.AddItem(
new ChartAxisItem(dbRow["ZipCode"].ToString()));
}
chrtZipCode.PlotArea.XAxis.LayoutMode =
ChartAxisLayoutMode.Between;
// Gets the one and the only series in the chart.
ChartSeries s0 = chrtZipCode.Series.GetSeries(0);
// If it doesn't exist - create and set it.
if (s0 == null)
{
s0 = chrtZipCode.CreateSeries(
string.Empty, Color.Empty, Color.Empty, ChartSeriesType.Bar);
}
s0.Type =
ChartSeriesType.Bar;
s0.Appearance.ShowLabels =
true;
s0.DefaultLabelValue =
"#Y";
s0.DataYColumn =
"TheCount";
s0.Appearance.LabelAppearance.FillStyle.MainColor =
Color.White;
s0.Appearance.LabelAppearance.Border.Color =
Color.Black;
s0.Appearance.TextAppearance.TextProperties.Color =
Color.Black;
// Clear series items.
s0.Clear();
// Set new items for the series.
foreach (DataRow dbRow in ds.Tables[0].Rows)
{
ChartSeriesItem seriesItem = new ChartSeriesItem();
seriesItem.YValue =
Convert.ToDouble(dbRow["TheCount"]);
seriesItem.Appearance.Border.Color =
Color.Black;
s0.Items.Add(seriesItem);
}
}