A forum dedicated to WPF version of LightningChart Ultimate.
Moderator: Queue Moderators
-
ussainik
- Posts: 7
- Joined: Tue Oct 24, 2017 9:39 pm
Post
by ussainik » Wed Oct 25, 2017 7:07 pm
I have a requirement where I have a Slider and it has two options top and bottom. When the value is Top I need to move
the data labels associated to the Chart Markers to the top and when its bottom I need to move the data labels to the bottom.
When the error bars height is small it works fine. But when the error bars height is big, this is the problem. Please see
the screen shot.
Here is the code that I am doing for aligning the DataLabels.
Code: Select all
public void AlignChartDataLabelsToporBottom(ChartMarkerLabelPosition value)
{
try
{
VerticalChartDataLabelAlignment = value;
if (Chart.ViewXY == null || Chart.ViewXY.FreeformPointLineSeries.Count < 1)
{
return;
}
for (int i = 0; i < Chart.ViewXY.FreeformPointLineSeries.Count; i++)
{
foreach (var item in Chart.ViewXY.FreeformPointLineSeries[i].SeriesEventMarkers)
{
item.Label.HorizontalAlign = AlignmentHorizontal.Center;
if (value == ChartMarkerLabelPosition.Top)
{
item.Label.VerticalAlign = AlignmentVertical.Top;
}
else if (value == ChartMarkerLabelPosition.Bottom)
{
item.Label.VerticalAlign = AlignmentVertical.Bottom;
}
}
}
}
catch (Exception exception)
{
SystemDebugLogLogger.LogError(exception);
}
}
-
Attachments
-
- ChartMarkerLableBottom.png (140.21 KiB) Viewed 8489 times
-
ArctionKestutis
- Posts: 555
- Joined: Mon Mar 14, 2016 9:22 am
Post
by ArctionKestutis » Thu Oct 26, 2017 8:30 am
Hello,
We would need the rest of application for testing. Or at least the part how you created SeriesEventMarker.
For example I created Marker at the same position as Point with following settings:
Code: Select all
for (int i = 0; i < pointCount; i++)
{
SeriesEventMarker seriesMarker = new SeriesEventMarker();
seriesMarker.XValue = points[i].X;
seriesMarker.YValue = points[i].Y;
seriesMarker.Symbol.Shape = Shape.Triangle;
seriesMarker.HorizontalPosition = SeriesEventMarkerHorizontalPosition.AtXValue;
seriesMarker.VerticalPosition = SeriesEventMarkerVerticalPosition.AtYValue;
seriesMarker.Label.HorizontalAlign = AlignmentHorizontal.Center;
seriesMarker.Label.VerticalAlign = AlignmentVertical.Bottom;
seriesMarker.Label.Distance = 20;
seriesMarker.Label.Text = seriesMarker.XValue.ToString("0");
series.SeriesEventMarkers.Add(seriesMarker);
}
Then in Chart's doubleClicking event handler I was flipping between Label.VerticalAlign Top-Bottom. I did not see any problem - Label is, as intended, above or below point.
-
ussainik
- Posts: 7
- Joined: Tue Oct 24, 2017 9:39 pm
Post
by ussainik » Thu Oct 26, 2017 7:09 pm
Hi here is the code how we created the Series event maker.
Code: Select all
public SeriesEventMarker CreateMarker(string text, double xVal, double yVal,
Shape shape, float angle)
{
//height = ChartMarkerHeightValue;
//width = ChartMarkerWidthValue;
//m_SeriesEventMarkerFontSize = ChartDataLabelFontSizeValue;
SeriesEventMarker marker = new SeriesEventMarker();
marker.MouseInteraction = true;
marker.MoveByMouse = false;
marker.Label.Font = m_ChartFontForSeriesEventMarker;
marker.Label.Font.Size = ChartDataLabelFontSizeValue; //this line may not be needed
marker.Label.Text = text;
marker.Label.HorizontalAlign = AlignmentHorizontal.Center;
marker.Label.Color = Colors.Black;
switch (VerticalChartDataLabelAlignment)
{
case ChartMarkerLabelPosition.Top:
{
marker.Label.VerticalAlign = AlignmentVertical.Top;
break;
}
case ChartMarkerLabelPosition.Bottom:
{
marker.Label.VerticalAlign = AlignmentVertical.Bottom;
break;
}
}
//marker.Label.VerticalAlign = AlignmentVertical.Top;
//marker.Label.Font = new WpfFont(FontFamily.GenericSansSerif, 10f, FontStyle.Bold);
marker.Symbol.Shape = shape;
marker.Symbol.Angle = angle;
marker.Symbol.Width = ChartMarkerWidthValue;
marker.Symbol.Height = ChartMarkerHeightValue;
marker.XValue = xVal;
marker.YValue = yVal;
marker.VerticalPosition = SeriesEventMarkerVerticalPosition.AtYValue;
return marker;
}
-
ArctionKestutis
- Posts: 555
- Joined: Mon Mar 14, 2016 9:22 am
Post
by ArctionKestutis » Fri Oct 27, 2017 6:19 am
Hi,
As far as I can, you are using similar Marker's settings as I did in my example.
I don't see any problem and I am not aware about any related bug.
You should tell what is wrong in your screenshot. Should labels be below, at around Y=0? How long error bar should be for labels not to flip?
Are you using bindable WPF edition of LightningChart (which version)?
Is it possible to send simplest version of your app, where issue is reproducible?
All the best.
-
ussainik
- Posts: 7
- Joined: Tue Oct 24, 2017 9:39 pm
Post
by ussainik » Fri Oct 27, 2017 7:48 pm
Hi In the screen shot when the Vertical Align is set to bottom typically, I expect the datalabels to move to the bottom of the marker below the error. But it is on top of the maker on the error bar. Is that possible to do or should I send a sample project.
Thank You,.
-
ArctionKestutis
- Posts: 555
- Joined: Mon Mar 14, 2016 9:22 am
Post
by ArctionKestutis » Sat Oct 28, 2017 12:43 pm
As I wrote, I could not see any problem with short or long error bars. With similar setting for Marker, labels have been flipping to top or bottom just fine.
Please send the sample project for testing.