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 [email protected].
//
// Permission to use this code in your application comes with LightningChart® license.
//
// http://www.arction.com | [email protected] | [email protected]
//
// © 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;
}
}
}