Group: Forum Members
Last Active: 12 Years Ago
Posts: 2,
Visits: 1
|
Hi, I've tried to modify the look and feel of my graphs with quite bad results Does anyone know how to perform a chart in Nevron Chart for .NET that looks like any of the charts below? Br, Magnus http://i43.tinypic.com/2cx7tzb.jpg http://i43.tinypic.com/11v2qvm.jpg
|
Group: Forum Members
Last Active: Last Week
Posts: 3,054,
Visits: 4,009
|
Hi Magnus, The following code snippet should get you started: nChartControl1.BackgroundStyle.FillStyle = new NColorFillStyle(Color.Black);NImageFrameStyle frameStyle = new NImageFrameStyle(PredefinedImageFrame.Emboss);frameStyle.FillStyle = new NGradientFillStyle(Color.DarkGray, Color.Black);nChartControl1.BackgroundStyle.FrameStyle = frameStyle; nChartControl1.Panels.Clear(); // set a chart titleNLabel title = new NLabel("EUR / USD Exchange rate<br/><font size='10pt'>click and drag in the chart area to zoom in</font>");title.Dock = DockStyle.Top;title.TextStyle.TextFormat = TextFormat.XML;title.TextStyle.FillStyle = new NColorFillStyle(Color.White);title.ContentAlignment = ContentAlignment.BottomCenter;title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));title.Margins = new NMarginsL(10, 10, 10, 0);nChartControl1.Panels.Add(title); NCartesianChart chart = new NCartesianChart();chart.Dock = DockStyle.Fill;chart.Margins = new NMarginsL(10, 10, 40, 10);chart.BoundsMode = BoundsMode.Stretch;chart.Wall( ChartWallType.Back).VisibilityMode = WallVisibilityMode.Hidden;nChartControl1.Panels.Add(chart); // configure the y axisNAxis yAxis = chart.Axis(StandardAxis.PrimaryY);NLinearScaleConfigurator yScale = yAxis.ScaleConfigurator as NLinearScaleConfigurator;yScale.InnerMajorTickStyle.Length = new NLength(0);yScale.OuterMajorTickStyle.LineStyle.Color = Color.LightGray;yScale.Title.Text = "Exchange Rate";yScale.Title.TextStyle.FillStyle = new NColorFillStyle(Color.LightGray);yScale.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.LightGray);yScale.RulerStyle.BorderStyle.Width = new NLength(0);// configure the x axisNAxis xAxis = chart.Axis(StandardAxis.PrimaryX);NDateTimeScaleConfigurator dtScale = new NDateTimeScaleConfigurator();dtScale.InnerMajorTickStyle.Length = new NLength(0);dtScale.OuterMajorTickStyle.LineStyle.Color = Color.LightGray;dtScale.RulerStyle.BorderStyle.Color = Color.LightGray;dtScale.LabelStyle.TextStyle.FillStyle = new NColorFillStyle(Color.LightGray);dtScale.MajorTickMode = MajorTickMode.CustomStep;dtScale.CustomStep = new NDateTimeSpan(1, NDateTimeUnit.Month);dtScale.EnableUnitSensitiveFormatting = false;dtScale.LabelValueFormatter = new NDateTimeValueFormatter("MMM yy");xAxis.ScaleConfigurator = dtScale; // add the first lineNAreaSeries area = (NAreaSeries)chart.Series.Add(SeriesType.Area);area.UseXValues = true;area.DataLabelStyle.Visible = false;area.FillStyle = new NGradientFillStyle(Color.FromArgb(200, Color.Yellow), Color.FromArgb(125, Color.Black));area.BorderStyle.Width = new NLength(0);int maxCount = 200;DateTime dt = DateTime.Now;Random rand = new Random();for (int i = 0; i < maxCount; i++){ double dValueY = 110 + Math.Sin(i * 3.14 / 18) * 50 * (rand.NextDouble() + 1.0);int nIndex = i % maxCount;area.Values.Add(dValueY); area.XValues.Add(dt.ToOADate()); dt += new TimeSpan(1, 0, 0, 0);} You probably need to change the colors a bit, but that's the basic configuration...
Best Regards, Nevron Support Team
|
Group: Forum Members
Last Active: 12 Years Ago
Posts: 2,
Visits: 1
|
Thanks!
I have some problem with a few things there:
title.Dock = DockStyle.Top;
DockStyle does not exist in current context
title.ContentAlignment = ContentAlignment.BottomCenter;
ContentAlignment does not exist in current context
new NColorFillStyle(Color.Black);
Color does not exist in current context
I'm using:
using Nevron.GraphicsCore; using Nevron.Chart; using Nevron.Chart.WinForm;
Do I need any more?
Br,
Magnus
|
Group: Forum Members
Last Active: Last Week
Posts: 3,054,
Visits: 4,009
|
Hi Magnus, You need: using System; using System.Drawing; using System.Windows.Forms; using Nevron; using Nevron.Chart; using Nevron.Dom; using Nevron.GraphicsCore;
BTW Pressing Ctrl + "." in Visual Studio will autmatically suggest which using you need to include for the class/enum etc. at the current cursor position...
Best Regards, Nevron Support Team
|