Profile Picture

Heading to a chart

Posted By Manal Goyal 6 Years Ago
Author
Message
Manal Goyal
Question Posted 6 Years Ago
View Quick Profile
Forum Member

Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)

Group: Forum Members
Last Active: 5 Years Ago
Posts: 29, Visits: 405
Hi Team,

Is there a way to add a heading to a chart, Actually I am creating 3 charts by creating 3 different y-axes on a same cartatian chart. and I want each of them to have a heading like shown in the pic below.


Thank you.



Manal Goyal
Posted 6 Years Ago
View Quick Profile
Forum Member

Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)

Group: Forum Members
Last Active: 5 Years Ago
Posts: 29, Visits: 405
I have created this chart in a very similar way as shown in the NevronChart->WPF->RealtimeLine example.


Nevron Support
This post has been flagged as an answer
Posted 6 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Today @ 1:54 AM
Posts: 3,054, Visits: 4,009
Hi Manal,
The following code shows how to create a chart with several Y axes which are docked to the left side and a custom X axis which is crossed at the end of the of the first Y axis. This approach can be used to add heading which are attached to the end of a Y axis:
using Nevron;
using Nevron.Chart;
using Nevron.GraphicsCore;
using System;
using System.Windows.Forms;

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

private void Form1_Load(object sender, EventArgs e)
{
// set a chart title
NLabel title = nChartControl1.Labels.AddHeader("Axis Crossing");

// turn off the legend
nChartControl1.Legends[0].Mode = LegendMode.Disabled;

// configure the chart
NChart chart = nChartControl1.Charts[0];
chart.BoundsMode = BoundsMode.Stretch;

// apply predefined lighting and projection
chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1);
chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft);

// configure primary Y
NAxis primaryY = chart.Axis(StandardAxis.PrimaryY);
primaryY.Anchor.BeginPercent = 0;
primaryY.Anchor.EndPercent = 40;

// configure secondary Y
NAxis secondaryY = chart.Axis(StandardAxis.SecondaryY);
secondaryY.Anchor = new NDockAxisAnchor(AxisDockZone.FrontLeft, false);
secondaryY.Visible = true;
secondaryY.Anchor.BeginPercent = 60;
secondaryY.Anchor.EndPercent = 100;

// create a custom axis
NAxis customX = ((NCartesianAxisCollection)chart.Axes).AddCustomAxis(AxisOrientation.Horizontal, AxisDockZone.FrontRight);
customX.Visible = true;
customX.ScaleConfigurator.Title.Text = "Some Text";

// hide the ticks and ruler
NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator();
linearScale.RulerStyle.Shape = ScaleLevelShape.None;
linearScale.Title.Text = "Some Text";
linearScale.Title.Offset = new NLength(0);
linearScale.MajorTickMode = MajorTickMode.CustomTicks;
linearScale.AutoLabels = false;
customX.ScaleConfigurator = linearScale;

// cross it with some vertical axis at the axis top
NCrossAxisAnchor crossAnchor = new NCrossAxisAnchor();
customX.Anchor = crossAnchor;
crossAnchor.AxisOrientation = AxisOrientation.Horizontal;
crossAnchor.Crossings.Add(new NModelAxisCrossing(primaryY, HorzAlign.Right, new NLength(0)));

// Setup the line series
Random rand = new Random();
NLineSeries l1 = (NLineSeries)chart.Series.Add(SeriesType.Line);
l1.Values.FillRandom(rand, 5);
l1.LineSegmentShape = LineSegmentShape.Tape;
l1.DataLabelStyle.Format = "<value>";

// make sure the custom x axis is used - otherwise it will not be displayed
l1.DisplayOnAxis(customX.AxisId, true);

NLineSeries l2 = (NLineSeries)chart.Series.Add(SeriesType.Line);
l2.Values.FillRandom(rand, 5);
l2.LineSegmentShape = LineSegmentShape.Tape;
l2.DataLabelStyle.Format = "<value>";
l2.DisplayOnAxis(StandardAxis.SecondaryY, true);
l2.DisplayOnAxis(StandardAxis.PrimaryY, false);
}
}
}
Please note that the custom axis has hidden major ticks and ruler, only title. Also in order for it to show up you need to configure some line series to scale on it:
// make sure the custom x axis is used - otherwise it will not be displayed
l1.DisplayOnAxis(customX.AxisId, true);

otherwise the axis will be marked as unused and will not show. You can use the same approach for the secondaryY and customY axis you have.

Hope this helps - let us know if you meet any problems.



Best Regards,
Nevron Support Team



Manal Goyal
Posted 6 Years Ago
View Quick Profile
Forum Member

Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)Forum Member (44 reputation)

Group: Forum Members
Last Active: 5 Years Ago
Posts: 29, Visits: 405
Hi Team,

Thank you for the example, I see it works fine for this scenario. But I am having some difficulties implementing this in my code. I am sending the code sample to Nevron Support <support@nevron.com>. Please have a look in the code and let me know what is missing there.

Thank you




Similar Topics


Reading This Topic