Hi,
First, can X-axis of Scatter Chart set as DateTime?
At the moment, I have tried getting values for x-axis as String and also as DateTime, but none of them work.
In my axis setting, I have done the following:
_chart.Axis.X.Labels.ItemFormatString = "<DATA_VALUE:MM/dd/yyyy>"
(And tried "<DATA_VALUE:MM-dd-yyyy>", <DATA_VALUE:mm-dd-hh> , and all other time syntax)
However, I always got on the graph as the FormatString (and not populated with the actual data).
Am I missing something, or Scatter Chart simply do not support this???
Nevermind, I was mistaken, it works.
My code is pretty much the same:
IRenderLabel:
context)
{
.Empty;
];
.FromOADate(dataValue);
label = dt.ToString("HH:mm");
label;
Here's the graph code:
DateTime
xValueDateTime;
DateTime.TryParse(xygValueCombo.XValue.ToString(), out xValueDateTime);
double xAOValue = xValueDateTime.ToOADate();
series.Points.Add(
new XYDataPoint(xAOValue, yDoubleValue, xValueDateTime.ToString("HH:mm"), false));
and finally...
graph.Axis.X.Labels.ItemFormatString =
"<MY_VALUE>";
Hashtable myLabelHashTable = new Hashtable();
myLabelHashTable.Add(
"MY_VALUE", new DateTimeLabelRender());
graph.LabelHash = myLabelHashTable;
I tried:
this.ultraChart1.ChartType = ChartType.ScatterChart;
XYSeries series = new XYSeries();
for (int i = 0; i < 10; i++)
series.Points.Add(new XYDataPoint(DateTime.Now.AddMinutes(i).ToOADate(), i, i.ToString(), false));
}
this.ultraChart1.Series.Add(series);
this.ultraChart1.Axis.X.Labels.ItemFormatString = "<MY_VALUE>";
Hashtable MyLabelHashTable = new Hashtable();
MyLabelHashTable.Add("MY_VALUE", new MyLabelRenderer());
this.ultraChart1.LabelHash = MyLabelHashTable;
…
public class MyLabelRenderer : IRenderLabel
public string ToString(Hashtable context)
double dataValue = (double)context["DATA_VALUE"];
DateTime datetime = DateTime.FromOADate(dataValue);
return datetime.ToString();
And it seems ok. Can you send us your code, so we can investigate it?
This works for me but when the double value of the axis gets passed to my class that implements IRenderLabel, the value is truncated resulting in a different time when I call
DateTime.FromOADate(axisValue)
Why is the axisValue being passed to the IRenderLabel interface being truncated?
Scatter Chart works only with numeric axis, so it is not possible setting DateTime values.
double axisValue = dateTime.ToOADate();
add them to the chart and show the labels with using IRenderLabel interface:
http://help.infragistics.com/Help/NetAdvantage/NET/2008.3/CLR2.0/html/Chart_Customize_Labels_Using_the_IRenderLabel_Interface.html
and converting the double values to DateTime:
string label = DateTime.FromOADate(axisValue).ToString();