|
this.chartControl1.PrimaryXAxis.TickLabelsDrawingMode = ChartAxisTickLabelDrawingMode.UserMode;
this.chartControl1.ChartRegionClick += ChartControl1_ChartRegionClick;
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("1999", Color.Black, new Font("Arial", 8F, System.Drawing.FontStyle.Regular), 0, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("2000", Color.Black, new Font("Arial", 8F, System.Drawing.FontStyle.Regular), 1, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("2001", Color.Black, new Font("Arial", 8F, System.Drawing.FontStyle.Regular), 2, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("2002", Color.Black, new Font("Arial", 8F, System.Drawing.FontStyle.Regular), 3, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("2003", Color.Black, new Font("Arial", 8F, System.Drawing.FontStyle.Regular), 4, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("2004", Color.Black, new Font("Arial", 8F, System.Drawing.FontStyle.Regular), 5, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("2005", Color.Black, new Font("Arial", 8F, System.Drawing.FontStyle.Regular), 6, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("2006", Color.Black, new Font("Arial", 8F, System.Drawing.FontStyle.Regular), 7, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("2007", Color.Black, new Font("Arial", 8F, System.Drawing.FontStyle.Regular), 8, "", ChartValueType.Custom));
this.chartControl1.PrimaryXAxis.Labels.Add(new ChartAxisLabel("2008", Color.Black, new Font("Arial", 8F, System.Drawing.FontStyle.Regular), 9, "", ChartValueType.Custom));
|
|
int previousIndex = -1;
private void ChartControl1_ChartRegionClick(object sender, ChartRegionMouseEventArgs e)
{
ChartControl series = sender as ChartControl;
int axisIndex = e.Region.AxisLabelIndex;
if (previousIndex != -1)
{
ChartAxisLabel previousChartAxisLabel = (chartControl1.PrimaryXAxis.Labels[previousIndex]) as ChartAxisLabel;
previousChartAxisLabel.Font = new Font(FontFamily.GenericMonospace, 8f, FontStyle.Regular);
chartControl1.PrimaryXAxis.Labels.RemoveAt(previousIndex);
chartControl1.PrimaryXAxis.Labels.Insert(previousIndex, previousChartAxisLabel);
}
ChartAxisLabel chartAxisLabel = (chartControl1.PrimaryXAxis.Labels[axisIndex]) as ChartAxisLabel;
chartAxisLabel.Font = new Font(FontFamily.GenericMonospace, 12f, FontStyle.Bold);
chartControl1.PrimaryXAxis.Labels.RemoveAt(axisIndex);
chartControl1.PrimaryXAxis.Labels.Insert(axisIndex, chartAxisLabel);
previousIndex = axisIndex;
}
|