The last point disappears.

A forum dedicated to WinForms version of LightningChart Ultimate.

The last point disappears.

Postby lukoprovandrey » Mon Apr 29, 2019 3:35 pm

Hello guys,

I have a problem when I set.AxisLayout.YAxesLayout to YAxesLayout.Stacked the latest point is not visible. I have modified your Y axis layouts sample (see the code below).

It seems like for chart applies small padding which equals 1 pixel because when I hover the line or change the width of the line to 2 I can see the half of it. Could you please help me with that?

Code: Select all
// ---------------------------------------------------------------------------------------------------------
// LightningChart® example code: Demo shows how to configure and use different y-axis layouts and placement.
//
// If you need any assistance, or notice error in this example code, please contact support@arction.com.
//
// Permission to use this code in your application comes with LightningChart® license.
//
// http://www.arction.com | support@arction.com | sales@arction.com
//
// © Arction Ltd 2009-2019. All rights reserved. 
// ---------------------------------------------------------------------------------------------------------
using System;
using System.Drawing;
using System.Windows.Forms;

using Arction.WinForms.Charting;
using Arction.WinForms.Charting.Axes;
using Arction.WinForms.Charting.SeriesXY;
using Arction.WinForms.Charting.Views.ViewXY;

namespace DemoAppWinForms
{
    public partial class ExampleYAxesLayouts : Example
    {
        public ExampleYAxesLayouts()
        {
            InitializeComponent();

            //CreateChart(panelSegmented, "Segmented layout", YAxesLayout.Segmented);
            CreateChart(panelStacked, "Stacked layout", YAxesLayout.Stacked);
           // CreateChart(panelLayered, "Layered layout", YAxesLayout.Layered);

            base.RaiseChartsCreatedEvent();
        }

        /// <summary>
        /// Create chart with different y-axes layout settings.
        /// Add some series.
        /// </summary>
        /// <param name="parent">Parent container for chart component.</param>
        /// <param name="name">Chart name.</param>
        /// <param name="layout">Y-axes layout for current chart.</param>
        private void CreateChart(Panel parent, string name, YAxesLayout layout)
        {
            var chart = new LightningChartUltimate();

            //Disable rendering, strongly recommended before updating chart properties
            chart.BeginUpdate();

            chart.Parent = parent;
            chart.Dock = DockStyle.Fill;
            chart.Name = chart.Title.Text = name;

            //Set given Y axes layout
            chart.ViewXY.AxisLayout.YAxesLayout = layout;

            //Set other layout and axis placement options
            chart.ViewXY.AxisLayout.YAxisAutoPlacement = YAxisAutoPlacement.LeftThenRight;
            chart.ViewXY.AxisLayout.AutoAdjustAxisGap = 0;

            //Hide legend box
            chart.ViewXY.LegendBoxes[0].Visible = false;

            //Configure x-axis
            AxisX axisX = chart.ViewXY.XAxes[0];
            axisX.SetRange(0, 6144);
            axisX.ValueType = AxisValueType.Number;
            axisX.ScrollMode = XAxisScrollMode.None;
            axisX.AxisColor = Color.Red;

            const int yAxes = 4; //Quantity new y-axes

            //Remove y-axes to create new axes
            ExampleUtils.DisposeAllAndClear(chart.ViewXY.YAxes); //Remove existing y-axes

            for (int axisY = 0; axisY < yAxes; axisY++)
            {
                string text = name.Substring(0, name.Length - 7);

                AxisY yAxis = new AxisY(chart.ViewXY);
                yAxis.AxisColor = DefaultColors.SeriesForBlackBackground[axisY % DefaultColors.SeriesForBlackBackground.Length];
                yAxis.Title.Text = text + " Axis " + (axisY + 1).ToString();
                yAxis.Title.Color = yAxis.AxisColor;
                yAxis.SetRange(-10, 10);
                chart.ViewXY.YAxes.Add(yAxis);

                //Create a PointLineSeries for each axis, and fill it with data
                PointLineSeries pls = new PointLineSeries(chart.ViewXY, axisX, yAxis);
                pls.LineStyle.Color = yAxis.AxisColor;
                pls.LineStyle.Width = 1;
                pls.LineStyle.AntiAliasing = LineAntialias.None;

                int pointCount = 6144;
                SeriesPoint[] points = new SeriesPoint[pointCount];

                for (int point = 0; point < pointCount; point++)
                {
                    points[point].X = (double)point;
                    points[point].Y = 10;
                }

                points[pointCount - 1].Y = 0;

                //Assign the data for the point line series
                pls.Points = points;

                chart.ViewXY.PointLineSeries.Add(pls);
            }

            // Setup custom style.
            ExampleUtils.SetDarkFlatStyle(chart);

            if (layout == YAxesLayout.Segmented)
            {
                ExampleUtils.DisposeAllAndClear(chart.ViewXY.AxisLayout.Segments); //Remove existing segments

                //Create segments, each segment
                //- height can be different
                //- can contain any count of Y axes
                chart.ViewXY.AxisLayout.Segments.Add(new YAxisSegment(chart.ViewXY.AxisLayout) { Height = 1 });
                chart.ViewXY.AxisLayout.Segments.Add(new YAxisSegment(chart.ViewXY.AxisLayout) { Height = 1 });
                chart.ViewXY.AxisLayout.Segments.Add(new YAxisSegment(chart.ViewXY.AxisLayout) { Height = 2.5 });

                //Set first Y axis to first segment
                chart.ViewXY.YAxes[0].SegmentIndex = 0;

                //Set second Y axis to second segment
                chart.ViewXY.YAxes[1].SegmentIndex = 1;

                //Set 3rd and 4th axis both to last segment
                chart.ViewXY.YAxes[2].SegmentIndex = 2;
                chart.ViewXY.YAxes[3].SegmentIndex = 2;
            }

            //Allow chart rendering
            chart.EndUpdate();
        }

