Hi
I have a winchart showing the cyclenumber on the x-axis and some electrical power information on the y-axis.
A row in the datatable has three columns
ist_zyklen (=cyclenumber)
yAchse (=electrical power information (its a variable for the desired y column from the datatable))
date (a date)
with the code below, I get labels for the cyclenumbers on the x-Axis, e.g.
|
_____________________________________________________________________________
3e+01 5e+01 8e+01 etc
what I need is to show the labels including the date value.
06/18/2015 08:03 06/18/2015 09:11 06/18/2015 10:32
I tried to add the "labelColumn" for the series1.DataBind(dt, "ist_zyklen", yAchse, <labelColumn>);
but with no success
public void setGraphics(DataTable dt, string yAchse, UltraChart chart, double? xMin, double? xMax, double? yMin, double? yMax) { chart.ChartType = ChartType.Composite; ChartArea area = new ChartArea(); chart.CompositeChart.ChartAreas.Add(area); AxisItem axisX = new AxisItem(); axisX.Labels.ItemFormat = AxisItemLabelFormat.DataValue; axisX.Labels.ItemFormatString = "<DATA_VALUE:E1>"; axisX.RangeType = AxisRangeType.Custom; axisX.RangeMin = (double)(xMin ?? 0); axisX.RangeMax = (double)(xMax == 0 || xMax == null ? Math.Round(getMax(dt, "ist_zyklen")) * 1.1 : xMax); axisX.LogBase = 1000000; axisX.Labels.Orientation = TextOrientation.Horizontal; axisX.Extent = 60; area.Axes.Add(axisX); AxisItem axisY = new AxisItem(); axisY.Labels.ItemFormatString = "<DATA_VALUE:####.##>"; axisY.RangeType = AxisRangeType.Custom; axisY.RangeMin = (double)(yMin ?? 0); axisY.RangeMax = (double)(yMax == 0 || yMax == null ? Math.Round(getMax(dt, yAchse)) * 1.1 : yMax); axisY.OrientationType = AxisNumber.Y_Axis; axisY.Extent = 30; axisY.Margin.Far.Value = 15; area.Axes.Add(axisY); XYSeries series1 = new XYSeries(); series1.DataBind(dt, "ist_zyklen", yAchse); series1.PEs.Add(new PaintElement(Color.SteelBlue)); ChartLayerAppearance myColumnLayer = new ChartLayerAppearance(); myColumnLayer.ChartType = ChartType.ScatterChart; myColumnLayer.ChartArea = area; myColumnLayer.Series.Add(series1); myColumnLayer.AxisX = axisX; myColumnLayer.AxisY = axisY; chart.CompositeChart.Series.Add(series1); chart.CompositeChart.ChartLayers.Add(myColumnLayer);
...
Hello,
You can accomplish this by implementing IRenderLabel. Please take a look at this article for details on how to use IRenderLabel.
Please let me know if you have any questions.
I've already seen this example but don't know how to continue..
In the example, there is a fixed value concatenated to the corresponding data value. The data value is referenced as (double)context["DATA_VALUE"];
double
But how can I reference another column of the datasource?
What I understand is that I have a hashtable with one entry , MyIRenderLabelClass. In the context (in ToString()), I can access the the data values with DATA_VALUE.
How can I access the date column? What I need would be something like (datetime)context["Other_Column"] to be able to return in the ToString
(double)context["DATA_VALUE"] + Environment.NewLine + (datetime)context["Other_Column"]
I simply don't know how to achieve the latter...
The context Hashtable doesn't provide access to other columns in the datasource, so this will need to be done in another way. I attached a sample here that demonstrates one way it might be accomplished. In my sample, I'm passing the DataTable to the IRenderLabel-inherited class, then using the DATA_VALUE to access the associated value in the DataTable. I also set up some layout properties to get the labels to look the way you described in your earlier post.
Please look over the sample and let me know if you find it helpful.
that solved my problem, thx for the support!