Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
ultradatachart Zoom with Margin
posted

Hello,

           i am using ultraDataChart. i have isue with zooming scale. zoom is working great without margin.

if add margin (top,left,bottom,right) then zoom is not reflecting the correct value on chart. 

namespace Zoom
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
try
{
AddSeries();

Data_Chart.PlotAreaMarginTop = 5;
Data_Chart.PlotAreaMarginBottom = 5;
Data_Chart.PlotAreaMarginLeft = 5;
Data_Chart.PlotAreaMarginRight = 5;

for (int i = 0; i < 11; i++)
{
DataPoint NewDataPoint = new DataPoint();
NewDataPoint.X = i;
NewDataPoint.Y = i * 5;
DataPoints.Add(NewDataPoint);
}

if (Data_Chart.Series.Count < 1) { return; }
var _series = Data_Chart.Series[0];
if (_series != null)
{
Data_Chart.Series[0].DataSource = DataPoints;
Data_Chart.Series[0].RenderSeries(false);
}

if (Data_Chart.Axes[0] is NumericXAxis _xAxis)
{
_xAxis.RenderAxis();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

private List<DataPoint> DataPoints = new List<DataPoint>();

private void AddSeries()
{
try
{
var _xAxis = new NumericXAxis
{
TitleFontSize = 16,
TitleTextStyle = FontStyle.Regular,
LabelFontSize = 12,
LabelTextStyle = FontStyle.Regular
};
var _yAxis = new NumericYAxis
{
TitleFontSize = _xAxis.TitleFontSize,
TitleFontFamily = _xAxis.TitleFontFamily,
TitleTextStyle = _xAxis.TitleTextStyle,
LabelFontSize = _xAxis.LabelFontSize,
LabelTextStyle = _xAxis.LabelTextStyle
};

// Title for xAxis and yAxis on Signal Chart
_xAxis.Title = "Time (ms)";
_yAxis.Title = "Amplitude";

Data_Chart.Axes.Add(_xAxis);
Data_Chart.Axes.Add(_yAxis);

// Set the series paarmeters
var _series = new ScatterLineSeries
{
XAxis = _xAxis,
YAxis = _yAxis,
XMemberPath = "X",
YMemberPath = "Y",
Brush = Color.Blue,
Opacity = 1,
MarkerType = MarkerType.None,
DataSource = DataPoints
};
Data_Chart.Series.Add(_series);

//Data_Chart.VerticalZoomable = true;
//Data_Chart.HorizontalZoomable = true;

Data_Chart.IsHorizontalZoomEnabled = true;
Data_Chart.IsVerticalZoomEnabled = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}

public class DataPoint
{
public double X { get; set; }
public double Y { get; set; }
}
}

thank you.