2014年7月13日 星期日

[RESOLVED] C# Charting and text in chartArea


Hello there, I need your help.


I need print in my ChartArea this text extract from the query:


your last statement is the best way

I tried this way but in the ChartArea I've 0 value printed, why?


            Chart1.Series.Add("Series2");
Chart1.Series["Series2"].YValueMembers = "TheMessage";
Chart1.Series["Series2"].IsValueShownAsLabel = true;

Can you help me?

Thank you





In order to display text in chart area you should use this:


Chart1.Titles.Add(new Title("Title 1"));

If you need to display text on your axis, you should not edit YValueMembers as it is used to as data point required to build the chart. Instead try this:


 foreach (Series series in Chart1.Series)
{
foreach (DataPoint point in series.Points)
{ //if non-empty data point
if (point.YValues.Length > 0)
{
point.LegendText = point.AxisLabel;//In case you have legend
point.AxisLabel = "Products";
point.Label = "custom label";
}
}
}







thank you for help, but I don't need print the title of my chart, but in the chartarea the text value extracted from my db.


沒有留言:

張貼留言