        private void ExampleYAxesLayouts_SizeChanged(object sender, EventArgs e)
        {
            int totalWidth = this.ClientSize.Width;

         
        }
    }
}
lukoprovandrey
 
Posts: 27
Joined: Fri Sep 04, 2015 2:30 pm

Re: The last point disappears.

Postby Arction_LasseP » Tue Apr 30, 2019 10:05 am

Hello,

By default, ViewXY has a border around it. It is one pixel wide, so it hides series points/line under it if they happen to be in the same location. However, there is a RenderBehindSeries -property which allows data to be drawn over the border, when set true. It should be useful here.

Code: Select all
chart.ViewXY.Border.RenderBehindSeries = true;


Note that this property was introduced in LightningChart v8.4. In versions before this chart.ViewXY.GraphBordersOverSeries = false had the same effect. This is now marked obsolete and will be removed in the future.

Hope this helps.
Arction_LasseP
 
Posts: 39
Joined: Wed Mar 27, 2019 1:05 pm

Re: The last point disappears.

Postby lukoprovandrey » Tue Apr 30, 2019 1:44 pm

Thank you for the response.

I was surprised that GraphBordersOverSeries is already set to false :shock: But the issue still actual for me. After some investigation I found that the reason for it is LimitYToStackSegment = true.
Does it appropriate behavior that the line cuts by the right border when this property is set to true?

Here is a modified code with the issue:

Code: Select all
// ---------------------------------------------------------------------------------------------------------
// LightningChart® example code: Demo shows how to configure and use different y-axis layouts and placement.
//
// If you need any assistance, or notice error in this example code, please contact support@arction.com.
//
// Permission to use this code in your application comes with LightningChart® license.
//
// http://www.arction.com | support@arction.com | sales@arction.com
//
// © Arction Ltd 2009-2019. All rights reserved. 
// ---------------------------------------------------------------------------------------------------------
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;

using Arction.WinForms.Charting;
using Arction.WinForms.Charting.Axes;
using Arction.WinForms.Charting.SeriesXY;
using Arction.WinForms.Charting.Views.ViewXY;

namespace DemoAppWinForms
{
    public partial class ExampleYAxesLayouts : Example
    {
        public ExampleYAxesLayouts()
        {
            InitializeComponent();

            //CreateChart(panelSegmented, "Segmented layout", YAxesLayout.Segmented);
            CreateChart(panelStacked, "Stacked layout", YAxesLayout.Stacked);
            // CreateChart(panelLayered, "Layered layout", YAxesLayout.Layered);

            base.RaiseChartsCreatedEvent();
        }

