Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1175
Showing Data Values on Chart
posted

I have this code

ChartTextAppearance chartText = new ChartTextAppearance();

chartText.Row = chartText.Column = -2;

chartText.Visible = true;

chartText.ItemFormatString = "<DATA_VALUE:0>";

ctrlUltraChart.ColumnChart.ChartText.Add(chartText);

 

but the hard coded reference to ColumnChart will not work for me since I let the user select the chart type, is there any way to set the chart text and let the user select the chart type? Thank you, Jamie

Parents
  • 26458
    Verified Answer
    Offline posted

    Try using reflection to get the ChartTypeAppearance property based on the current chart type:

    PropertyInfo chartAppearancePoperty = ultraChart1.GetType().GetProperty(ultraChart1.ChartType.ToString());
    if (chartAppearancePoperty != null)
    {
       ChartTypeAppearance chartAppearance = chartAppearancePoperty.GetValue(ultraChart1, null) as ChartTypeAppearance;
       PropertyInfo chartTextProperty = chartAppearance.GetType().GetProperty("ChartText");
       if (chartTextProperty != null)
       {
          ChartTextCollection chartTextCollection = chartTextProperty.GetValue(chartAppearance, null) as ChartTextCollection;
          if (chartTextCollection != null)
          {
             chartTextCollection.Add(myChartText);
          }
       }
    }

Reply Children
No Data