Increase the size of error bars with Chart Marker Sizes.

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
ussainik
Posts: 7
Joined: Tue Oct 24, 2017 9:39 pm

Increase the size of error bars with Chart Marker Sizes.

Post by ussainik » Fri Nov 03, 2017 5:51 pm

Right now I have a requirement to increase and decrease the width of the Chart Makers. Problem is initially when the Chart Markers load up I can see the error bars. As the Chart Markers are increased in size, I cannot see the error bars. Its rendered inside the chart markers.

Please see the attachment.

Is there a way increase the size of the error bars with the Chart Makers height and width. Could you please post some sample code. Here is my code currently to increase the size of the Chart Markers.

Code: Select all

public void ChangeChartMarkersSize(double value)
		{
			try
			{
				ChartMarkerHeightValue = (float)value;
				ChartMarkerWidthValue = (float)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.Symbol.Height = (float)value;
						item.Symbol.Width = (float)value;
					}
				}

			}

			catch (Exception exception)
			{
				SystemDebugLogLogger.LogError(exception);
			}
		}
Here is how the Chart markers are created.

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;
		}
Attachments
DownloadAttachment.png
DownloadAttachment.png (112.33 KiB) Viewed 9624 times

ArctionKestutis
Posts: 552
Joined: Mon Mar 14, 2016 9:22 am

Re: Increase the size of error bars with Chart Marker Sizes.

Post by ArctionKestutis » Mon Nov 06, 2017 10:28 am

Hello,

If you want to set different length of Error-Bars, you just need to insert proper length in SeriesErrorPoint(double x, double y, double errorXMinus, double errorXPlus, double errorYMinus, double errorYPlus) method. Or change corresponding fields of PointsWithErrors.

However, probably you asking about changing rendering order. That is, you want Error-Bars be visible, in front of marker. It is not straightforward, but doable. By LightningChart design Error-Bars are rendered before Line and Points is rendered, and Markers rendered at the end. There are two ways to get around this. First, you could create two (FreeformPoint)LineSeries. One is dummy just to have all your markers (to be rendered first), and next one to contain SeriesErrorPoints. Second way, instead of ErrorPoint use LineCollection as show in "Box-whisker plot" example of our Demo ap (XY -> Others).

Hope this helps.
All the best.

ussainik
Posts: 7
Joined: Tue Oct 24, 2017 9:39 pm

Re: Increase the size of error bars with Chart Marker Sizes.

Post by ussainik » Tue Nov 07, 2017 1:12 am

Hi I am trying the following approach just to see if the error bars increase in height and width. But the following code dosen't seem to do anything. Can you please help what I am doing wrong.

Code: Select all

public void ChangeChartMarkersSize(double value)
		{
			try
			{
				ChartMarkerHeightValue = (float)value;
				ChartMarkerWidthValue = (float)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.Symbol.Height = (float)value;
						item.Symbol.Width = (float)value;
					}

					SeriesErrorPoint[] errorPoints = Chart.ViewXY.FreeformPointLineSeries[i].PointsWithErrors;
					for (int e = 0; e < errorPoints.Count(); e++)
					{
						//errorPoints[e].X  = 1;
						//errorPoints[e].Y  = 1;
						errorPoints[e].ErrorXPlus = errorPoints[e].ErrorXPlus + 3;
						errorPoints[e].ErrorXMinus = errorPoints[e].ErrorXMinus + 3;
						errorPoints[e].ErrorYPlus = errorPoints[e].ErrorYPlus + 3;
						errorPoints[e].ErrorYMinus = errorPoints[e].ErrorYMinus + 3;
					}
				}
			}

ArctionKestutis
Posts: 552
Joined: Mon Mar 14, 2016 9:22 am

Re: Increase the size of error bars with Chart Marker Sizes.

Post by ArctionKestutis » Tue Nov 07, 2017 10:19 am

Then you changing properties this way, you should inform chart that draw-data need to be recreated. Please add line

Code: Select all

Chart.ViewXY.FreeformPointLineSeries[i].InvalidateData();
at the end of your FOR loop.

It is also good idea to keep everything between Chart.BeginUpdate() and Chart.EndUpdate() method calls. If you programmatically change more than one property at same time, you should make the property changes between BeginUpdate() and EndUpdate() method calls, as a batch. BeginUpdate() will stop drawing the control until EndUpdate() is called.

ussainik
Posts: 7
Joined: Tue Oct 24, 2017 9:39 pm

Re: Increase the size of error bars with Chart Marker Sizes.

Post by ussainik » Thu Nov 09, 2017 1:49 am

Thanks it works.

Post Reply