        /// <summary>
        /// Create chart with different y-axes layout settings.
        /// Add some series.
        /// </summary>
        /// <param name="parent">Parent container for chart component.</param>
        /// <param name="name">Chart name.</param>
        /// <param name="layout">Y-axes layout for current chart.</param>
        private void CreateChart(Panel parent, string name, YAxesLayout layout)
        {
            var chart = new LightningChartUltimate();

            //Disable rendering, strongly recommended before updating chart properties
            chart.BeginUpdate();

            chart.Parent = parent;
            chart.Dock = DockStyle.Fill;
            chart.Name = chart.Title.Text = name;

            //Set given Y axes layout
            chart.ViewXY.AxisLayout.YAxesLayout = layout;

            //Set other layout and axis placement options
            chart.ViewXY.AxisLayout.AutoAdjustAxisGap = 0;

            //Hide legend box
            chart.ViewXY.LegendBoxes[0].Visible = false;

            //Configure x-axis
            AxisX axisX = chart.ViewXY.XAxes[0];
            axisX.SetRange(0, 23.99609375);
            axisX.ValueType = AxisValueType.Number;
            axisX.ScrollMode = XAxisScrollMode.None;
            axisX.AxisColor = Color.Red;

            const int yAxes = 4; //Quantity new y-axes

            //Remove y-axes to create new axes
            ExampleUtils.DisposeAllAndClear(chart.ViewXY.YAxes); //Remove existing y-axes

            for (int axisY = 0; axisY < yAxes; axisY++)
            {
                string text = name.Substring(0, name.Length - 7);

                AxisY yAxis = new AxisY(chart.ViewXY);
                yAxis.AxisColor = DefaultColors.SeriesForBlackBackground[axisY % DefaultColors.SeriesForBlackBackground.Length];
                yAxis.Title.Text = text + " Axis " + (axisY + 1).ToString();
                yAxis.Title.Color = yAxis.AxisColor;
                yAxis.SetRange(-10, 10);
                chart.ViewXY.YAxes.Add(yAxis);

                //Create a PointLineSeries for each axis, and fill it with data
                var sds = new SampleDataSeries(chart.ViewXY, axisX, yAxis);
                sds.LineStyle.Color = yAxis.AxisColor;
                sds.SampleFormat = SampleFormat.SingleFloat;
                sds.LineStyle.Width = 1;
                sds.SamplingFrequency = 256;
                sds.FirstSampleTimeStamp = 0;
                sds.LimitYToStackSegment = true;
                sds.LineStyle.AntiAliasing = LineAntialias.None;

                int pointCount = 6144;

                var points = new float[pointCount];
                for (int point = 0; point < pointCount; point++)
                {
                    points[point] = 10;
                }

                points[pointCount - 1] = 0;

                //Assign the data for the point line series
                sds.SamplesSingle = points;

                chart.ViewXY.SampleDataSeries.Add(sds);
            }

            // Setup custom style.
            ExampleUtils.SetDarkFlatStyle(chart);

            chart.ViewXY.Border.RenderBehindSeries = true;

            if (layout == YAxesLayout.Segmented)
            {
                ExampleUtils.DisposeAllAndClear(chart.ViewXY.AxisLayout.Segments); //Remove existing segments

                //Create segments, each segment
                //- height can be different
                //- can contain any count of Y axes
                chart.ViewXY.AxisLayout.Segments.Add(new YAxisSegment(chart.ViewXY.AxisLayout) { Height = 1 });
                chart.ViewXY.AxisLayout.Segments.Add(new YAxisSegment(chart.ViewXY.AxisLayout) { Height = 1 });
                chart.ViewXY.AxisLayout.Segments.Add(new YAxisSegment(chart.ViewXY.AxisLayout) { Height = 2.5 });

                //Set first Y axis to first segment
                chart.ViewXY.YAxes[0].SegmentIndex = 0;

                //Set second Y axis to second segment
                chart.ViewXY.YAxes[1].SegmentIndex = 1;

                //Set 3rd and 4th axis both to last segment
                chart.ViewXY.YAxes[2].SegmentIndex = 2;
                chart.ViewXY.YAxes[3].SegmentIndex = 2;
            }

            //Allow chart rendering
            chart.EndUpdate();

        }
        private void ExampleYAxesLayouts_SizeChanged(object sender, EventArgs e)
        {
            int totalWidth = this.ClientSize.Width;


        }
    }
}
lukoprovandrey
 
Posts: 27
Joined: Fri Sep 04, 2015 2:30 pm

Re: The last point disappears.

Postby Arction_LasseP » Fri May 03, 2019 7:21 am

Hello,

We checked this issue and found out that this is currently how these properties behave together. LimitYToStackSegment prevents GraphBordersOverSeries and RenderBehindSeries working properly so it is a case of overlapping properties. Unfortunately there isn't much that can be done to prevent this but we are planning to fix this in the future though.

Meanwhile we can think of two workarounds: increasing the line width (1.1f works but not 1) or increasing the x-axis range by a small amount.
Arction_LasseP
 
Posts: 39
Joined: Wed Mar 27, 2019 1:05 pm


Return to LightningChart Ultimate WinForms

Who is online

Users browsing this forum: No registered users and 6 guests

cron