Hi Andre,
This can be achieved with custom painting - the following example shows how to add a line cap at the end of the line:
public class CustomPaintCallback : NPaintCallback
{
public CustomPaintCallback(NChartControl chartControl, NChart chart, NLineSeries line)
{
m_Line = line;
m_Chart = chart;
m_ChartControl = chartControl;
}
public override void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs)
{
NScale2DToViewTransformation scale2View = new NScale2DToViewTransformation(m_ChartControl.View.Context, m_Chart, (int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY);
int count = m_Line.Values.Count;
if (count < 2)
{
return;
}
double y1 = (double)m_Line.Values[count - 2];
double x1 = (double)m_Line.XValues[count - 2];
double y2 = (double)m_Line.Values[count - 1];
double x2 = (double)m_Line.XValues[count - 1];
NPointF point1 = new NPointF();
NPointF point2 = new NPointF();
scale2View.Transform(new NVector2DD(x1, y1), ref point1);
scale2View.Transform(new NVector2DD(x2, y2), ref point2);
// now paint the arrow
Graphics graphics = eventArgs.Graphics.DeviceGraphics;
GraphicsState state = graphics.Save();
double angle = Math.Atan2(point1.Y - point2.Y, point1.X - point2.X);
graphics.TranslateTransform(point2.X, point2.Y);
double rad2Degree = 57.2958f;
graphics.RotateTransform((float)(rad2Degree * angle) - 90);
using (SolidBrush brush = new SolidBrush(Color.Black))
{
using (GraphicsPath path = new GraphicsPath())
{
float arrowSize = 5;
path.AddLine(new PointF(0, 0), new PointF(-arrowSize, arrowSize));
path.AddLine(new PointF(-arrowSize, arrowSize), new PointF(arrowSize, arrowSize));
path.CloseAllFigures();
graphics.FillPath(brush, path);
}
}
graphics.Restore(state);
}
NLineSeries m_Line;
NChart m_Chart;
NChartControl m_ChartControl;
}
private void Form1_Load(object sender, EventArgs e)
{
NChart m_Chart = nChartControl1.Charts[0];
NLineSeries m_Line2 = (NLineSeries)m_Chart.Series.Add(SeriesType.Line);
m_Line2.Name = "Alimentador";
m_Line2.InflateMargins = true;
m_Line2.DataLabelStyle.Visible = true;
m_Line2.MarkerStyle.Visible = false;
m_Line2.SamplingMode = SeriesSamplingMode.Enabled;
m_Line2.LineSize = new NLength(50);
m_Line2.MarkerStyle.PointShape = PointShape.Cylinder;
m_Line2.MarkerStyle.Width = new NLength(1.5f, NRelativeUnit.ParentPercentage);
m_Line2.MarkerStyle.Height = new NLength(1.5f, NRelativeUnit.ParentPercentage);
m_Line2.UseXValues = true;
m_Line2.Values.Add(0);
m_Line2.XValues.Add(-125);
m_Line2.Values.Add(10);
m_Line2.XValues.Add(20);
m_Line2.BorderStyle.Color = Color.Black;
m_Chart.PaintCallback = new CustomPaintCallback(nChartControl1, m_Chart, m_Line2);
}
Hope this helps - let us know if you meet any problems...
Best Regards,
Nevron Support Team