Hello..
It is displayed in green when zoom out.
When it is zoom out, the data appears to be incorrect.
Can not I show the palette precisely on the chart?
ValueRangePalette zoom out issue
Moderator: Queue Moderators
ValueRangePalette zoom out issue
- Attachments
-
- zoom out
- 2.png (5.27 KiB) Viewed 16132 times
-
- default
- 1.png (12.92 KiB) Viewed 16132 times
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: ValueRangePalette zoom out issue
Hello,
the coloring of XY line is made screen-coordinate based. Therefore, when zooming out a lot, the other side of a thick line may have different color than the other. It is a limitation of the palette-coloring feature.
You may want to try if using series.CustomLinePointColoringAndShaping event works better for your purpose. The CustomLinePointColoringAndShaping assumes screen coordinates too. You can convert data point values to screen coordinates with yAxis.ValueToCoord method, and screen coordinates to values with yAxis.CoordToValue method. In the event, you can get color as series.ValueRangePalette.GetColorByValue().
the coloring of XY line is made screen-coordinate based. Therefore, when zooming out a lot, the other side of a thick line may have different color than the other. It is a limitation of the palette-coloring feature.
You may want to try if using series.CustomLinePointColoringAndShaping event works better for your purpose. The CustomLinePointColoringAndShaping assumes screen coordinates too. You can convert data point values to screen coordinates with yAxis.ValueToCoord method, and screen coordinates to values with yAxis.CoordToValue method. In the event, you can get color as series.ValueRangePalette.GetColorByValue().
LightningChart Support Team, PT
Re: ValueRangePalette zoom out issue
Thank you for answer.
I try used CustomLinePointColoringAndShaping event.
It works well.
How does "PaletteType.Uniform" apply when using the CustomLinePointColoringAndShaping event?
It seems to be "PaletteType.Gradient" by default.
I attach my sample code .
I try used CustomLinePointColoringAndShaping event.
It works well.
How does "PaletteType.Uniform" apply when using the CustomLinePointColoringAndShaping event?
It seems to be "PaletteType.Gradient" by default.
I attach my sample code .
Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Arction.WinForms.Charting;
using Arction.WinForms.Charting.SeriesXY;
using Arction.WinForms.Charting.Axes;
using System.Diagnostics;
namespace AboutCustomLinePointColoringAndShaping
{
public partial class Form1 : Form
{
LightningChartUltimate chart;
public Form1()
{
InitializeComponent();
this.chart = new LightningChartUltimate();
chart.BeginUpdate();
chart.Dock = DockStyle.Fill;
chart.ViewXY.XAxes[0].ValueType = AxisValueType.Number;
var series = new PointLineSeries();
//Quantity of points
int pointCount = 501;
//Data interval
const double xInterval = 0.1;
SeriesPoint[] points = new SeriesPoint[pointCount];
double x;
//Generate some data
for (int point = 0; point < pointCount; point++)
{
x = (double)point * xInterval;
points[point].X = x;
points[point].Y = 50.0 + 30.0 * Math.Sin(x / 5.0) + 1.0 * Math.Sin(x * 5.0) + 15.0 * Math.Cos(x);
}
series.Points = points;
ValueRangePalette palette = new ValueRangePalette();
palette.Steps.Clear();
palette.Type = PaletteType.Uniform;
palette.Steps.Add(new PaletteStep(palette, Color.White, 0));
palette.Steps.Add(new PaletteStep(palette, Color.Red, 40));
palette.Steps.Add(new PaletteStep(palette, Color.Blue, 70));
palette.Steps.Add(new PaletteStep(palette, Color.Lime, 100));
series.ValueRangePalette = palette;
series.UsePalette = false;
series.CustomLinePointColoringAndShaping += Series_CustomLinePointColoringAndShaping;
chart.ViewXY.PointLineSeries.Add(series);
chart.ViewXY.ZoomToFit();
this.Controls.Add(chart);
chart.EndUpdate();
}
private void Series_CustomLinePointColoringAndShaping(object sender, CustomLinePointColoringAndShapingEventArgs e)
{
Stopwatch sw = Stopwatch.StartNew();
PointLineSeries series = (PointLineSeries)e.Series;
AxisY axisY = series.OwnerView.YAxes[series.AssignYAxisIndex];
AxisX axisX = series.OwnerView.XAxes[series.AssignXAxisIndex];
PointFloat[] coords = e.Coords;
double yValue;
Color color;
for (int i = 0; i < coords.Length; i++)
{
bool isFind = false;
PointFloat point = coords[i];
LineSeriesCoordinateSolveResult res = series.SolveYCoordAtXCoord((int)point.X);
if (res.SolveStatus == LineSeriesSolveStatus.OK)
{
yValue = series.Points[res.MinIndex].Y;
if (series.ValueRangePalette.GetColorByValue(yValue, out color))
{
e.Colors[i] = color.ToArgb();
isFind = true;
}
}
if (isFind == false)
{
e.Colors[i] = series.LineStyle.Color.ToArgb();
}
}
sw.Stop();
Debug.WriteLine(sw.Elapsed.ToString());
}
}
}
Re: ValueRangePalette zoom out issue
I have confirmed that it changes according to ValueRangePalette.Type.
However, when "ValueRangePalette.Type = PaletteType.Uniform", a gradient effect occurs.
However, when "ValueRangePalette.Type = PaletteType.Uniform", a gradient effect occurs.
- Attachments
-
- 123.png (48.62 KiB) Viewed 16124 times
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: ValueRangePalette zoom out issue
When a sharp color change is required, you'll need to add two points with same coordinates. Blue and Red. Otherwise GPU interpolates colors between two coordinates.
LightningChart Support Team, PT