Page 1 of 1

Data Label for the Chart Marker are not aligning bottom

Posted: Wed Oct 25, 2017 7:07 pm
by ussainik
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);
			}
		}

Re: Data Label for the Chart Marker are not aligning bottom

Posted: Thu Oct 26, 2017 8:30 am
by ArctionKestutis
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.

Re: Data Label for the Chart Marker are not aligning bottom

Posted: Thu Oct 26, 2017 7:09 pm
by ussainik
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;
		}

Re: Data Label for the Chart Marker are not aligning bottom

Posted: Fri Oct 27, 2017 6:19 am
by ArctionKestutis
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.

Re: Data Label for the Chart Marker are not aligning bottom

Posted: Fri Oct 27, 2017 7:48 pm
by ussainik
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,.

Re: Data Label for the Chart Marker are not aligning bottom

Posted: Sat Oct 28, 2017 12:43 pm
by ArctionKestutis
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.