public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("2D High Low Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // configure the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Axis(StandardAxis.Depth).Visible = false; // add a High-Low series m_HighLow = (NHighLowSeries)m_Chart.Series.Add(SeriesType.HighLow); m_HighLow.Name = "High-Low Series"; m_HighLow.Legend.Mode = SeriesLegendMode.SeriesLogic; m_HighLow.HighFillStyle = new NColorFillStyle(GreyBlue); m_HighLow.LowFillStyle = new NColorFillStyle(DarkOrange); m_HighLow.DataLabelStyle.Visible = false; m_HighLow.DataLabelStyle.Format = "<high_value>:<low_value>"; m_HighLow.LowValues.ValueFormatter = new NNumericValueFormatter("0.#"); m_HighLow.HighValues.ValueFormatter = new NNumericValueFormatter("0.#"); GenerateData(); // apply layout ConfigureStandardLayout(m_Chart, title, nChartControl1.Legends[0]); }
private void DepthScroll_Scroll(object sender, Nevron.UI.WinForm.Controls.ScrollBarEventArgs e) { NHighLowSeries highLow = (NHighLowSeries)nChartControl1.Charts[0].Series[0]; highLow.DepthPercent = DepthScroll.Value; nChartControl1.Refresh(); }
private void DropLinesCheckBox_Checked(object sender, System.Windows.RoutedEventArgs e) { NHighLowSeries highLow = (NHighLowSeries)nChartControl1.Charts[0].Series[0]; highLow.DropLines = (bool)DropLinesCheckBox.IsChecked; nChartControl1.Refresh(); }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = nChartControl1.Labels.AddHeader("2D High Low Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // configure the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Axis(StandardAxis.Depth).Visible = false; // add a High-Low series m_HighLow = (NHighLowSeries)m_Chart.Series.Add(SeriesType.HighLow); m_HighLow.Name = "High-Low Series"; m_HighLow.Legend.Mode = SeriesLegendMode.SeriesLogic; m_HighLow.HighFillStyle = new NColorFillStyle(GreyBlue); m_HighLow.LowFillStyle = new NColorFillStyle(DarkOrange); m_HighLow.DataLabelStyle.Visible = false; m_HighLow.DataLabelStyle.Format = "<high_value>:<low_value>"; m_HighLow.LowValues.ValueFormatter = new NNumericValueFormatter("0.#"); m_HighLow.HighValues.ValueFormatter = new NNumericValueFormatter("0.#"); GenerateData(); // apply layout ConfigureStandardLayout(m_Chart, title, null); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); nChartControl1.Refresh(); }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Advanced High Low Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // configure the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalHalf); m_Chart.Axis(StandardAxis.Depth).Visible = false; NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; // create the series m_HighLow = (NHighLowSeries)m_Chart.Series.Add(SeriesType.HighLow); m_HighLow.Name = "High-Low Series"; m_HighLow.HighFillStyle = new NColorFillStyle(GreyBlue); m_HighLow.LowFillStyle = new NColorFillStyle(DarkOrange); m_HighLow.UseXValues = true; m_HighLow.DataLabelStyle.Format = "<high_label><low_label>"; m_HighLow.Legend.Mode = SeriesLegendMode.SeriesLogic; // fill with values GenerateValuesY(8); GenerateValuesX(8); // apply layout ConfigureStandardLayout(m_Chart, title, nChartControl1.Legends[0]); }
private void DropLinesCheck_CheckedChanged(object sender, System.EventArgs e) { NHighLowSeries highLow = (NHighLowSeries)nChartControl1.Charts[0].Series[0]; highLow.DropLines = DropLinesCheck.Checked; nChartControl1.Refresh(); }
private void LowAreaFEButton_Click(object sender, System.EventArgs e) { NFillStyle fillStyleResult; NHighLowSeries highLow = (NHighLowSeries)nChartControl1.Charts[0].Series[0]; if (NFillStyleTypeEditor.Edit(highLow.LowFillStyle, out fillStyleResult)) { highLow.LowFillStyle = fillStyleResult; nChartControl1.Refresh(); } }
private void GenerateData(NHighLowSeries highLow) { highLow.ClearDataPoints(); for (int i = 0; i < 21; i++) { double d1 = Math.Log(i + 1) + 0.1 * Random.NextDouble(); double d2 = d1 + Math.Cos(0.33 * i) + 0.1 * Random.NextDouble(); highLow.HighValues.Add(d1); highLow.LowValues.Add(d2); } }
private void GenerateValuesX(NHighLowSeries highLow, int nCount) { highLow.XValues.Clear(); double dValue = (double)Random.Next(100); for (int i = 0; i < nCount; i++) { highLow.XValues.Add(dValue); dValue = dValue + Random.Next(5, 10); } }
private void GenerateValuesY(NHighLowSeries highLow, int nCount) { double dPhase1 = Random.Next(5); double dPhase2 = dPhase1 + 1; highLow.HighValues.Clear(); highLow.LowValues.Clear(); for (int i = 0; i < nCount; i++) { double d1 = 10 + Math.Sin(dPhase1 + 0.8 * i) + 0.5 * Random.NextDouble(); double d2 = 10 + Math.Cos(dPhase2 + 0.8 * i) + 0.5 * Random.NextDouble(); highLow.HighValues.Add(d1); highLow.LowValues.Add(d2); } }
private void LoadFromFileButton_Click(object sender, System.EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Binary(*.bin)|*.bin|XML(*.xml)|*.xml|All files (*.*)|*.*"; if (dlg.ShowDialog() != DialogResult.OK) { return; } try { NSerializationFilter filter = GetSeriazliationFilter(); nChartControl1.Serializer.LoadControlStateFromFile(dlg.FileName, (PersistencyFormat)SerializationFormatComboBox.SelectedIndex, filter); // update form members if (nChartControl1.Charts.Count > 0) { m_Chart = nChartControl1.Charts[0]; foreach (NSeriesBase series in m_Chart.Series) { if (series is NHighLowSeries) { m_HighLow = (NHighLowSeries)series; } else if (series is NLineSeries) { m_LineSMA = (NLineSeries)series; } else if (series is NStockSeries) { m_Stock = (NStockSeries)series; } } } nChartControl1.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = nChartControl1.Labels.AddHeader("High Low Palette"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // configure the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Enable3D = true; m_Chart.Axis(StandardAxis.Depth).Visible = false; // add a High-Low series m_HighLow = (NHighLowSeries)m_Chart.Series.Add(SeriesType.HighLow); m_HighLow.Legend.Mode = SeriesLegendMode.None; m_HighLow.DataLabelStyle.Visible = false; GenerateData(); NPalette palette = new NPalette(); palette.Clear(); palette.SmoothPalette = true; palette.Mode = PaletteMode.Custom; palette.Add(0, Color.Green); palette.Add(1.5, Color.Yellow); palette.Add(3, Color.Red); m_HighLow.Palette = palette; // apply layout ConfigureStandardLayout(m_Chart, title, nChartControl1.Legends[0]); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); SmoothPaletteCheckBox.IsChecked = true; Enable3DCheckBox.IsChecked = true; }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = nChartControl1.Labels.AddHeader("3D High Low Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Width = 65; chart.Height = 40; chart.Axis(StandardAxis.Depth).Visible = false; chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); NHighLowSeries highLow = (NHighLowSeries)chart.Series.Add(SeriesType.HighLow); highLow.Name = "High-Low Series"; highLow.HighFillStyle = new NColorFillStyle(GreyBlue); highLow.LowFillStyle = new NColorFillStyle(DarkOrange); highLow.HighBorderStyle = new NStrokeStyle(GreyBlue); highLow.LowBorderStyle = new NStrokeStyle(DarkOrange); highLow.Legend.Mode = SeriesLegendMode.SeriesLogic; highLow.DataLabelStyle.Visible = false; highLow.DataLabelStyle.Format = "<high_value>:<low_value>"; highLow.LowValues.ValueFormatter = new NNumericValueFormatter("0.#"); highLow.HighValues.ValueFormatter = new NNumericValueFormatter("0.#"); GenerateData(highLow); // apply layout ConfigureStandardLayout(chart, title, null); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); nChartControl1.Refresh(); }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("3D High Low Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Width = 65; chart.Height = 40; chart.Axis(StandardAxis.Depth).Visible = false; chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); NHighLowSeries highLow = (NHighLowSeries)chart.Series.Add(SeriesType.HighLow); highLow.Name = "High-Low Series"; highLow.HighFillStyle = new NColorFillStyle(GreyBlue); highLow.LowFillStyle = new NColorFillStyle(DarkOrange); highLow.HighBorderStyle = new NStrokeStyle(GreyBlue); highLow.LowBorderStyle = new NStrokeStyle(DarkOrange); highLow.Legend.Mode = SeriesLegendMode.SeriesLogic; highLow.DataLabelStyle.Visible = false; highLow.DataLabelStyle.Format = "<high_value>:<low_value>"; highLow.LowValues.ValueFormatter = new NNumericValueFormatter("0.#"); highLow.HighValues.ValueFormatter = new NNumericValueFormatter("0.#"); GenerateData(highLow); // apply layout ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); // init form controls DepthScroll.Value = (int)highLow.DepthPercent; }
private void SeriesTypeCombo_SelectedIndexChanged(object sender, System.EventArgs e) { if (nChartControl1 == null) { return; } NChart chart = nChartControl1.Charts[0]; NSeries series = null; chart.Series.Clear(); switch (SeriesTypeCombo.SelectedIndex) { case 0: series = (NSeries)chart.Series.Add(SeriesType.FloatBar); NFloatBarSeries bar = (NFloatBarSeries)series; GenerateData(bar.Values, bar.EndValues, 10, 3); break; case 1: series = (NSeries)chart.Series.Add(SeriesType.HighLow); NHighLowSeries highLow = (NHighLowSeries)series; GenerateData(highLow.HighValues, highLow.LowValues, 10, 3); break; } series.Values.ValueFormatter = new NNumericValueFormatter("0.00"); series.Legend.Mode = SeriesLegendMode.DataPoints; nChartControl1.Refresh(); ValueModeCombo.SelectedIndex = 0; AppearanceModeCombo.SelectedIndex = 0; MarkerModeCombo.SelectedIndex = 0; ShowLabelsCheck.Checked = false; CustomValue.Text = "0"; }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("High Low Palette"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // configure the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Axis(StandardAxis.Depth).Visible = false; // add a High-Low series m_HighLow = (NHighLowSeries)m_Chart.Series.Add(SeriesType.HighLow); m_HighLow.Legend.Mode = SeriesLegendMode.None; m_HighLow.DataLabelStyle.Visible = false; GenerateData(); NPalette palette = new NPalette(); palette.Clear(); palette.Mode = PaletteMode.Custom; palette.Add(0, Color.Green); palette.Add(1.5, Color.Yellow); palette.Add(3, Color.Red); m_HighLow.Palette = palette; // apply layout ConfigureStandardLayout(m_Chart, title, nChartControl1.Legends[0]); SmoothPaletteCheckBox.Checked = true; Enable3DCheckBox.Checked = true; }
/// <summary> /// /// </summary> /// <returns></returns> protected override NWidget CreateExampleContent() { NChartView chartView = CreateCartesianChartView(); // configure title chartView.Surface.Titles[0].Text = "Standard High Low"; // configure chart m_Chart = (NCartesianChart)chartView.Surface.Charts[0]; m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear); // add interlace stripe NLinearScale linearScale = m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale as NLinearScale; NScaleStrip strip = new NScaleStrip(new NColorFill(ENNamedColor.Beige), null, true, 0, 0, 1, 1); strip.Interlaced = true; m_HighLow = new NHighLowSeries(); m_HighLow.Name = "High-Low Series"; m_HighLow.HighFill = new NColorFill(NColor.Gray); m_HighLow.LowFill = new NColorFill(NColor.Orange); m_HighLow.HighStroke = new NStroke(2, NColor.Black); m_HighLow.LowStroke = new NStroke(2, NColor.Red); m_HighLow.Stroke = new NStroke(2, NColor.Black); m_HighLow.DataLabelStyle = new NDataLabelStyle(false); m_HighLow.Palette = new NTwoColorPalette(NColor.Red, NColor.Green); GenerateData(); m_Chart.Series.Add(m_HighLow); chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, false)); return(chartView); }
public override void Initialize() { base.Initialize(); const int nNumberOfWeeks = 20; const int nWorkDaysInWeek = 5; const int nDaysInWeek = 7; const int nTotalWorkDays = nNumberOfWeeks * nWorkDaysInWeek; const int nTotalDays = nNumberOfWeeks * nDaysInWeek; const int nHistoricalDays = 20; NLabel title = nChartControl1.Labels.AddHeader("Financial Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // setup chart m_Chart = nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Fit; m_Chart.Location = new NPointL(new NLength(7, NRelativeUnit.ParentPercentage), new NLength(10, NRelativeUnit.ParentPercentage)); m_Chart.Size = new NSizeL(new NLength(86, NRelativeUnit.ParentPercentage), new NLength(70, NRelativeUnit.ParentPercentage)); m_Chart.Height = 30; m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); m_Chart.Wall(ChartWallType.Floor).Visible = false; m_Chart.Wall(ChartWallType.Left).Visible = false; m_Chart.Wall(ChartWallType.Back).Width = 0; m_Chart.Wall(ChartWallType.Back).FillStyle = new NColorFillStyle(Color.FromArgb(239, 245, 239)); m_Chart.Axis(StandardAxis.Depth).Visible = false; // setup y axis NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.MajorGridStyle.LineStyle.Color = Color.Gray; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, false); // setup x axis NAxis axisX1 = m_Chart.Axis(StandardAxis.PrimaryX); linearScale = new NLinearScaleConfigurator(); axisX1.ScaleConfigurator = linearScale; linearScale.AutoLabels = false; linearScale.MinorTickCount = 4; linearScale.MajorTickMode = MajorTickMode.CustomStep; linearScale.CustomStep = 5; linearScale.RoundToTickMax = false; linearScale.RoundToTickMin = false; linearScale.OuterMajorTickStyle.Length = new NLength(4, NGraphicsUnit.Point); linearScale.InnerMajorTickStyle.Length = new NLength(0, NGraphicsUnit.Point); linearScale.InnerMinorTickStyle.Length = new NLength(0, NGraphicsUnit.Point); linearScale.OuterMinorTickStyle.Length = new NLength(2, NGraphicsUnit.Point); linearScale.OuterMinorTickStyle.LineStyle.Color = Color.Brown; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, false); linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale.LabelStyle.ValueScale = 0.2; // create a line series for the simple moving average m_LineSMA = (NLineSeries)m_Chart.Series.Add(SeriesType.Line); m_LineSMA.Name = "SMA(20)"; m_LineSMA.DataLabelStyle.Visible = false; m_LineSMA.BorderStyle.Color = Color.DarkOrange; // create the stock series m_Stock = (NStockSeries)m_Chart.Series.Add(SeriesType.Stock); m_Stock.Name = "Stock Data"; m_Stock.Legend.Mode = SeriesLegendMode.None; m_Stock.DataLabelStyle.Visible = false; m_Stock.CandleStyle = CandleStyle.Bar; m_Stock.CandleWidth = new NLength(5, NGraphicsUnit.Point); m_Stock.InflateMargins = false; m_Stock.UpFillStyle = new NColorFillStyle(LightOrange); m_Stock.UpStrokeStyle.Color = Color.Black; m_Stock.DownFillStyle = new NColorFillStyle(DarkOrange); m_Stock.DownStrokeStyle.Color = Color.Black; m_Stock.DisplayOnAxis(StandardAxis.PrimaryX, true); m_Stock.InflateMargins = true; m_Stock.OpenValues.Name = "open"; m_Stock.CloseValues.Name = "close"; m_Stock.HighValues.Name = "high"; m_Stock.LowValues.Name = "low"; // add the bollinger bands as high low area m_HighLow = (NHighLowSeries)m_Chart.Series.Add(SeriesType.HighLow); m_HighLow.Name = "BB(20, 2)"; m_HighLow.DataLabelStyle.Visible = false; m_HighLow.HighFillStyle = new NColorFillStyle(Color.FromArgb(80, 130, 134, 168)); m_HighLow.HighBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); m_HighLow.DisplayOnAxis(StandardAxis.SecondaryX, true); // generate some stock data GenerateOHLCData(m_Stock, 300, nTotalWorkDays + nHistoricalDays); // create a function calculator NFunctionCalculator fc = new NFunctionCalculator(); fc.Arguments.Add(m_Stock.CloseValues); // calculate the bollinger bands fc.Expression = "BOLLINGER(close; 20; 2)"; m_HighLow.HighValues = fc.Calculate(); m_HighLow.HighValues.Name = "BollingerUpper"; fc.Expression = "BOLLINGER(close; 20; -2)"; m_HighLow.LowValues = fc.Calculate(); m_HighLow.LowValues.Name = "BollingerLower"; // calculate the simple moving average fc.Expression = "SMA(close; 20)"; m_LineSMA.Values = fc.Calculate(); // remove data that won't be charted m_Stock.HighValues.RemoveRange(0, nHistoricalDays); m_Stock.LowValues.RemoveRange(0, nHistoricalDays); m_Stock.OpenValues.RemoveRange(0, nHistoricalDays); m_Stock.CloseValues.RemoveRange(0, nHistoricalDays); m_HighLow.HighValues.RemoveRange(0, nHistoricalDays); m_HighLow.LowValues.RemoveRange(0, nHistoricalDays); m_LineSMA.Values.RemoveRange(0, nHistoricalDays); GenerateDateLabels(nTotalDays); CandleStyleCombo.Items.Add("Candle"); CandleStyleCombo.Items.Add("Stick"); CandleStyleCombo.SelectedIndex = 0; NRangeSelection rangeSelection = new NRangeSelection(); rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper(); ((NCartesianChart)m_Chart).RangeSelections.Add(rangeSelection); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); nChartControl1.Controller.Tools.Add(new NDataPanTool()); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CandleStyleDropDownList.Items.Add("Candle"); CandleStyleDropDownList.Items.Add("Stick"); CandleStyleDropDownList.SelectedIndex = 0; } const int nNumberOfWeeks = 20; const int nWorkDaysInWeek = 5; const int nTotalWorkDays = nNumberOfWeeks * nWorkDaysInWeek; nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set chart title NLabel title = nChartControl1.Labels.AddHeader("Financial Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // setup chart NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; chart.Location = new NPointL(new NLength(5, NRelativeUnit.ParentPercentage), new NLength(12, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(90, NRelativeUnit.ParentPercentage), new NLength(84, NRelativeUnit.ParentPercentage)); chart.Height = 30; // setup y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; scaleY.MajorGridStyle.LineStyle.Color = Color.Gray; scaleY.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; // add interlaced stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleY.StripStyles.Add(stripStyle); // setup X axis NRangeTimelineScaleConfigurator scaleX = new NRangeTimelineScaleConfigurator(); scaleX.FirstRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleX.FirstRow.GridStyle.LineStyle = new NStrokeStyle(1, Color.FromArgb(225, 225, 225)); scaleX.FirstRow.UseGridStyle = true; scaleX.SecondRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleX.SecondRow.GridStyle.LineStyle = new NStrokeStyle(1, Color.FromArgb(215, 215, 215)); scaleX.SecondRow.UseGridStyle = true; scaleX.ThirdRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleX.ThirdRow.GridStyle.LineStyle = new NStrokeStyle(1, Color.FromArgb(205, 205, 205)); scaleX.ThirdRow.UseGridStyle = true; // calendar NWeekDayRule wdr = new NWeekDayRule(WeekDayBit.All); wdr.Saturday = false; wdr.Sunday = false; scaleX.Calendar.Rules.Add(wdr); scaleX.EnableCalendar = true; // set configurator chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // create a line series for the simple moving average NLineSeries lineSMA = (NLineSeries)chart.Series.Add(SeriesType.Line); lineSMA.Name = "SMA(20)"; lineSMA.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point); lineSMA.DataLabelStyle.Visible = false; lineSMA.BorderStyle.Color = Color.DarkOrange; lineSMA.UseXValues = true; // create the stock series NStockSeries stock = (NStockSeries)chart.Series.Add(SeriesType.Stock); stock.Name = "Stock Data"; stock.Legend.Mode = SeriesLegendMode.None; stock.DataLabelStyle.Visible = false; stock.CandleStyle = CandleStyle.Bar; stock.CandleWidth = new NLength(2, NGraphicsUnit.Point); stock.InflateMargins = true; stock.UseXValues = true; stock.UpFillStyle = new NColorFillStyle(Green); stock.UpStrokeStyle.Color = Color.Black; stock.DownFillStyle = new NColorFillStyle(DarkOrange); stock.DownStrokeStyle.Color = Color.Black; // add the bollinger bands as high low area NHighLowSeries highLow = (NHighLowSeries)chart.Series.Add(SeriesType.HighLow); highLow.Name = "BB(20, 2)"; highLow.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point); highLow.DataLabelStyle.Visible = false; highLow.HighFillStyle = new NColorFillStyle(Color.FromArgb(80, 130, 134, 168)); highLow.HighBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); highLow.UseXValues = true; // generate some stock data WebExamplesUtilities.GenerateOHLCData(stock, 400, nTotalWorkDays + 20); FillStockDates(stock, nTotalWorkDays + 20); // create a function calculator NFunctionCalculator fc = new NFunctionCalculator(); stock.CloseValues.Name = "close"; fc.Arguments.Add(stock.CloseValues); // calculate the bollinger bands fc.Expression = "BOLLINGER(close; 20; 2)"; highLow.HighValues = fc.Calculate(); fc.Expression = "BOLLINGER(close; 20; -2)"; highLow.LowValues = fc.Calculate(); // calculate the simple moving average fc.Expression = "SMA(close; 20)"; lineSMA.Values = fc.Calculate(); // remove data that won't be charted stock.HighValues.RemoveRange(0, 20); stock.LowValues.RemoveRange(0, 20); stock.OpenValues.RemoveRange(0, 20); stock.CloseValues.RemoveRange(0, 20); stock.XValues.RemoveRange(0, 20); highLow.HighValues.RemoveRange(0, 20); highLow.LowValues.RemoveRange(0, 20); highLow.XValues = (NDataSeriesDouble)stock.XValues.Clone(); lineSMA.Values.RemoveRange(0, 20); lineSMA.XValues = (NDataSeriesDouble)stock.XValues.Clone(); stock.CandleStyle = (CandleStyle)CandleStyleDropDownList.SelectedIndex; lineSMA.Visible = SMACheckBox.Checked; highLow.Visible = SBBCheckBox.Checked; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { HighLabelTextBox.Text = "High"; LowLabelTextBox.Text = "Low"; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("XY High-Low"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // no legend nChartControl1.Legends.Clear(); // configure chart NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; // setup X axis NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; scaleX.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleX.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; // add interlace stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left }; scaleY.StripStyles.Add(stripStyle); // create the series NHighLowSeries highLow = (NHighLowSeries)chart.Series.Add(SeriesType.HighLow); highLow.Name = "High-Low Series"; highLow.DataLabelStyle.Format = "<high_label><low_label>"; highLow.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(7); highLow.HighFillStyle = new NColorFillStyle(Color.LightSlateGray); highLow.LowFillStyle = new NColorFillStyle(Color.DarkOrange); highLow.ShadowStyle.Type = ShadowType.GaussianBlur; highLow.UseXValues = true; highLow.HighLabel = HighLabelTextBox.Text; highLow.LowLabel = LowLabelTextBox.Text; // fill values GenerateValuesY(highLow, 8); GenerateValuesX(highLow, 8); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataLabelFormatDropDownList.Items.Add("high"); DataLabelFormatDropDownList.Items.Add("low"); DataLabelFormatDropDownList.Items.Add("high low"); DataLabelFormatDropDownList.SelectedIndex = 0; WebExamplesUtilities.FillComboWithEnumValues(MarkerShapeDropDownList, typeof(PointShape)); MarkerShapeDropDownList.SelectedIndex = 0; WebExamplesUtilities.FillComboWithColorNames(HighAreaColorDropDownList, KnownColor.LightSlateGray); WebExamplesUtilities.FillComboWithColorNames(LowAreaColorDropDownList, KnownColor.DarkOrange); WebExamplesUtilities.FillComboWithValues(MarkerSizeDropDownList, 0, 5, 1); MarkerSizeDropDownList.SelectedIndex = 2; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("2D High-Low Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // configure the chart NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; // setup X axis NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; scaleX.DisplayDataPointsBetweenTicks = false; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.MajorGridStyle.LineStyle.Color = Color.LightGray; // add interlace stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleY.StripStyles.Add(stripStyle); NHighLowSeries highLow = (NHighLowSeries)chart.Series.Add(SeriesType.HighLow); highLow.Name = "High-Low Series"; highLow.InflateMargins = true; highLow.Legend.Mode = SeriesLegendMode.SeriesLogic; highLow.MarkerStyle.FillStyle = new NColorFillStyle(Red); highLow.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(7); highLow.LowValues.ValueFormatter = new NNumericValueFormatter("0.#"); highLow.HighValues.ValueFormatter = new NNumericValueFormatter("0.#"); highLow.HighFillStyle = new NColorFillStyle(WebExamplesUtilities.ColorFromDropDownList(HighAreaColorDropDownList)); highLow.LowFillStyle = new NColorFillStyle(WebExamplesUtilities.ColorFromDropDownList(LowAreaColorDropDownList)); highLow.DropLines = ShowDropLinesCheckBox.Checked; highLow.DataLabelStyle.Visible = ShowDataLabelsCheckBox.Checked; switch (DataLabelFormatDropDownList.SelectedIndex) { case 0: highLow.DataLabelStyle.Format = "<high_value>"; break; case 1: highLow.DataLabelStyle.Format = "<low_value>"; break; case 2: highLow.DataLabelStyle.Format = "<high_value> - <low_value>"; break; } MarkerShapeDropDownList.Enabled = ShowMarkersCheckBox.Checked; MarkerSizeDropDownList.Enabled = ShowMarkersCheckBox.Checked; highLow.MarkerStyle.Visible = ShowMarkersCheckBox.Checked; highLow.MarkerStyle.PointShape = (PointShape)MarkerShapeDropDownList.SelectedIndex; highLow.MarkerStyle.Width = new NLength((float)MarkerSizeDropDownList.SelectedIndex, NRelativeUnit.ParentPercentage); highLow.MarkerStyle.Height = new NLength((float)MarkerSizeDropDownList.SelectedIndex, NRelativeUnit.ParentPercentage); GenerateData(highLow); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, nChartControl1.Legends[0]); }
private void AddData(NCartesianChart chart, NWorkCalendar calendar) { const int nNumberOfWeeks = 20; const int nWorkDaysInWeek = 5; const int nTotalWorkDays = nNumberOfWeeks * nWorkDaysInWeek; const int nHistoricalDays = 20; NLineSeries lineSMA = new NLineSeries(); lineSMA.Name = "SMA(20)"; lineSMA.DataLabelStyle.Visible = false; lineSMA.BorderStyle.Color = Color.DarkOrange; lineSMA.UseXValues = true; // create the stock series NStockSeries stock = new NStockSeries(); chart.Series.Add(stock); stock.DisplayOnAxis(StandardAxis.PrimaryX, true); stock.Name = "Stock Data"; stock.Legend.Mode = SeriesLegendMode.None; stock.DataLabelStyle.Visible = false; stock.CandleStyle = CandleStyle.Bar; stock.CandleWidth = new NLength(0.8f, NRelativeUnit.ParentPercentage); stock.InflateMargins = true; stock.UseXValues = true; stock.UpFillStyle = new NColorFillStyle(Green); stock.UpStrokeStyle.Color = Color.Black; stock.DownFillStyle = new NColorFillStyle(DarkOrange); stock.DownStrokeStyle.Color = Color.Black; stock.OpenValues.Name = "open"; stock.CloseValues.Name = "close"; stock.HighValues.Name = "high"; stock.LowValues.Name = "low"; int period = 20; // add the bollinger bands as high low area NHighLowSeries highLow = new NHighLowSeries(); chart.Series.Add(highLow); highLow.DisplayOnAxis(StandardAxis.SecondaryX, true); highLow.Name = "BB(" + period.ToString() + ", 2)"; highLow.DataLabelStyle.Visible = false; highLow.HighFillStyle = new NColorFillStyle(Color.FromArgb(80, 130, 134, 168)); highLow.HighBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); highLow.UseXValues = true; // generate some stock data GenerateData(stock, calendar, 300, nTotalWorkDays + nHistoricalDays); // create a function calculator NFunctionCalculator fc = new NFunctionCalculator(); fc.Arguments.Add(stock.CloseValues); // calculate the bollinger bands fc.Expression = "BOLLINGER(close;" + period.ToString() + "; 2)"; highLow.HighValues = fc.Calculate(); highLow.HighValues.Name = "BollingerUpper"; fc.Expression = "BOLLINGER(close; " + period.ToString() + "; -2)"; highLow.LowValues = fc.Calculate(); highLow.LowValues.Name = "BollingerLower"; highLow.XValues.InsertRange(0, stock.XValues); // calculate the simple moving average fc.Expression = "SMA(close; " + period.ToString() + ")"; lineSMA.Values = fc.Calculate(); lineSMA.XValues.InsertRange(0, stock.XValues); // remove first period from line SMA lineSMA.Values.RemoveRange(0, period); lineSMA.XValues.RemoveRange(0, period); // remove first period from high low highLow.XValues.RemoveRange(0, period); highLow.HighValues.RemoveRange(0, period); highLow.LowValues.RemoveRange(0, period); // remove first period from stock stock.OpenValues.RemoveRange(0, period); stock.HighValues.RemoveRange(0, period); stock.LowValues.RemoveRange(0, period); stock.CloseValues.RemoveRange(0, period); stock.XValues.RemoveRange(0, period); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SmoothPaletteCheckBox.Checked = true; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Legends[0].Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Float Bar Palette"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // configure the chart NChart chart = nChartControl1.Charts[0]; chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalHalf); chart.Axis(StandardAxis.Depth).Visible = false; // add interlace stripe NAxis yAxis = chart.Axis(StandardAxis.PrimaryY); NLinearScaleConfigurator linearScale = yAxis.ScaleConfigurator as NLinearScaleConfigurator; NScaleStripStyle strip = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); strip.Interlaced = true; strip.SetShowAtWall(ChartWallType.Back, true); linearScale.StripStyles.Add(strip); // add a High-Low series NHighLowSeries highLow = (NHighLowSeries)chart.Series.Add(SeriesType.HighLow); highLow.Legend.Mode = SeriesLegendMode.None; highLow.DataLabelStyle.Visible = false; highLow.ClearDataPoints(); for (int i = 0; i < 20; i++) { double d1 = Math.Log(i + 1) + 0.1 * Random.NextDouble(); double d2 = d1 + Math.Cos(0.33 * i) + 0.1 * Random.NextDouble(); highLow.HighValues.Add(d1); highLow.LowValues.Add(d2); } NPalette palette = new NPalette(); palette.Clear(); palette.Mode = PaletteMode.Custom; palette.Add(0, Color.Green); palette.Add(1.5, Color.Yellow); palette.Add(3, Color.Red); highLow.Palette = palette; highLow.Palette.SmoothPalette = SmoothPaletteCheckBox.Checked; // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, nChartControl1.Legends[0]); }
private void callLowHighGraph(string projectName, string ScenarioName) { nChartControl1.Clear(); nChartControl1.Legends.Clear(); NLabel title = nChartControl1.Labels.AddHeader("이미지별 최대 최소 시간"); //title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Bold); title.TextStyle.FontStyle = new NFontStyle(pfc.Families[0].ToString(), 18, FontStyle.Regular); //title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); // configure the chart m_Chart = nChartControl1.Charts[0]; m_Chart.Axis(StandardAxis.Depth).Visible = false; // add a High-Low series m_HighLow = (NHighLowSeries)m_Chart.Series.Add(SeriesType.HighLow); m_HighLow.Name = "High-Low Series"; m_HighLow.HighFillStyle = new NColorFillStyle(Color.FromArgb(68, 90, 108)); m_HighLow.HighBorderStyle = new NStrokeStyle(Color.FromArgb(254, 181, 25)); //m_HighLow.LowFillStyle = new NColorFillStyle(DarkOrange); m_HighLow.DataLabelStyle.Visible = true; m_HighLow.DataLabelStyle.Format = " <high_value>\n<low_value>"; m_HighLow.LowValues.ValueFormatter = new NNumericValueFormatter("0.##"); m_HighLow.HighValues.ValueFormatter = new NNumericValueFormatter("0.##"); m_HighLow.DropLines = true; m_HighLow.ClearDataPoints(); NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); //m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; m_Chart.Axis(StandardAxis.PrimaryX).ScrollBar.ResetButton.Visible = false; NNumericAxisPagingView numericPagingView = new NNumericAxisPagingView(new NRange1DD(0, 10)); m_Chart.Axis(StandardAxis.PrimaryX).PagingView = numericPagingView; m_Chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true; nChartControl1.Controller.Tools.Add(new NAxisScrollTool()); NStandardScaleConfigurator scaleConfiguratorX = (NStandardScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; scaleConfiguratorX.MajorTickMode = MajorTickMode.AutoMaxCount; scaleConfiguratorX.AutoLabels = false; // data 값을 다 불러와서 foreach (ResultData.ResultInfo temp in rData.getRData()) { // 현재 찾고자 하는 프로젝트와 시나리오랑 같으면 if (temp.projectName == projectName && temp.taskName == ScenarioName) { // 해당 시나리오 값에서 이동한 path 이미지들 값 가져오기 foreach (ResultData.ImgTime imgTemp in temp.pathInfo) { bool inList = false; float timeValue = System.Convert.ToSingle(imgTemp.timeImg); // 리스트 내에 같은 값 찾기 if (ImgTimeInfo.Count != 0) { foreach (ImgTime inListImg in ImgTimeInfo) { // 같은게 있다면 if (inListImg.imgName == imgTemp.imgName) { // 현재 값이 high 보다 크다면 if (inListImg.High <= timeValue) inListImg.High = timeValue; else if (inListImg.Low >= timeValue) inListImg.Low = timeValue; inList = true; break; } } } // 리스트 내에 없다면 if (inList == false) ImgTimeInfo.Add(new ImgTime() { imgName = imgTemp.imgName, High = timeValue, Low = timeValue }); } } } foreach (ImgTime listImg in ImgTimeInfo) { scaleConfiguratorX.Labels.Add(listImg.imgName); m_HighLow.HighValues.Add(listImg.High); m_HighLow.LowValues.Add(listImg.Low); } nChartControl1.Refresh(); }