How do I show string values on the x axis of a chart control ? the datapoints (x & y) are both double. I have an IEnumerable containing a list of objects with 2 properties. The name of a report and an integer value indicating how many times it was run. so the integer is on the y axis and the report name is on the x axis. But I only seem to have double options for the value types. So when I create my datapoint, Im geting an error
DataPoint p1 = new DataPoint();
p1.XValue = log.ReportName; ---> this is invalid
p1.YValues = new Double[] { log.ReportTotal };
how can this be done ?
Ive tried this
reportTotal.XValueType = ChartValueType.String;
and when I plot my datapoints, Ive done this
int i = 1;
foreach (var log in this._reportLogs)
{
DataPoint p1 = new DataPoint();
p1.XValue = (double)i;
p1.YValues = new Double[] { log.ReportFrequency };
i++;
reportTotal.Points.Add(p1);
}
but now all im getting along the x axis are the number of the i varaible, how on earth do I just get the content of the text property ?
this is how I made it work
Dictionary<string, int> ReportLogs = new Dictionary<string, int>();
foreach (var log in this._reportLogs)
ReportLogs.Add(log.ReportName, log.ReportFrequency);
foreach (KeyValuePair<string, int> log in ReportLogs)
reportTotal.Points.AddXY(log.Key, log.Value);