I have a simple scatter chart to which I add a NumericTimeSeries.
I can switch on the data point labels and set the ItemFormatString = "<DATA_VALUE:##.##>".
But I cannot get it to display the Value from the NumericTimeSeries, I think it's trying to format the date using the format string!?
Is there a way of telling the chart to use the Value column from the NumericTimeSeries?
Many Thanks!
Hi Andy,
The ItemFormatString should be encoded as "<DATA_VALUE:n2>" when set by the aspx code. When set dynamically it should be "<DATA_VALUE:n2>".
I have attached my sample project with your sample code. Please, review it and let me know how it differs from yours.
Hmmm, Still not working!?
This is what I see with the ItemFormatString as suggested ...
It seems to me that the column it's trying to show is not the value column and it can't format it?
In the online sample https://es.infragistics.com/samples/aspnet/chart/scatter-chart the points have values just fine but these are from the X axis and the X axis in the sample is numerical not time based. I need to tell it to pull data from it's Y value for the label!?
Many Thanks for the support!
Andy.
Hi, excuse me for my misunderstanding. Try setting it to:
ItemFormatString="<DATA_VALUE:n2>"
This will display two decimal places. We use standard string formatting for the numeric labels. You can read about it in more detail here:https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-1.1/dwhawy9k(v=vs.71)
Many Thanks for the reply! Still not working though I'm afraid. Here is the code I'm using....
>>>>
//Setup DataSource
DataTable table = new DataTable();table.Columns.Add("Date", typeof(DateTime));table.Columns.Add("Value", typeof(double));
double minValue=0;double maxValue=0;
foreach (MyData data in dataList){ table.Rows.Add(new object[] { data.Date, data.Value }); if (exceedenceHistory.Value > 0 && exceedenceHistory.Value > maxValue) { maxValue = exceedenceHistory.Value; } if (exceedenceHistory.Value < 0 && exceedenceHistory.Value < minValue) { minValue = exceedenceHistory.Value; }}
NumericTimeSeries series = new NumericTimeSeries();series.Data.TimeValueColumn = "Date";series.Data.ValueColumn = "Value";series.Data.DataSource = table;series.DataBind();this.UltraChart1.Series.Add(series);
//Setup Chartthis.UltraChart1.ChartType = ChartType.ScatterChart;this.UltraChart1.ScatterChart.ConnectWithLines = true;this.UltraChart1.ScatterChart.LineAppearance.SplineTension = 0;this.UltraChart1.Data.UseMinMax = true;this.UltraChart1.Data.ZeroAligned = true;this.UltraChart1.Tooltips.FormatString = "Run DateTime : <DATA_VALUE_X:dd-MM-yyyy HH:mm>\r\n" +"Value : <DATA_VALUE_Y:##.##>mm";this.UltraChart1.ScatterChart.Icon = SymbolIcon.Circle;this.UltraChart1.ScatterChart.IconSize = SymbolIconSize.Medium;
//Setup X Axisthis.UltraChart1.Axis.X.Labels.ItemFormatString = "<DATA_VALUE:MMM-yyyy>";this.UltraChart1.Axis.X.LineThickness = 1;this.UltraChart1.Axis.X.Labels.ItemFormat = AxisItemLabelFormat.Custom;this.UltraChart1.Axis.X.Labels.Orientation = TextOrientation.Horizontal;this.UltraChart1.Axis.X.TickmarkStyle = AxisTickStyle.Smart;this.UltraChart1.Axis.X.TimeAxisStyle.TimeAxisStyle = RulerGenre.Continuous;
//Setup Y Axisthis.UltraChart1.Axis.Y.Labels.ItemFormatString = "<DATA_VALUE:##.##>";this.UltraChart1.Axis.Y.LineThickness = 1;this.UltraChart1.Axis.Y.Labels.ItemFormat = AxisItemLabelFormat.Custom;this.UltraChart1.Axis.Y.Labels.Orientation = TextOrientation.Horizontal;this.UltraChart1.Axis.Y.RangeType = AxisRangeType.Custom;this.UltraChart1.Axis.Y.RangeMin = minValue; //Calculate during datasource creation!this.UltraChart1.Axis.Y.RangeMax = maxValue; //Calculate during datasource creation!
//Setup Item Labelsthis.UltraChart1.ScatterChart.ChartText[0].Visible = true;this.UltraChart1.ScatterChart.ChartText[0].Column = -2;this.UltraChart1.ScatterChart.ChartText[0].Row = -2;this.UltraChart1.ScatterChart.ChartText[0].ItemFormatString = "<ITEM_LABEL:##.##>mm";
<<<<
I've tried using "<DATA_VALUE_Y:##.##>mm" as the format string as this works fine for the tooltip, but does not work for the item label, with the code above I get this as the output ...
Any help will be much appreciated!
Try setting the axis Labels property ItemFormatString="<ITEM_LABEL>".
You can read more about it from the following link:
https://es.infragistics.com/help/winforms/chart-display-data-on-a-time-scale-axis
Let me know if you have further problems.