Hello,
I need Constant Line for both X and Y axis, and for Y-axis I am able to use "Arction.Wpf.SemibindableCharting.SeriesXY.CONSTANTLINE", and add it to "ConstantLineCollection" .... but, I do not know, what to use for X-axis, how to add a constant line on a X-axis
Constant Line on X-axis
Moderator: Queue Moderators
-
- Posts: 141
- Joined: Wed Mar 27, 2019 1:05 pm
Re: Constant Line on X-axis
Hello,
Currently X-axes have no ConstantLines available like Y-axes do. However, there are several ways to draw something similar for X-axis. For example a Band, LineSeriesCursor, PolygonSeries or FreeformPointLineSeries could be used.
Of these Band is by far the best option. It can be bound to X-axis to have a vertical band or to Y-axis to have a horizontal band. Disabling MouseResize but allowing MoveByMouse results to exact same behaviour as with a ConstantLine.
ValueBegin and ValueEnd determine the width of the Band (can be set simultaneously via SetValues()).
Here is an example of adding a Band:
Hope this helps.
Best regards,
Lasse
Currently X-axes have no ConstantLines available like Y-axes do. However, there are several ways to draw something similar for X-axis. For example a Band, LineSeriesCursor, PolygonSeries or FreeformPointLineSeries could be used.
Of these Band is by far the best option. It can be bound to X-axis to have a vertical band or to Y-axis to have a horizontal band. Disabling MouseResize but allowing MoveByMouse results to exact same behaviour as with a ConstantLine.
ValueBegin and ValueEnd determine the width of the Band (can be set simultaneously via SetValues()).
Here is an example of adding a Band:
Code: Select all
Band band = new Band(_chart.ViewXY, _chart.ViewXY.XAxes[0], _chart.ViewXY.YAxes[0]);
band.Binding = AxisBinding.XAxis; // Vertical Band
band.MouseResize = false; // Cannot be resized by mouse
band.MoveByMouse = true; // Can be moved by mouse
band.Fill.Color = Colors.Red;
band.Fill.GradientFill = GradientFill.Solid;
band.SetValues(5, 6); // Set width
band.Behind = true; // Show behind other series
_chart.ViewXY.Bands.Add(band);
Best regards,
Lasse
Re: Constant Line on X-axis
and is there any chance to make the line of the Band to be "Dash" or "Dot" ?
-
- Posts: 141
- Joined: Wed Mar 27, 2019 1:05 pm
Re: Constant Line on X-axis
Hello,
That is unfortunately not possible with Bands, unless using Bitmap fills or ClipAreas to hide parts of the Band, but these would be unnecessarily complicated. Therefore if you need dashed or dotted pattern, I'd recommend using another option that is LineSeriesCursor, which in many ways is similar to a Band or a ConstantLine.
Cursors are mostly used to track series, but this feature can be disabled by setting SnapToPoints to false and CursorStyle to VerticalNotracking. After that the cursor behaves similarly to a ConstantLine.
Hope this helps.
Kind regards,
Lasse
That is unfortunately not possible with Bands, unless using Bitmap fills or ClipAreas to hide parts of the Band, but these would be unnecessarily complicated. Therefore if you need dashed or dotted pattern, I'd recommend using another option that is LineSeriesCursor, which in many ways is similar to a Band or a ConstantLine.
Cursors are mostly used to track series, but this feature can be disabled by setting SnapToPoints to false and CursorStyle to VerticalNotracking. After that the cursor behaves similarly to a ConstantLine.
Code: Select all
LineSeriesCursor cursor = new LineSeriesCursor(_chart.ViewXY, axisX);
cursor.ValueAtXAxis = 5; // Assign cursor to X-position 5.
cursor.SnapToPoints = false;
cursor.Style = CursorStyle.VerticalNoTracking;
cursor.LineStyle.Pattern = LinePattern.Dash;
_chart.ViewXY.LineSeriesCursors.Add(cursor);
Kind regards,
Lasse