SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

0
0

Hi,
Is there solution to always display series name below the line on the chart, not in legen, but I need to hide legend and I do not know what is series name. Thank You

  • You must to post comments
0
0

Hi there,

Sure, all you need to do is to add a TextAnnotation to your chart and to set TextAnnotation.Text = RenderableSeries.DataSeries.SeriesName.

I suggest doing this inside the SciChartSurface.RenderedEvent and repositioning as you zoom and pan.

To position the annotation, set X1,Y1 equal to a point just below the line. You can use the following API to determine the location where to put the annotation:

var xRange = renderableSeries.XAxis.VisibleRange;
var visiblePoints = renderableSeries.DataSeries.GetIndicesRange(xRange);

// Compute the X-Value at the end (right) of the viewport
// To compute left, use visiblePoints.Min instead
var xValue = (IComparable)renderableSeries.DataSeries.XValues[visiblePoints.Max];

// Compute the Y-value at the end (right) of the viewport
// To compute left, pass new Point(0,0) instead
var hitTest = renderableSeries.VerticalSliceHitTest(new Point(SciChartSurface.ModifierSurface.ActualWidth - 1, 0), true);
var yValue = hitTest.YValue;

// Set X,Y value of TextAnnotation
textAnnotation.X1 = xValue;
textAnnotation.Y1 = yValue;

// Set alignment of TextAnnotation
textAnnotation.HorizontalAnchorPoint = HorizontalAnchorPoint.Right;
textAnnotation.VerticalAnchorPoint= VerticalAnchorPoint.Top;

Let me know if this helps,

Best regards,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.