private void GenerateData() { WebExamplesUtilities.GenerateOHLCData(m_Stock, 100, 200, new NRange1DD(50, 350)); double min = (double)m_Stock.LowValues[m_Stock.LowValues.FindMinValue()]; double max = (double)m_Stock.HighValues[m_Stock.HighValues.FindMaxValue()]; m_MinIndicator.Value = min; m_MaxIndicator.Value = max; int count = m_Stock.CloseValues.Count; double sum = 0; for (int i = 0; i < count; i++) { sum += (double)m_Stock.CloseValues[i]; } if (count > 0) { m_AvgIndicator.Value = sum / count; } else { m_AvgIndicator.Value = 0; } }
private void GenerateData(NStockSeries stock) { const double initialPrice = 100; const int numDataPoits = 50; WebExamplesUtilities.GenerateOHLCData(stock, initialPrice, numDataPoits); FillStockDates(stock, numDataPoits, new DateTime(2010, 1, 11)); }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // confgigure chart nChartControl1.Panels.Clear(); // set a chart title NLabel title = new NLabel("Legend Item Text Fit Mode"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.DockMode = PanelDockMode.Top; title.Margins = new NMarginsL(0, 10, 0, 10); nChartControl1.Panels.Add(title); // configure the legend NLegend legend = new NLegend(); legend.Header.Text = "Maximum Legend Item Text Size"; legend.Mode = LegendMode.Manual; legend.Data.ExpandMode = LegendExpandMode.HorzWrap; legend.DockMode = PanelDockMode.Top; legend.Margins = new NMarginsL(20, 20, 20, 20); nChartControl1.Panels.Add(legend); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // init controls if (!IsPostBack) { WebExamplesUtilities.FillComboWithEnumNames(LegendItemTextFitModeDropDownList, typeof(LegendTextFitMode)); WebExamplesUtilities.FillComboWithValues(LegendItemMaximumWidthDropDownList, 50, 150, 50); } // Update legend items Array markShapes = Enum.GetValues(typeof(LegendMarkShape)); NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Nevron); for (int i = 0; i < markShapes.Length; i++) { NLegendItemCellData licd = new NLegendItemCellData(); LegendMarkShape markShape = (LegendMarkShape)markShapes.GetValue(i); licd.Text = "Some very long text about mark shape [" + markShape.ToString() + "]"; licd.MarkShape = markShape; licd.MarkFillStyle = new NColorFillStyle(palette.SeriesColors[i % palette.SeriesColors.Count]); licd.TextFitMode = (LegendTextFitMode)LegendItemTextFitModeDropDownList.SelectedIndex; licd.MaxTextWidth = new NLength((float)(LegendItemMaximumWidthDropDownList.SelectedIndex + 1) * 50); legend.Data.Items.Add(licd); } }
protected void Page_Load(object sender, System.EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel header = nChartControl1.Labels.AddFooter("Volume Indicators"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // setup charts NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; chart.Location = new NPointL(new NLength(5, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(90, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); SetupTimeScale(chart.Axis(StandardAxis.PrimaryX)); NStockSeries stock = SetupStockChart(chart); NAreaSeries volume = SetupVolumeChart(chart); NLineSeries line = SetupIndicatorChart(chart); // form controls if (!IsPostBack) { FunctionDropDownList.Items.Add("Accumulation Distribution"); FunctionDropDownList.Items.Add("Chaikin Oscillator"); FunctionDropDownList.Items.Add("Ease of Movement"); FunctionDropDownList.Items.Add("Money Flow Index"); FunctionDropDownList.Items.Add("Negative Volume Index"); FunctionDropDownList.Items.Add("On Balance Volume"); FunctionDropDownList.Items.Add("Positive Volume Index"); FunctionDropDownList.Items.Add("Price and Volume Trend"); FunctionDropDownList.SelectedIndex = 0; WebExamplesUtilities.FillComboWithValues(ParameterDropDownList, 0, 100, 10); ParameterDropDownList.SelectedIndex = 1; } NFunctionCalculator function = new NFunctionCalculator(); // generate data GenerateData(stock, volume, line); GenerateVolumeData(volume, prevVolumeValue, numDataPoits); UpdateFunction(stock, volume, line, function); line.Values = function.Calculate(); line.XValues = (NDataSeriesDouble)stock.XValues.Clone(); volume.XValues = (NDataSeriesDouble)stock.XValues.Clone(); }
private void AddPieButton_Click(object sender, EventArgs e) { NChart chart = nChartControl1.Charts[0]; NPieSeries pieSeries = (NPieSeries)chart.Series[0]; double value = Convert.ToDouble(PieValueTextBox.Text); String text = "Pie " + Convert.ToString(pieSeries.Values.Count + 1); NFillStyle fill = new NColorFillStyle(WebExamplesUtilities.RandomColor()); pieSeries.AddDataPoint(new NDataPoint(value, text, fill)); }
private void GenerateData(NStockSeries stock, NAreaSeries volume, NLineSeries line) { WebExamplesUtilities.GenerateOHLCData(stock, prevCloseValue, numDataPoits); FillStockDates(stock, numDataPoits, new DateTime(2010, 1, 11)); GenerateVolumeData(volume, prevVolumeValue, numDataPoits); volume.XValues.Clear(); volume.XValues.AddRange(stock.XValues); line.XValues.Clear(); line.XValues.AddRange(stock.XValues); }
private void GenerateData(DateTime dtStart, DateTime dtEnd, NDateTimeSpan span) { long count = span.GetSpanCountInRange(new NDateTimeRange(dtStart, dtEnd)); WebExamplesUtilities.GenerateOHLCData(m_Stock, 100, (int)count); m_Stock.XValues.Clear(); DateTime dtNow = dtStart; for (int i = 0; i < m_Stock.Values.Count; i++) { m_Stock.XValues.Add(dtNow.ToOADate()); dtNow = span.Add(dtNow); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SampleFormattedLabelDropDownList.Items.Add("Font size and color"); SampleFormattedLabelDropDownList.Items.Add("Font style control"); SampleFormattedLabelDropDownList.Items.Add("Subscript and superscript"); SampleFormattedLabelDropDownList.Items.Add("Shapes"); SampleFormattedLabelDropDownList.Items.Add("Bullets"); SampleFormattedLabelDropDownList.Items.Add("Fill Effects"); SampleFormattedLabelDropDownList.Items.Add("Borders"); SampleFormattedLabelDropDownList.Items.Add("Shadows"); SampleFormattedLabelDropDownList.Items.Add("Background Fill and Stroke"); SampleFormattedLabelDropDownList.SelectedIndex = 8; WebExamplesUtilities.FillComboWithFontNames(FontDropDownList, "Arial"); WebExamplesUtilities.FillComboWithValues(FontSizeDropDownList, 8, 52, 1); WebExamplesUtilities.FillComboWithColorNames(FontColorDropDownList, KnownColor.Black); HasBackplaneCheckBox.Checked = true; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Panels.Clear(); NLabel label = new NLabel(); try { label.TextStyle.FontStyle = new NFontStyle(FontDropDownList.SelectedItem.Text, FontSizeDropDownList.SelectedIndex + 8); } catch { } label.Text = GetFormattedString((int)label.TextStyle.FontStyle.EmSize.Value); label.TextStyle.FillStyle = new NColorFillStyle(WebExamplesUtilities.ColorFromDropDownList(FontColorDropDownList)); label.TextStyle.TextFormat = TextFormat.XML; label.TextStyle.BackplaneStyle.Visible = HasBackplaneCheckBox.Checked; label.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Left; label.TextStyle.StringFormatStyle.VertAlign = VertAlign.Top; label.TextStyle.TextFormat = TextFormat.XML; label.Location = new NPointL(new NLength(5, NRelativeUnit.ParentPercentage), new NLength(5, NRelativeUnit.ParentPercentage)); nChartControl1.Panels.Add(label); }
protected void Page_Load(object sender, EventArgs e) { NChart chart = nChartControl1.Charts[0]; if (!IsPostBack) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Dynamic Axis Range"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // no legend nChartControl1.Legends.Clear(); // setup chart chart.BoundsMode = BoundsMode.Stretch; NLineSeries line = new NLineSeries(); line.DataLabelStyle.Visible = false; line.VerticalAxisRangeMode = AxisRangeMode.ViewRange; GenerateData(line, 100.0, 100, new NRange1DD(60, 140)); chart.Series.Add(line); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator(); WebExamplesUtilities.FillComboWithEnumNames(VerticalAxisRangeModeDropDownList, typeof(AxisRangeMode)); VerticalAxisRangeModeDropDownList.SelectedIndex = (int)AxisRangeMode.ViewRange; int step = 10; for (int beginValue = 0; beginValue < 100; beginValue += step) { IntervalDropDownList.Items.Add(beginValue.ToString() + " - " + (beginValue + step).ToString()); } } { double start = IntervalDropDownList.SelectedIndex * 10; // assign new range chart.Axis(StandardAxis.PrimaryX).View = new NRangeAxisView(new NRange1DD(start, start + 10), true, true); // assign the range mode chart.Series[0].VerticalAxisRangeMode = (AxisRangeMode)VerticalAxisRangeModeDropDownList.SelectedIndex; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SortOrderDropDownList.Items.Add("Ascending"); SortOrderDropDownList.Items.Add("Descending"); SortOrderDropDownList.SelectedIndex = 0; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // add header NLabel header = nChartControl1.Labels.AddHeader("Sorting Data"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.TextStyle.FillStyle = new NColorFillStyle(Color.FromArgb(60, 90, 108)); header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; chart.Axis(StandardAxis.Depth).Visible = false; chart.Location = new NPointL( new NLength(5, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL( new NLength(70, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); // add a new bar serie NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.Values.FillRandom(Random, 6); bar.Labels.FillRandom(Random, 6); for (int i = 0; i < bar.Values.Count; i++) { bar.FillStyles[i] = new NColorFillStyle(WebExamplesUtilities.RandomColor()); } bar.Legend.Mode = SeriesLegendMode.DataPoints; bar.Values.Sort((DataSeriesSortOrder)SortOrderDropDownList.SelectedIndex); }
private void GenerateData(DateTime dtStart, DateTime dtEnd, NDateTimeSpan span) { long count = span.GetSpanCountInRange(new NDateTimeRange(dtStart, dtEnd)); WebExamplesUtilities.GenerateOHLCData(m_Stock, 100, (int)count); m_Stock.XValues.Clear(); DateTime dtNow = dtStart; for (int i = 0; i < m_Stock.Values.Count; i++) { m_Stock.XValues.Add(dtNow.ToOADate()); dtNow = span.Add(dtNow); } m_Chart.Axis(StandardAxis.PrimaryX).PagingView.Enabled = false; }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { WebExamplesUtilities.FillComboWithColorNames(UpColorDropDownList, KnownColor.Red); WebExamplesUtilities.FillComboWithColorNames(DownColorDropDownList, KnownColor.Black); ProportionalXCheckBox.Checked = false; ProportionalYCheckBox.Checked = false; WebExamplesUtilities.FillComboWithFloatValues(BoxSizeDropdownlist, 0.5F, 10, 0.5F); BoxSizeDropdownlist.SelectedIndex = 9; WebExamplesUtilities.FillComboWithValues(ReversalAmountDropDownList, 1, 5, 1); ReversalAmountDropDownList.SelectedIndex = 2; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Point and Figure"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // no legend nChartControl1.Legends.Clear(); // configure the chart NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; // setup X axis NPriceScaleConfigurator priceConfigurator = new NPriceScaleConfigurator(); priceConfigurator.LabelValueFormatter = new NDateTimeValueFormatter(DateTimeValueFormat.Date); priceConfigurator.MajorTickMode = MajorTickMode.AutoMaxCount; priceConfigurator.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; priceConfigurator.InnerMajorTickStyle.LineStyle.Width = new NLength(0); priceConfigurator.MaxTickCount = 8; NNumericRangeSamplerProvider provider = new NNumericRangeSamplerProvider(); provider.SamplingMode = SamplingMode.CustomStep; provider.CustomStep = 1; provider.UseOrigin = true; provider.Origin = -0.5; priceConfigurator.MajorGridStyle.RangeSamplerProvider = provider; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = priceConfigurator; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.MajorTickMode = MajorTickMode.CustomStep; scaleY.CustomStep = 5; scaleY.OuterMajorTickStyle.Width = new NLength(0); scaleY.InnerMajorTickStyle.Width = new NLength(0); scaleY.AutoMinorTicks = true; scaleY.MinorTickCount = 1; scaleY.RoundToTickMin = false; scaleY.RoundToTickMax = false; scaleY.MajorGridStyle.LineStyle.Width = new NLength(0); scaleY.MinorGridStyle.LineStyle.Width = new NLength(1); scaleY.MinorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; float[] highValues = new float[20] { 21.3F, 42.4F, 11.2F, 65.7F, 38.0F, 71.3F, 49.54F, 83.7F, 13.9F, 56.12F, 27.43F, 23.1F, 31.0F, 75.4F, 9.3F, 39.12F, 10.0F, 44.23F, 21.76F, 49.2F }; float[] lowValues = new float[20] { 12.1F, 14.32F, 8.43F, 36.0F, 13.5F, 47.34F, 24.54F, 68.11F, 6.87F, 23.3F, 12.12F, 14.54F, 25.0F, 37.2F, 3.9F, 23.11F, 1.9F, 14.0F, 8.23F, 34.21F }; // setup Point & Figure series NPointAndFigureSeries pointAndFigure = (NPointAndFigureSeries)chart.Series.Add(SeriesType.PointAndFigure); pointAndFigure.UseXValues = true; // fill data pointAndFigure.HighValues.AddRange(highValues); pointAndFigure.LowValues.AddRange(lowValues); DateTime dt = new DateTime(2007, 1, 1); for (int i = 0; i < 20; i++) { pointAndFigure.XValues.Add(dt); dt = dt.AddDays(1); } double dBoxSize = Convert.ToDouble(BoxSizeDropdownlist.SelectedValue); pointAndFigure.BoxSize = dBoxSize; scaleY.CustomStep = dBoxSize; pointAndFigure.ProportionalX = ProportionalXCheckBox.Checked; pointAndFigure.ProportionalY = ProportionalYCheckBox.Checked; pointAndFigure.ReversalAmount = Convert.ToInt32(ReversalAmountDropDownList.SelectedValue); pointAndFigure.UpStrokeStyle.Color = WebExamplesUtilities.ColorFromDropDownList(UpColorDropDownList); pointAndFigure.DownStrokeStyle.Color = WebExamplesUtilities.ColorFromDropDownList(DownColorDropDownList); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { WebExamplesUtilities.FillComboWithColorNames(UpStickColorDropDownList, KnownColor.Black); WebExamplesUtilities.FillComboWithColorNames(DownStickColorDropDownList, KnownColor.Crimson); // init form controls ShowHighLowCheckBox.Checked = true; ShowOpenCheckBox.Checked = true; ShowCloseCheckBox.Checked = true; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Stick Stock Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // no legend nChartControl1.Legends.Clear(); // setup chart NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; // setup X axis NValueTimelineScaleConfigurator scaleX = new NValueTimelineScaleConfigurator(); 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.FirstRow.InnerTickStyle.Visible = false; 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.SecondRow.InnerTickStyle.Visible = false; scaleX.ThirdRow.GridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; scaleX.ThirdRow.GridStyle.LineStyle = new NStrokeStyle(1, Color.FromArgb(205, 205, 205)); scaleX.ThirdRow.UseGridStyle = true; scaleX.ThirdRow.InnerTickStyle.Visible = false; // 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; // setup Y axis NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleY.OuterMajorTickStyle.Length = new NLength(3, NGraphicsUnit.Point); scaleY.InnerMajorTickStyle.Visible = false; NFillStyle stripFill = new NColorFillStyle(Color.FromArgb(234, 233, 237)); NScaleStripStyle stripStyle = new NScaleStripStyle(stripFill, null, true, 1, 0, 1, 1); stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; stripStyle.Interlaced = true; scaleY.StripStyles.Add(stripStyle); // setup stock series NStockSeries stock = (NStockSeries)chart.Series.Add(SeriesType.Stock); stock.CandleStyle = CandleStyle.Stick; stock.CandleWidth = new NLength(1.3f, NRelativeUnit.ParentPercentage); stock.DataLabelStyle.Visible = false; stock.UseXValues = true; stock.InflateMargins = true; stock.UpStrokeStyle.Width = new NLength(1, NGraphicsUnit.Point); stock.DownStrokeStyle.Width = new NLength(1, NGraphicsUnit.Point); stock.ShowClose = ShowCloseCheckBox.Checked; stock.ShowOpen = ShowOpenCheckBox.Checked; stock.ShowHighLow = ShowHighLowCheckBox.Checked; stock.UpStrokeStyle.Color = WebExamplesUtilities.ColorFromDropDownList(UpStickColorDropDownList); stock.DownStrokeStyle.Color = WebExamplesUtilities.ColorFromDropDownList(DownStickColorDropDownList); // add some stock items const int count = 40; GenerateOHLCData(stock, count); FillStockDates(stock, count); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LabelTextBox.Text = "Chart Title"; WebExamplesUtilities.FillComboWithPercents(HorizontalMarginDropDownList, 10); HorizontalMarginDropDownList.SelectedIndex = 5; WebExamplesUtilities.FillComboWithPercents(VerticalMarginDropDownList, 10); VerticalMarginDropDownList.SelectedIndex = 1; ContentAlignmentDropDownList.Items.Add("BottomCenter"); ContentAlignmentDropDownList.Items.Add("BottomLeft"); ContentAlignmentDropDownList.Items.Add("BottomRight"); ContentAlignmentDropDownList.Items.Add("MiddleCenter"); ContentAlignmentDropDownList.Items.Add("MiddleLeft"); ContentAlignmentDropDownList.Items.Add("MiddleRight"); ContentAlignmentDropDownList.Items.Add("TopCenter"); ContentAlignmentDropDownList.Items.Add("TopLeft"); ContentAlignmentDropDownList.Items.Add("TopRight"); ContentAlignmentDropDownList.SelectedIndex = 0; WebExamplesUtilities.FillComboWithFontNames(FontDropDownList, "Arial"); WebExamplesUtilities.FillComboWithValues(FontSizeDropDownList, 8, 52, 1); FontSizeDropDownList.SelectedIndex = 2; WebExamplesUtilities.FillComboWithColorNames(FontColorDropDownList, KnownColor.Black); WebExamplesUtilities.FillComboWithValues(FontOrientationDropDownList, 0, 360, 10); HasBackplaneCheckBox.Checked = true; BackplaneStyleDropDownList.Items.Add("Rectangle"); BackplaneStyleDropDownList.Items.Add("Ellipse"); BackplaneStyleDropDownList.Items.Add("Circle"); BackplaneStyleDropDownList.Items.Add("Cut Edge Rectangle"); BackplaneStyleDropDownList.Items.Add("Smooth Edge Rectangle"); BackplaneStyleDropDownList.SelectedIndex = 0; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // setup the label NLabel label = new NLabel(); nChartControl1.Panels.Add(label); label.Text = LabelTextBox.Text; label.TextStyle.FillStyle = new NColorFillStyle(WebExamplesUtilities.ColorFromDropDownList(FontColorDropDownList)); label.TextStyle.Orientation = FontOrientationDropDownList.SelectedIndex * 10; label.TextStyle.BackplaneStyle.Visible = HasBackplaneCheckBox.Checked; label.ContentAlignment = (ContentAlignment)Enum.Parse(typeof(ContentAlignment), ContentAlignmentDropDownList.SelectedItem.Text); label.Location = new NPointL( new NLength(HorizontalMarginDropDownList.SelectedIndex * 10, NRelativeUnit.ParentPercentage), new NLength(VerticalMarginDropDownList.SelectedIndex * 10, NRelativeUnit.ParentPercentage)); try { label.TextStyle.FontStyle = new NFontStyle(FontDropDownList.SelectedItem.Text, FontSizeDropDownList.SelectedIndex + 8);; } catch { } BackplaneStyleDropDownList.Enabled = HasBackplaneCheckBox.Checked; if (HasBackplaneCheckBox.Checked) { label.TextStyle.BackplaneStyle.Shape = (BackplaneShape)BackplaneStyleDropDownList.SelectedIndex; } // no legend nChartControl1.Legends.Clear(); // setup the chart NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Fit; chart.Axis(StandardAxis.PrimaryX).Visible = false; chart.Axis(StandardAxis.PrimaryY).Visible = false; chart.Location = new NPointL( new NLength(15, NRelativeUnit.ParentPercentage), new NLength(20, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL( new NLength(70, NRelativeUnit.ParentPercentage), new NLength(60, NRelativeUnit.ParentPercentage)); NBarSeries series = (NBarSeries)chart.Series.Add(SeriesType.Bar); series.DataLabelStyle.Visible = false; series.Values.AddRange(new double[] { 16, 42, 56, 23, 47, 38 }); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(series); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { EnableInitialPositioningCheckBox.Checked = true; RemoveOverlappedLabelsCheckBox.Checked = false; EnableLabelAdjustmentCheckBox.Checked = true; EnableDataPointSafeguardCheckBox.Checked = true; WebExamplesUtilities.FillComboWithValues(SafeguardSizeDropDownList, 0, 20, 1); SafeguardSizeDropDownList.SelectedIndex = 12; HiddenField1.Value = Random.Next().ToString(); } nChartControl1.Settings.JitterMode = JitterMode.Enabled; nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("XY Point Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); // configure the chart NChart chart = nChartControl1.Charts[0]; // configure X axis NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); scaleX.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; scaleX.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // configure Y axis NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator(); scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; scaleY.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back }; chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = scaleY; // add interlaced stripe for Y axis 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); // point series 1 NPointSeries series1 = (NPointSeries)chart.Series.Add(SeriesType.Point); series1.Name = "Point 1"; series1.PointShape = PointShape.Ellipse; series1.Size = new NLength(1.7f, NRelativeUnit.ParentPercentage); series1.UseXValues = true; series1.InflateMargins = true; series1.FillStyle = new NColorFillStyle(DarkOrange); series1.DataLabelStyle.Visible = true; series1.DataLabelStyle.VertAlign = VertAlign.Center; series1.DataLabelStyle.ArrowLength = new NLength(10); series1.DataLabelStyle.ArrowStrokeStyle.Color = DarkOrange; series1.DataLabelStyle.TextStyle.BackplaneStyle.StandardFrameStyle.InnerBorderColor = DarkOrange; series1.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(8); // point series 2 NPointSeries series2 = (NPointSeries)chart.Series.Add(SeriesType.Point); series2.Name = "Point 2"; series2.PointShape = PointShape.Ellipse; series2.Size = new NLength(1.7f, NRelativeUnit.ParentPercentage); series2.UseXValues = true; series2.InflateMargins = true; series2.FillStyle = new NColorFillStyle(Green); series2.DataLabelStyle.Visible = true; series2.DataLabelStyle.VertAlign = VertAlign.Center; series2.DataLabelStyle.ArrowLength = new NLength(10); series2.DataLabelStyle.ArrowStrokeStyle.Color = Green; series2.DataLabelStyle.TextStyle.BackplaneStyle.StandardFrameStyle.InnerBorderColor = Green; series2.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(8); // label layout settings chart.LabelLayout.EnableInitialPositioning = EnableInitialPositioningCheckBox.Checked; chart.LabelLayout.RemoveOverlappedLabels = RemoveOverlappedLabelsCheckBox.Checked; chart.LabelLayout.EnableLabelAdjustment = EnableLabelAdjustmentCheckBox.Checked; series1.LabelLayout.OutOfBoundsLocationMode = OutOfBoundsLocationMode.PushWithinBounds; series1.LabelLayout.InvertLocationsIfIgnored = true; series2.LabelLayout.OutOfBoundsLocationMode = OutOfBoundsLocationMode.PushWithinBounds; series2.LabelLayout.InvertLocationsIfIgnored = true; // enable / disable data point safeguard size for both series series1.LabelLayout.EnableDataPointSafeguard = EnableDataPointSafeguardCheckBox.Checked; series2.LabelLayout.EnableDataPointSafeguard = EnableDataPointSafeguardCheckBox.Checked; // set data point safeguard size for both series float sizeValue = (float)SafeguardSizeDropDownList.SelectedIndex; NSizeL size = new NSizeL(new NLength(sizeValue, NGraphicsUnit.Point), new NLength(sizeValue, NGraphicsUnit.Point)); series1.LabelLayout.DataPointSafeguardSize = size; series2.LabelLayout.DataPointSafeguardSize = size; // fill with random data GenerateData(chart); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { StandardBorderDropDownList.Items.Add("None"); StandardBorderDropDownList.Items.Add("SingleFixed"); StandardBorderDropDownList.Items.Add("Sunken"); StandardBorderDropDownList.Items.Add("Raised"); StandardBorderDropDownList.Items.Add("SunkenRaised"); StandardBorderDropDownList.Items.Add("RaisedSunken"); WebExamplesUtilities.FillComboWithColorNames(BorderColorDropDownList, KnownColor.White); WebExamplesUtilities.FillComboWithValues(BevelWidthDropDownList, 1, 10, 1); WebExamplesUtilities.FillComboWithValues(BorderWidthDownList, 1, 10, 1); StandardBorderDropDownList.SelectedIndex = 2; } nChartControl1.Settings.JitterMode = JitterMode.Enabled; // set an image frame NStandardFrameStyle standardFrameStyle = new NStandardFrameStyle(); standardFrameStyle.SetPredefinedFrameStyle((PredefinedStandardFrame)(StandardBorderDropDownList.SelectedIndex)); standardFrameStyle.InnerBevelWidth = new NLength(BevelWidthDropDownList.SelectedIndex + 1, NGraphicsUnit.Pixel); standardFrameStyle.OuterBevelWidth = new NLength(BevelWidthDropDownList.SelectedIndex + 1, NGraphicsUnit.Pixel); standardFrameStyle.OuterBorderColor = WebExamplesUtilities.ColorFromDropDownList(BorderColorDropDownList); standardFrameStyle.OuterBorderWidth = new NLength(BorderWidthDownList.SelectedIndex + 1, NGraphicsUnit.Pixel); nChartControl1.BackgroundStyle.FrameStyle = standardFrameStyle; nChartControl1.BackgroundStyle.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.LightSteelBlue, Color.White); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Standard Border"); 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.Enable3D = true; chart.Depth = 50; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); NStandardScaleConfigurator scaleX = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; scaleX.MajorTickMode = MajorTickMode.AutoMaxCount; NStandardScaleConfigurator scaleZ = (NStandardScaleConfigurator)chart.Axis(StandardAxis.Depth).ScaleConfigurator; scaleZ.MajorTickMode = MajorTickMode.AutoMaxCount; // add the first bar NBarSeries bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar1.MultiBarMode = MultiBarMode.Series; bar1.Name = "Bar1"; bar1.DataLabelStyle.Visible = false; bar1.BorderStyle.Color = Color.Crimson; bar1.FillStyle = new NColorFillStyle(Color.Crimson); bar1.Values.FillRandomRange(Random, 5, 10, 40); // add the second bar NBarSeries bar2 = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar2.MultiBarMode = MultiBarMode.Series; bar2.Name = "Bar2"; bar2.DataLabelStyle.Visible = false; bar2.BorderStyle.Color = Color.PaleGreen; bar2.FillStyle = new NColorFillStyle(Color.PaleGreen); bar2.Values.FillRandomRange(Random, 5, 30, 60); // add the third bar NBarSeries bar3 = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar3.MultiBarMode = MultiBarMode.Series; bar3.Name = "Bar3"; bar3.DataLabelStyle.Visible = false; bar3.BorderStyle.Color = Color.CornflowerBlue; bar3.FillStyle = new NColorFillStyle(Color.CornflowerBlue); bar3.Values.FillRandomRange(Random, 5, 50, 80); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, nChartControl1.Legends[0]); }
protected void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { WebExamplesUtilities.FillComboWithPercents(LengthBottomAxisDropDownList, 10); WebExamplesUtilities.FillComboWithPercents(LengthLeftAxisDropDownList, 10); } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel header = nChartControl1.Labels.AddHeader("Axis Model Crossing <br/> <font size = '9pt'>Demonstrates how to use the model cross anchor</font>"); header.TextStyle.TextFormat = TextFormat.XML; header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Left; header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL( new NLength(7, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); m_Chart = nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; m_Chart.Location = new NPointL( new NLength(7, NRelativeUnit.ParentPercentage), new NLength(18, NRelativeUnit.ParentPercentage)); m_Chart.Size = new NSizeL( new NLength(86, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage)); // configure scales NLinearScaleConfigurator yScaleConfigurator = (NLinearScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; NScaleStripStyle yStripStyle = new NScaleStripStyle(new NColorFillStyle(Color.FromArgb(40, Color.LightGray)), null, true, 0, 0, 1, 1); yStripStyle.SetShowAtWall(ChartWallType.Back, true); yStripStyle.Interlaced = true; yScaleConfigurator.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); yScaleConfigurator.StripStyles.Add(yStripStyle); NLinearScaleConfigurator xScaleConfigurator = new NLinearScaleConfigurator(); NScaleStripStyle xStripStyle = new NScaleStripStyle(new NColorFillStyle(Color.FromArgb(40, Color.LightGray)), null, true, 0, 0, 1, 1); xStripStyle.SetShowAtWall(ChartWallType.Back, true); xStripStyle.Interlaced = true; xScaleConfigurator.StripStyles.Add(xStripStyle); xScaleConfigurator.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = xScaleConfigurator; // cross X and Y axes m_Chart.Axis(StandardAxis.PrimaryX).Anchor = new NCrossAxisAnchor(AxisOrientation.Horizontal, new NValueAxisCrossing(m_Chart.Axis(StandardAxis.PrimaryY), 0)); m_Chart.Axis(StandardAxis.PrimaryX).Anchor.RulerOrientation = RulerOrientation.Right; m_Chart.Axis(StandardAxis.PrimaryY).Anchor = new NCrossAxisAnchor(AxisOrientation.Vertical, new NValueAxisCrossing(m_Chart.Axis(StandardAxis.PrimaryX), 0)); m_Chart.Axis(StandardAxis.Depth).Visible = false; m_Chart.Wall(ChartWallType.Floor).Visible = false; m_Chart.Wall(ChartWallType.Left).Visible = false; // setup bubble series NBubbleSeries bubble = (NBubbleSeries)m_Chart.Series.Add(SeriesType.Bubble); bubble.Name = "Bubble Series"; bubble.InflateMargins = true; bubble.DataLabelStyle.Visible = false; bubble.UseXValues = true; bubble.ShadowStyle.Type = ShadowType.GaussianBlur; bubble.BubbleShape = PointShape.Sphere; bubble.Legend.Mode = SeriesLegendMode.None; // fill with random data bubble.Values.FillRandomRange(Random, 10, -20, 20); bubble.XValues.FillRandomRange(Random, 10, -20, 20); bubble.Sizes.FillRandomRange(Random, 10, 1, 6); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); UpdateCrossings(); }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel header = nChartControl1.Labels.AddHeader("Train Sales"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); nChartControl1.Legends[0].Mode = LegendMode.Disabled; NChart chart = nChartControl1.Charts[0]; // perform manual stretch float fAspect = ((float)nChartControl1.Width.Value / (float)nChartControl1.Height.Value); // perform manual stretch if (fAspect > 1) { chart.Width = 86 * fAspect; chart.Height = 70; } else { chart.Width = 86; chart.Height = 70 * fAspect; } chart.Location = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(18, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(86, NRelativeUnit.ParentPercentage), new NLength(70, NRelativeUnit.ParentPercentage)); chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal); chart.Wall(ChartWallType.Floor).Visible = false; chart.Wall(ChartWallType.Left).Visible = false; chart.Axis(StandardAxis.Depth).Visible = false; chart.Axis(StandardAxis.Depth).Visible = false; NOrdinalScaleConfigurator ordinalScaleConfigurator = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; ordinalScaleConfigurator.InnerMajorTickStyle.LineStyle.Width = new NLength(0, NGraphicsUnit.Pixel); ordinalScaleConfigurator.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; ordinalScaleConfigurator.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, false); ordinalScaleConfigurator.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); NDockAxisAnchor anchor = new NDockAxisAnchor(AxisDockZone.FrontBottom, false, 5, 95); chart.Axis(StandardAxis.PrimaryX).Anchor = anchor; NLinearScaleConfigurator linearSclaeConfigurator = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; linearSclaeConfigurator.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line); NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.Name = "Bar Series"; bar.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); bar.FillStyle = new NColorFillStyle(Color.MediumPurple); bar.DataLabelStyle.Visible = false; bar.InflateMargins = true; // fill with random data Random random = new Random(); bar.Values.FillRandom(random, 10); // generate a data series cumulative sum of the bar values NFunctionCalculator fc = new NFunctionCalculator(); fc.Expression = "CUMSUM(Value)"; fc.Arguments.Add(bar.Values); // display this data series as line line.Name = "Cumulative"; line.Values = fc.Calculate(); line.MarkerStyle.Visible = true; line.MarkerStyle.PointShape = PointShape.Cylinder; line.DataLabelStyle.Visible = false; line.DataLabelStyle.ArrowStrokeStyle.Width = new NLength(0, NGraphicsUnit.Pixel); bar.BarShape = BarShape.Cylinder; for (int i = 0; i < bar.Values.Count; i++) { bar.FillStyles[i] = new NColorFillStyle(WebExamplesUtilities.RandomColor()); } bar.Legend.Mode = SeriesLegendMode.DataPoints; line.Legend.Mode = SeriesLegendMode.None; NImageResponse imageResponse = new NImageResponse(); imageResponse.StreamImageToBrowser = true; nChartControl1.ServerSettings.BrowserResponseSettings.DefaultResponse = imageResponse; nChartControl1.RenderControl(null); }
protected void Page_Load(object sender, System.EventArgs e) { nChartControl1.Settings.JitterMode = JitterMode.Enabled; nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("3D Funnel Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.ContentAlignment = ContentAlignment.BottomRight; title.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); NLegend legend = nChartControl1.Legends[0]; legend.SetPredefinedLegendStyle(PredefinedLegendStyle.BottomRight); NFunnelChart chart = new NFunnelChart(); chart.BoundsMode = BoundsMode.Fit; chart.Location = new NPointL(new NLength(5, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(85, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); chart.Enable3D = true; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights); chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective); chart.Projection.Elevation = 18; nChartControl1.Charts.Clear(); nChartControl1.Charts.Add(chart); NFunnelSeries funnel = (NFunnelSeries)chart.Series.Add(SeriesType.Funnel); funnel.BorderStyle.Color = Color.LemonChiffon; funnel.Legend.DisplayOnLegend = legend; funnel.Legend.Mode = SeriesLegendMode.DataPoints; funnel.DataLabelStyle.Format = "<percent>"; funnel.Values.Add(20.0); funnel.Values.Add(10.0); funnel.Values.Add(15.0); funnel.Values.Add(7.0); funnel.Values.Add(28.0); funnel.Labels.Add("Awareness"); funnel.Labels.Add("First Hear"); funnel.Labels.Add("Further Learn"); funnel.Labels.Add("Liking"); funnel.Labels.Add("Decision"); NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Bright); for (int i = 0; i < funnel.Values.Count; i++) { funnel.FillStyles[i] = palette.SeriesColors[i % palette.SeriesColors.Count]; } if (!IsPostBack) { // init form controls WebExamplesUtilities.FillComboWithEnumValues(FunnelLabelModeDropDownList, typeof(FunnelLabelMode)); FunnelLabelModeDropDownList.SelectedIndex = 0; WebExamplesUtilities.FillComboWithValues(FunnelRadiusDropDownList, 0, 100, 10); FunnelRadiusDropDownList.SelectedIndex = (int)(chart.Width / 10); WebExamplesUtilities.FillComboWithValues(FunnelPointGapDropDownList, 0, 100, 10); FunnelPointGapDropDownList.SelectedIndex = (int)(funnel.FunnelPointGap / 10); WebExamplesUtilities.FillComboWithValues(NeckWidthDropDownList, 0, 100, 10); NeckWidthDropDownList.SelectedIndex = (int)(funnel.NeckWidthPercent / 10); WebExamplesUtilities.FillComboWithValues(NeckHeightDropDownList, 0, 100, 10); NeckHeightDropDownList.SelectedIndex = (int)(funnel.NeckHeightPercent / 10); WebExamplesUtilities.FillComboWithValues(LabelArrowLengthDropDownList, 0, 10, 1); LabelArrowLengthDropDownList.SelectedIndex = (int)(funnel.DataLabelStyle.ArrowLength.Value); } SetLabelMode(funnel); // set funnel arrow length funnel.DataLabelStyle.ArrowLength = new NLength((float)(LabelArrowLengthDropDownList.SelectedIndex), NRelativeUnit.ParentPercentage); // set funnel radius nChartControl1.Charts[0].Width = FunnelRadiusDropDownList.SelectedIndex * 10.0f; // set funnel gap funnel.FunnelPointGap = FunnelPointGapDropDownList.SelectedIndex; // set neck width funnel.NeckWidthPercent = NeckWidthDropDownList.SelectedIndex * 10.0f; // set neck height funnel.NeckHeightPercent = NeckHeightDropDownList.SelectedIndex * 10.0f; }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Axis Ruler Caps<br/> <font size = '9pt'>Demonstrates how to change the caps of the axis ruler</font>"); header.DockMode = PanelDockMode.Top; header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.TextStyle.TextFormat = TextFormat.XML; header.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Left; header.FitAlignment = ContentAlignment.MiddleLeft; header.Margins = new NMarginsL(5, 0, 0, 5); nChartControl1.Panels.Add(header); NCartesianChart chart = new NCartesianChart(); chart.DockMode = PanelDockMode.Fill; chart.BoundsMode = BoundsMode.Stretch; chart.Margins = new NMarginsL(5, 10, 10, 5); nChartControl1.Panels.Add(chart); Random random = new Random(); // feed some random data NPointSeries point = new NPointSeries(); point.DataLabelStyle.Visible = false; point.UseXValues = true; point.Size = new NLength(5); point.BorderStyle.Width = new NLength(0); // fill in some random data for (int j = 0; j < 30; j++) { point.Values.Add(5 + random.Next(90)); point.XValues.Add(5 + random.Next(90)); } chart.Series.Add(point); // configure scales NLinearScaleConfigurator xScale = new NLinearScaleConfigurator(); xScale.RoundToTickMax = true; xScale.RoundToTickMin = true; xScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); xScale.ScaleBreaks.Add(new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Orange)), null, new NLength(10)), new NRange1DD(29, 41))); // add an interlaced strip to the X axis NScaleStripStyle xInterlacedStrip = new NScaleStripStyle(); xInterlacedStrip.SetShowAtWall(ChartWallType.Back, true); xInterlacedStrip.Interlaced = true; xInterlacedStrip.FillStyle = new NColorFillStyle(Color.FromArgb(40, Color.LightGray)); xScale.StripStyles.Add(xInterlacedStrip); NCartesianAxis xAxis = (NCartesianAxis)chart.Axis(StandardAxis.PrimaryX); xAxis.ScaleConfigurator = xScale; xAxis.View = new NRangeAxisView(new NRange1DD(0, 100)); NDockAxisAnchor xAxisAnchor = new NDockAxisAnchor(AxisDockZone.FrontBottom); xAxisAnchor.BeforeSpace = new NLength(10); xAxis.Anchor = xAxisAnchor; NLinearScaleConfigurator yScale = new NLinearScaleConfigurator(); yScale.RoundToTickMax = true; yScale.RoundToTickMin = true; yScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); yScale.ScaleBreaks.Add(new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Orange)), null, new NLength(10)), new NRange1DD(29, 41))); // add an interlaced strip to the Y axis NScaleStripStyle yInterlacedStrip = new NScaleStripStyle(); yInterlacedStrip.SetShowAtWall(ChartWallType.Back, true); yInterlacedStrip.Interlaced = true; yInterlacedStrip.FillStyle = new NColorFillStyle(Color.FromArgb(40, Color.LightGray)); yScale.StripStyles.Add(yInterlacedStrip); NCartesianAxis yAxis = (NCartesianAxis)chart.Axis(StandardAxis.PrimaryY); yAxis.ScaleConfigurator = yScale; yAxis.View = new NRangeAxisView(new NRange1DD(0, 100)); NDockAxisAnchor yAxisAnchor = new NDockAxisAnchor(AxisDockZone.FrontLeft); yAxisAnchor.BeforeSpace = new NLength(10); yAxis.Anchor = yAxisAnchor; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // update form controls if (!IsPostBack) { PaintOnScaleBreaksCheckBox.Checked = false; WebExamplesUtilities.FillComboWithEnumValues(BeginCapStyleDropDownList, typeof(CapStyle)); BeginCapStyleDropDownList.SelectedIndex = (int)CapStyle.Ellipse; WebExamplesUtilities.FillComboWithEnumValues(ScaleBreakCapStyleDropDownList, typeof(CapStyle)); ScaleBreakCapStyleDropDownList.SelectedIndex = (int)CapStyle.LeftCrossLine; WebExamplesUtilities.FillComboWithEnumValues(EndCapStyleDropDownList, typeof(CapStyle)); EndCapStyleDropDownList.SelectedIndex = (int)CapStyle.Arrow; } UpdateRulerStyleForAxis(xAxis); UpdateRulerStyleForAxis(yAxis); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { WebExamplesUtilities.FillComboWithEnumNames(ContourDisplayModeDropDownList, typeof(ContourDisplayMode)); WebExamplesUtilities.FillComboWithEnumNames(ContourColorModeDropDownList, typeof(ContourColorMode)); ShowFillCheckBox.Checked = true; SmoothPaletteCheckBox.Checked = true; ContourDisplayModeDropDownList.SelectedIndex = (int)ContourDisplayMode.Contour; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Panels.Clear(); // set a chart title NLabel title = new NLabel("Heat Map - Contour"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); title.DockMode = PanelDockMode.Top; title.Margins = new NMarginsL(0, 5, 0, 0); nChartControl1.Panels.Add(title); NLegend legend = new NLegend(); legend.DockMode = PanelDockMode.Right; legend.Margins = new NMarginsL(0, 5, 5, 0); legend.FitAlignment = ContentAlignment.TopCenter; nChartControl1.Panels.Add(legend); NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); chart.DisplayOnLegend = legend; chart.DockMode = PanelDockMode.Fill; chart.BoundsMode = BoundsMode.Stretch; chart.Margins = new NMarginsL(5); // create the heat map NHeatMapSeries heatMap = new NHeatMapSeries(); chart.Series.Add(heatMap); heatMap.Palette.Add(0.0, Color.Purple); heatMap.Palette.Add(1.5, Color.MediumSlateBlue); heatMap.Palette.Add(3.0, Color.CornflowerBlue); heatMap.Palette.Add(4.5, Color.LimeGreen); heatMap.Palette.Add(6.0, Color.LightGreen); heatMap.Palette.Add(7.5, Color.Yellow); heatMap.Palette.Add(9.0, Color.Orange); heatMap.Palette.Add(10.5, Color.Red); heatMap.XValuesMode = HeatMapValuesMode.OriginAndStep; heatMap.YValuesMode = HeatMapValuesMode.OriginAndStep; heatMap.ContourDisplayMode = ContourDisplayMode.Contour; heatMap.Legend.Mode = SeriesLegendMode.SeriesLogic; heatMap.Legend.Format = "<zone_value>"; GenerateData(heatMap); // update chart control from form controls heatMap.ContourDisplayMode = (ContourDisplayMode)ContourDisplayModeDropDownList.SelectedIndex; heatMap.ContourColorMode = (ContourColorMode)ContourColorModeDropDownList.SelectedIndex; heatMap.ShowFill = ShowFillCheckBox.Checked; heatMap.Palette.SmoothPalette = SmoothPaletteCheckBox.Checked; if (heatMap.Palette.SmoothPalette) { heatMap.Legend.Format = "<zone_value>"; } else { heatMap.Legend.Format = "<zone_begin> - <zone_end>"; } }
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]); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { EnableInitialPositioningCheckBox.Checked = true; RemoveOverlappedLabelsCheckBox.Checked = false; EnableLabelAdjustmentCheckBox.Checked = true; EnableDataPointSafeguardCheckBox.Checked = true; WebExamplesUtilities.FillComboWithValues(SafeguardSizeDropDownList, 0, 20, 1); SafeguardSizeDropDownList.SelectedIndex = 12; HiddenField1.Value = Random.Next().ToString(); } nChartControl1.Settings.JitterMode = JitterMode.Enabled; nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("XYZ Point Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); // configure the chart NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.SoftCameraLight); chart.Depth = 55.0f; chart.Width = 55.0f; chart.Height = 55.0f; // set automatic walls foreach (NChartWall wall in chart.Walls) { wall.VisibilityMode = WallVisibilityMode.Auto; } // set auto axis anchors chart.Axis(StandardAxis.PrimaryX).Anchor = new NBestVisibilityAxisAnchor(AxisOrientation.Horizontal); chart.Axis(StandardAxis.PrimaryY).Anchor = new NBestVisibilityAxisAnchor(AxisOrientation.Vertical); chart.Axis(StandardAxis.Depth).Anchor = new NBestVisibilityAxisAnchor(AxisOrientation.Depth); // configure X axis NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); scaleX.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; scaleX.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Floor, ChartWallType.Top, ChartWallType.Front }; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; // configure Y axis NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator(); scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; scaleY.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left, ChartWallType.Right, ChartWallType.Front }; chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = scaleY; // add interlaced stripe for Y axis 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, ChartWallType.Front, ChartWallType.Right }; scaleY.StripStyles.Add(stripStyle); // configure Z axis NLinearScaleConfigurator scaleZ = new NLinearScaleConfigurator(); scaleZ.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; scaleZ.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Floor, ChartWallType.Top, ChartWallType.Left, ChartWallType.Right }; chart.Axis(StandardAxis.Depth).ScaleConfigurator = scaleZ; // point series 1 NPointSeries series1 = (NPointSeries)chart.Series.Add(SeriesType.Point); series1.Name = "Point 1"; series1.PointShape = PointShape.Bar; series1.Size = new NLength(2.4f, NRelativeUnit.ParentPercentage); series1.UseXValues = true; series1.UseZValues = true; series1.InflateMargins = true; series1.FillStyle = new NColorFillStyle(DarkOrange); series1.DataLabelStyle.Visible = true; series1.DataLabelStyle.VertAlign = VertAlign.Center; series1.DataLabelStyle.ArrowLength = new NLength(12); series1.DataLabelStyle.TextStyle.BackplaneStyle.StandardFrameStyle.InnerBorderColor = DarkOrange; series1.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(8); // point series 2 NPointSeries series2 = (NPointSeries)chart.Series.Add(SeriesType.Point); series2.Name = "Point 2"; series2.PointShape = PointShape.Bar; series2.Size = new NLength(2.4f, NRelativeUnit.ParentPercentage); series2.UseXValues = true; series2.UseZValues = true; series2.InflateMargins = true; series2.FillStyle = new NColorFillStyle(Green); series2.DataLabelStyle.Visible = true; series2.DataLabelStyle.VertAlign = VertAlign.Center; series2.DataLabelStyle.ArrowLength = new NLength(12); series2.DataLabelStyle.TextStyle.BackplaneStyle.StandardFrameStyle.InnerBorderColor = Green; series2.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(8); // fill with random data GenerateData(chart); // label layout settings chart.LabelLayout.EnableInitialPositioning = EnableInitialPositioningCheckBox.Checked; chart.LabelLayout.RemoveOverlappedLabels = RemoveOverlappedLabelsCheckBox.Checked; chart.LabelLayout.EnableLabelAdjustment = EnableLabelAdjustmentCheckBox.Checked; // enable / disable data point safeguard size for both series series1.LabelLayout.EnableDataPointSafeguard = EnableDataPointSafeguardCheckBox.Checked; series2.LabelLayout.EnableDataPointSafeguard = EnableDataPointSafeguardCheckBox.Checked; // set data point safeguard size for both series float sizeValue = (float)SafeguardSizeDropDownList.SelectedIndex; NSizeL size = new NSizeL(new NLength(sizeValue, NGraphicsUnit.Point), new NLength(sizeValue, NGraphicsUnit.Point)); series1.LabelLayout.DataPointSafeguardSize = size; series2.LabelLayout.DataPointSafeguardSize = size; // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { WebExamplesUtilities.FillComboWithColorNames(UpColorDropDownList, KnownColor.Black); WebExamplesUtilities.FillComboWithColorNames(DownColorDropDownList, KnownColor.Black); WebExamplesUtilities.FillComboWithValues(UpStrokeDropDownList, 1, 3, 1); UpStrokeDropDownList.SelectedIndex = 1; WebExamplesUtilities.FillComboWithValues(DownStrokeDropDownList, 1, 3, 1); reversalAmountDropdownlist.Items.AddRange(new ListItem[] { new ListItem("0.5"), new ListItem("1"), new ListItem("2"), new ListItem("1%"), new ListItem("2%"), new ListItem("5%") }); } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // no legend nChartControl1.Legends.Clear(); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Kagi Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; // setup X axis NPriceScaleConfigurator priceConfigurator = new NPriceScaleConfigurator(); priceConfigurator.InnerMajorTickStyle.LineStyle.Width = new NLength(0); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = priceConfigurator; // setup Y axis NLinearScaleConfigurator linearScale = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.StripStyles.Add(stripStyle); //Setup Kagi series NKagiSeries kagi = (NKagiSeries)chart.Series.Add(SeriesType.Kagi); kagi.UpStrokeStyle.Color = WebExamplesUtilities.ColorFromDropDownList(UpColorDropDownList); kagi.DownStrokeStyle.Color = WebExamplesUtilities.ColorFromDropDownList(DownColorDropDownList); kagi.UpStrokeStyle.Width = new NLength(Convert.ToInt32(UpStrokeDropDownList.SelectedValue)); kagi.DownStrokeStyle.Width = new NLength(Convert.ToInt32(DownStrokeDropDownList.SelectedValue)); kagi.UseXValues = true; switch (reversalAmountDropdownlist.SelectedIndex) { case 0: kagi.ReversalAmount = 0.5; kagi.ReversalAmountInPercents = false; break; case 1: kagi.ReversalAmount = 1; kagi.ReversalAmountInPercents = false; break; case 2: kagi.ReversalAmount = 2; kagi.ReversalAmountInPercents = false; break; case 3: kagi.ReversalAmount = 1; kagi.ReversalAmountInPercents = true; break; case 4: kagi.ReversalAmount = 2; kagi.ReversalAmountInPercents = true; break; case 5: kagi.ReversalAmount = 5; kagi.ReversalAmountInPercents = true; break; } GenerateData(kagi); // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DefaultFormatDropDown.Items.Add("[value] [label]"); DefaultFormatDropDown.Items.Add("[index] [cumulative]"); DefaultFormatDropDown.Items.Add("[percent] [total]"); DefaultFormatDropDown.SelectedIndex = 0; DefaultVerticalAlignDropDown.Items.Add("Center"); DefaultVerticalAlignDropDown.Items.Add("Top"); DefaultVerticalAlignDropDown.Items.Add("Bottom"); DefaultVerticalAlignDropDown.SelectedIndex = 1; DefaultLabelVisibleCheck.Checked = true; DefaultBackplaneVisibleCheck.Checked = true; Label3FormatDropDown.Items.Add("Individual"); Label3FormatDropDown.Items.Add("[value] [label]"); Label3FormatDropDown.Items.Add("[index] [cumulative]"); Label3FormatDropDown.Items.Add("[percent] [total]"); Label3FormatDropDown.SelectedIndex = 0; Label3VerticalAlignDropDown.Items.Add("Center"); Label3VerticalAlignDropDown.Items.Add("Top"); Label3VerticalAlignDropDown.Items.Add("Bottom"); Label3VerticalAlignDropDown.SelectedIndex = 1; Label3VisibleCheck.Checked = true; Backplane3VisibleCheck.Checked = true; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Legends[0].Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Data Labels"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // no legend nChartControl1.Legends.Clear(); // setup chart NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; chart.Axis(StandardAxis.Depth).Visible = false; NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.AddDataPoint(new NDataPoint(10, "Item A")); bar.AddDataPoint(new NDataPoint(20, "Item B")); bar.AddDataPoint(new NDataPoint(30, "Item C")); bar.AddDataPoint(new NDataPoint(25, "Item D")); bar.AddDataPoint(new NDataPoint(29, "Item E")); // add interlaced stripe NLinearScaleConfigurator linearScaleConfigurator = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); linearScaleConfigurator.StripStyles.Add(stripStyle); // apply style sheet NFillStyleSheetConfigurator fillStyleSheet = new NFillStyleSheetConfigurator(); fillStyleSheet.SeriesFillTemplate = new NGradientFillStyleTemplate(GradientStyle.Horizontal, GradientVariant.Variant1); fillStyleSheet.MultiColorSeries = true; fillStyleSheet.Palette.SetPredefinedPalette(ChartPredefinedPalette.Nature); NStrokeStyleSheetConfigurator strokeStyleSheet = new NStrokeStyleSheetConfigurator(); strokeStyleSheet.MultiColorSeries = true; strokeStyleSheet.ApplyToDataLabels = false; strokeStyleSheet.Palette.SetPredefinedPalette(ChartPredefinedPalette.Nature); NStyleSheet styleSheet = new NStyleSheet(); fillStyleSheet.ConfigureSheet(styleSheet); strokeStyleSheet.ConfigureSheet(styleSheet); styleSheet.Apply(bar); // add a different data label for data point 3 NDataLabelStyle label = new NDataLabelStyle(); label.TextStyle.FontStyle.Style = FontStyle.Bold; label.TextStyle.FillStyle = new NColorFillStyle(Color.Crimson); label.TextStyle.BackplaneStyle.Inflate = new NSizeL(3, 3); label.TextStyle.BackplaneStyle.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant2, Color.White, Color.Lavender); bar.DataLabelStyles[3] = label; label.Format = WebExamplesUtilities.GetXmlFormatString(Label3FormatDropDown.SelectedItem.Text); label.VertAlign = (VertAlign)Label3VerticalAlignDropDown.SelectedIndex; label.Visible = Label3VisibleCheck.Checked; label.TextStyle.BackplaneStyle.Visible = Backplane3VisibleCheck.Checked; bar.DataLabelStyle.Format = WebExamplesUtilities.GetXmlFormatString(DefaultFormatDropDown.SelectedItem.Text); bar.DataLabelStyle.VertAlign = (VertAlign)DefaultVerticalAlignDropDown.SelectedIndex; bar.DataLabelStyle.Visible = DefaultLabelVisibleCheck.Checked; bar.DataLabelStyle.TextStyle.BackplaneStyle.Visible = DefaultBackplaneVisibleCheck.Checked; // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { WebExamplesUtilities.FillComboWithEnumValues(YLabelGenerationModeDropDownList, typeof(LabelGenerationMode)); WebExamplesUtilities.FillComboWithEnumValues(XLabelGenerationModeDropDownList, typeof(LabelGenerationMode)); WebExamplesUtilities.FillComboWithValues(XTicksPerLabelDropDownList, 1, 10, 1); WebExamplesUtilities.FillComboWithValues(YTicksPerLabelDropDownList, 1, 10, 1); } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel header = nChartControl1.Labels.AddHeader("Axis Labels"); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.ContentAlignment = ContentAlignment.BottomRight; header.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // remove all legends nChartControl1.Legends.Clear(); // setup chart m_Chart = nChartControl1.Charts[0]; m_Chart.BoundsMode = BoundsMode.Stretch; m_Chart.Location = new NPointL( new NLength(4, NRelativeUnit.ParentPercentage), new NLength(13, NRelativeUnit.ParentPercentage)); m_Chart.Size = new NSizeL( new NLength(90, NRelativeUnit.ParentPercentage), new NLength(82, NRelativeUnit.ParentPercentage)); NStandardScaleConfigurator scaleConfiguratorY = (NStandardScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; scaleConfiguratorY.MajorTickMode = MajorTickMode.AutoMaxCount; scaleConfiguratorY.MaxTickCount = 50; // add interlaced stripe NScaleStripStyle stripStyle = new NScaleStripStyle(); stripStyle.FillStyle = new NColorFillStyle(Color.Beige); stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); stripStyle.Interlaced = true; scaleConfiguratorY.StripStyles.Add(stripStyle); NStandardScaleConfigurator scaleConfiguratorX = (NStandardScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator; scaleConfiguratorX.MajorTickMode = MajorTickMode.AutoMaxCount; scaleConfiguratorX.AutoLabels = false; scaleConfiguratorX.Labels.Add("France"); scaleConfiguratorX.Labels.Add("Italy"); scaleConfiguratorX.Labels.Add("Germany"); scaleConfiguratorX.Labels.Add("Norway"); scaleConfiguratorX.Labels.Add("Spain"); scaleConfiguratorX.Labels.Add("Belgium"); scaleConfiguratorX.Labels.Add("Greece"); scaleConfiguratorX.Labels.Add("Austria"); scaleConfiguratorX.Labels.Add("Sweden"); scaleConfiguratorX.Labels.Add("Finland"); scaleConfiguratorX.Labels.Add("Poland"); scaleConfiguratorX.Labels.Add("Denmark"); NBarSeries series1 = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); series1.Name = "Product A"; series1.DataLabelStyle.Visible = false; GenerateData(series1.Values, 12); NBarSeries series2 = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar); series2.MultiBarMode = MultiBarMode.Clustered; series2.Name = "Product B"; series2.DataLabelStyle.Visible = false; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); GenerateData(series2.Values, 12); UpdateScale(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // fill the combo LineStyleDropDownList.Items.Add("Line"); LineStyleDropDownList.Items.Add("Tape"); LineStyleDropDownList.Items.Add("Tube"); LineStyleDropDownList.Items.Add("Ellipsoid"); LineStyleDropDownList.SelectedIndex = 0; WebExamplesUtilities.FillComboWithEnumValues(MarkerShapeDropDownList, typeof(PointShape)); MarkerShapeDropDownList.SelectedIndex = 1; WebExamplesUtilities.FillComboWithPercents(LineDepthDropDownList, 10); LineDepthDropDownList.SelectedIndex = 4; WebExamplesUtilities.FillComboWithValues(LineWidthDropDownList, 0, 5, 1); LineWidthDropDownList.SelectedIndex = 1; WebExamplesUtilities.FillComboWithColorNames(LineColorDropDownList, KnownColor.DarkSalmon); WebExamplesUtilities.FillComboWithColorNames(LineFillColorDropDownList, KnownColor.LightSalmon); WebExamplesUtilities.FillComboWithValues(MarkerSizeDropDownList, 0, 10, 1); MarkerSizeDropDownList.SelectedIndex = 2; ShowMarkersCheckBox.Checked = true; LeftAxisRoundToTickCheckBox.Checked = true; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("3D Line Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; NChart chart = nChartControl1.Charts[0]; chart.Enable3D = true; chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective2); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); chart.Axis(StandardAxis.Depth).Visible = false; // setup Y axis NLinearScaleConfigurator scaleY = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; scaleY.RoundToTickMin = LeftAxisRoundToTickCheckBox.Checked; scaleY.RoundToTickMax = LeftAxisRoundToTickCheckBox.Checked; // add Y axis interlaced stripe NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1); stripStyle.Interlaced = true; stripStyle.SetShowAtWall(ChartWallType.Back, true); stripStyle.SetShowAtWall(ChartWallType.Left, true); scaleY.StripStyles.Add(stripStyle); // setup X axis NOrdinalScaleConfigurator scaleX = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; scaleX.MajorTickMode = MajorTickMode.AutoMaxCount; scaleX.DisplayDataPointsBetweenTicks = false; // setup the line series NLineSeries nLine = (NLineSeries)chart.Series.Add(SeriesType.Line); nLine.Values.FillRandom(Random, 10); nLine.DataLabelStyle.Visible = false; nLine.Legend.Mode = SeriesLegendMode.DataPoints; nLine.BorderStyle.Width = new NLength(LineWidthDropDownList.SelectedIndex, NGraphicsUnit.Pixel); nLine.DepthPercent = LineDepthDropDownList.SelectedIndex * 10; nLine.BorderStyle.Color = WebExamplesUtilities.ColorFromDropDownList(LineColorDropDownList); nLine.FillStyle = new NColorFillStyle(WebExamplesUtilities.ColorFromDropDownList(LineFillColorDropDownList)); nLine.InflateMargins = InflateMarginsCheckBox.Checked; nLine.MarkerStyle.Visible = ShowMarkersCheckBox.Checked; bool bSimpleLine = (LineStyleDropDownList.SelectedIndex == 0); switch (LineStyleDropDownList.SelectedIndex) { case 0: // simple line nLine.LineSegmentShape = LineSegmentShape.Line; break; case 1: // tape nLine.LineSegmentShape = LineSegmentShape.Tape; break; case 2: // tube nLine.LineSegmentShape = LineSegmentShape.Tube; break; case 3: // elipsoid nLine.LineSegmentShape = LineSegmentShape.Ellipsoid; break; } LineDepthDropDownList.Enabled = !bSimpleLine; LineFillColorDropDownList.Enabled = !bSimpleLine; MarkerShapeDropDownList.Enabled = ShowMarkersCheckBox.Checked; MarkerSizeDropDownList.Enabled = ShowMarkersCheckBox.Checked; if (nLine.MarkerStyle.Visible) { nLine.MarkerStyle.PointShape = (PointShape)MarkerShapeDropDownList.SelectedIndex; nLine.MarkerStyle.Height = new NLength((float)MarkerSizeDropDownList.SelectedIndex, NRelativeUnit.ParentPercentage); nLine.MarkerStyle.Width = new NLength((float)MarkerSizeDropDownList.SelectedIndex, NRelativeUnit.ParentPercentage); nLine.MarkerStyle.FillStyle = new NColorFillStyle(Red); nLine.MarkerStyle.BorderStyle.Color = WebExamplesUtilities.ColorFromDropDownList(LineColorDropDownList); } // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { WebExamplesUtilities.FillComboWithEnumNames(PointShapeDropDownList, typeof(PointShape)); DifferentColorsCheckBox.Checked = true; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Ternary Point Chart"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // setup chart NTernaryChart ternaryChart = new NTernaryChart(); nChartControl1.Panels.Add(ternaryChart); ConfigureAxis(ternaryChart.Axis(StandardAxis.TernaryA)); ConfigureAxis(ternaryChart.Axis(StandardAxis.TernaryB)); ConfigureAxis(ternaryChart.Axis(StandardAxis.TernaryC)); NTernaryPointSeries point = new NTernaryPointSeries(); ternaryChart.Series.Add(point); // setup point series point.Name = "Ternary Point Series"; point.Shape = (PointShape)PointShapeDropDownList.SelectedIndex; Random rand = new Random(); for (int i = 0; i < 20; i++) { // will be automatically normalized so that the sum of a, b, c value is 100 double aValue = rand.Next(100); double bValue = rand.Next(100); double cValue = rand.Next(100); point.AValues.Add(aValue); point.BValues.Add(bValue); point.CValues.Add(cValue); } // apply layout ApplyLayoutTemplate(0, nChartControl1, ternaryChart, title, null); if (DifferentColorsCheckBox.Checked) { // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(nChartControl1.Document); } else { // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); } }
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) { // fill the combo WebExamplesUtilities.FillComboWithValues(XValueDropDownList, 10, 90, 10); WebExamplesUtilities.FillComboWithValues(YValueDropDownList, 10, 90, 10); } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Intersect Line With X/Y Value"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; NChart chart = nChartControl1.Charts[0]; // 2D line chart chart.BoundsMode = BoundsMode.Stretch; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = GetScaleConfigurator(); chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = GetScaleConfigurator(); chart.Axis(StandardAxis.Depth).Visible = false; NAxisCollection axes = chart.Axes; // add point series NPointSeries point = (NPointSeries)chart.Series.Add(SeriesType.Point); point.UseXValues = true; point.FillStyle = new NColorFillStyle(Color.Red); point.DataLabelStyle.Visible = false; point.Size = new NLength(2); NLineSeries line = new NLineSeries(); chart.Series.Add(line); line.Name = "Point 1"; line.FillStyle = new NColorFillStyle(Color.Red); line.BorderStyle.Color = Color.Pink; line.DataLabelStyle.Visible = false; line.UseXValues = true; line.InflateMargins = true; // fill with data Random rand = new Random(); double radius = 0; double angle = 0; int dataPointCount = 1000; double rStep = 50.0 / dataPointCount; double aStep = 10.0; for (int i = 0; i < dataPointCount; i++) { double y = Math.Sin(angle * 0.0174533f) * radius; double x = Math.Cos(angle * 0.0174533f) * radius; line.XValues.Add(50.0 + x); line.Values.Add(50.0 + y); radius += rStep; angle += aStep; } point.XValues.Clear(); point.Values.Clear(); NAxisConstLine horizontalAxisCursor = new NAxisConstLine(); NAxisConstLine verticalAxisCursor = new NAxisConstLine(); chart.Axis(StandardAxis.PrimaryX).ConstLines.Add(horizontalAxisCursor); chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(verticalAxisCursor); double xValue = (XValueDropDownList.SelectedIndex + 1) * 10; double yValue = (YValueDropDownList.SelectedIndex + 1) * 10; horizontalAxisCursor.Value = xValue; List <double> intersections = line.IntersectWithXValue(xValue); for (int i = 0; i < intersections.Count; i++) { point.XValues.Add(xValue); point.Values.Add(intersections[i]); } verticalAxisCursor.Value = yValue; intersections = line.IntersectWithYValue(yValue); for (int i = 0; i < intersections.Count; i++) { point.XValues.Add(intersections[i]); point.Values.Add(yValue); } // apply layout ApplyLayoutTemplate(0, nChartControl1, chart, title, null); }