public override void Initialize() { base.Initialize(); // set a chart title NLabel title = new NLabel("Heat Map"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; // create the heat map (will be updated on timer tick) m_HeatMap = new NHeatMapSeries(); m_HeatMap.Data.SetGridSize(m_SizeX, m_SizeY); m_HeatMap.Data.SetValues(double.NaN); m_HeatMap.Legend.Mode = SeriesLegendMode.SeriesLogic; // used to display palette information m_HeatMap.Legend.PaletteLegendMode = PaletteLegendMode.GradientAxis; m_HeatMap.Legend.PaletteScaleStepMode = PaletteScaleStepMode.SynchronizeWithScaleConfigurator; m_HeatMap.Legend.PaletteLength = new NLength(400); NNumericScaleConfigurator numericScale = m_HeatMap.Legend.PaletteScaleConfigurator as NNumericScaleConfigurator; numericScale.MajorTickMode = MajorTickMode.CustomStep; numericScale.CustomStep = 10; m_HeatMap.Palette.Mode = PaletteMode.AutoMinMaxColor; m_HeatMap.Palette.PositiveColor = Color.FromArgb(125, Color.Red); m_HeatMap.Palette.ZeroColor = Color.FromArgb(125, Color.Blue); m_HeatMap.Palette.SmoothPalette = true; chart.Series.Add(m_HeatMap); // add background image NRangeSeries range = new NRangeSeries(); range.UseXValues = true; range.DataLabelStyle.Visible = false; range.Legend.Mode = SeriesLegendMode.None; range.Values.Add(0); range.Y2Values.Add(m_SizeY); range.XValues.Add(0); range.X2Values.Add(m_SizeX); Bitmap bitmap = NResourceHelper.BitmapFromResource(this.GetType(), "USMap.png", "Nevron.Examples.Chart.WinForm.Resources"); range.FillStyle = new NImageFillStyle(bitmap); chart.Series.Add(range); timer1.Interval = 100; timer1.Start(); ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); }
private void UpdateScale() { if (m_Updating) { return; } m_Updating = true; NAxis yAxis = nChartControl1.Charts[0].Axis(StandardAxis.PrimaryY); NNumericScaleConfigurator scale = (NNumericScaleConfigurator)yAxis.ScaleConfigurator; scale.ViewRangeInflateMode = (ScaleViewRangeInflateMode)ViewRangeInflateModeComboBox.SelectedIndex; scale.InflateViewRangeBegin = InflateViewRangeMinCheckBox.Checked; scale.InflateViewRangeEnd = InflateViewRangeMaxCheckBox.Checked; switch (scale.ViewRangeInflateMode) { case ScaleViewRangeInflateMode.MajorTick: break; case ScaleViewRangeInflateMode.Logical: scale.LogicalInflate = new NRange1DD((double)LogicalInflateMinNumericUpDown.Value, (double)LogicalInflateMaxNumericUpDown.Value); break; case ScaleViewRangeInflateMode.Absolute: scale.AbsoluteInflate = new NRange1DL(new NLength((float)AbsoluteInflateMinNumericUpDown.Value, NGraphicsUnit.Point), new NLength((float)AbsoluteInflateMaxNumericUpDown.Value, NGraphicsUnit.Point)); break; } // assign scale configurator to y axis yAxis.ScaleConfigurator = scale; // update controls state bool logicalInflate = scale.ViewRangeInflateMode == ScaleViewRangeInflateMode.Logical; LogicalInflateMinNumericUpDown.Enabled = logicalInflate; LogicalInflateMaxNumericUpDown.Enabled = logicalInflate; bool absoluteInflate = scale.ViewRangeInflateMode == ScaleViewRangeInflateMode.Absolute; AbsoluteInflateMinNumericUpDown.Enabled = absoluteInflate; AbsoluteInflateMaxNumericUpDown.Enabled = absoluteInflate; m_Updating = false; nChartControl1.Refresh(); }
protected void Page_Load(object sender, System.EventArgs e) { // init form controls if (!IsPostBack) { AngleModeDropDownList.Items.Add("View"); AngleModeDropDownList.Items.Add("Scale"); AngleModeDropDownList.SelectedIndex = 1; AllowFlipCheckBox.Checked = false; FitAxisContentInBox.Checked = true; } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Axis Labels Orientation"); nChartControl1.Panels.Add(header); header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.Margins = new NMarginsL(10, 10, 10, 4); header.DockMode = PanelDockMode.Top; // setup the chart NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); chart.Enable3D = true; chart.Fit3DAxisContent = FitAxisContentInBox.Checked; chart.DockMode = PanelDockMode.Fill; chart.BorderStyle = new NStrokeBorderStyle(BorderShape.RoundedRect); chart.BackgroundFillStyle = new NGradientFillStyle(Color.White, Color.LightGray); chart.Margins = new NMarginsL(10, 0, 10, 10); chart.Padding = new NMarginsL(2, 2, 2, 2); // set predefined projection and lighting chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); chart.Depth = 50; chart.Width = 50; chart.Height = 50; chart.BoundsMode = BoundsMode.Fit; chart.Location = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(10, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage)); // add interlaced stripe NStandardScaleConfigurator scaleConfiguratorY = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator; 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); // add series Color[] seriesColors = new Color[] { Color.Crimson, Color.Orange, Color.OliveDrab }; int dataItemsCount = 6; for (int i = 0; i < seriesColors.Length; i++) { NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar); bar.BarShape = BarShape.SmoothEdgeBar; bar.FillStyle = new NColorFillStyle(seriesColors[i]); bar.Name = "Series " + i.ToString(); bar.Values.FillRandomRange(Random, dataItemsCount, 10, 30); bar.InflateMargins = true; bar.DataLabelStyle.Visible = false; } // configure the x axis labels (categories) NOrdinalScaleConfigurator ordinalScale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.Title.Text = "Categories Title"; ordinalScale.MajorTickMode = MajorTickMode.CustomStep; ordinalScale.LabelFitModes = new LabelFitMode[] { LabelFitMode.Stagger2, LabelFitMode.AutoScale }; for (int i = 0; i < dataItemsCount; i++) { ordinalScale.Labels.Add("S" + i.ToString()); } // configure the depth axis labels (series) ordinalScale = chart.Axis(StandardAxis.Depth).ScaleConfigurator as NOrdinalScaleConfigurator; ordinalScale.AutoLabels = false; ordinalScale.Title.Text = "Series Title"; ordinalScale.MajorTickMode = MajorTickMode.CustomStep; ordinalScale.Labels.Add("S1"); ordinalScale.Labels.Add("S2"); ordinalScale.Labels.Add("S3"); ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); ordinalScale.LabelFitModes = new LabelFitMode[] { LabelFitMode.Stagger2, LabelFitMode.AutoScale }; // set title to Y axis NNumericScaleConfigurator numericScale = chart.Axis((int)StandardAxis.PrimaryY).ScaleConfigurator as NNumericScaleConfigurator; numericScale.Title.Text = "Values"; // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh); styleSheet.Apply(nChartControl1.Document); // read the form control values float customAngle; if (!float.TryParse(CustomAngleTextBox.Text, out customAngle) || customAngle < 0 || customAngle > 360) { customAngle = 0f; CustomAngleTextBox.Text = customAngle.ToString(); } // update scale labels angle int count = chart.Axes.Count; NScaleLabelAngle angle = new NScaleLabelAngle((ScaleLabelAngleMode)Enum.Parse(typeof(ScaleLabelAngleMode), AngleModeDropDownList.SelectedItem.Value), customAngle, AllowFlipCheckBox.Checked); // update the x axis NAxis axis = (NAxis)chart.Axes[(int)StandardAxis.PrimaryX]; NStandardScaleConfigurator scale = axis.ScaleConfigurator as NStandardScaleConfigurator; scale.LabelStyle.Angle = angle; // update the depth axis axis = (NAxis)chart.Axes[(int)StandardAxis.Depth]; scale = axis.ScaleConfigurator as NStandardScaleConfigurator; scale.LabelStyle.Angle = angle; }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Panels.Clear(); // set a chart title NLabel title = new NLabel("Heat Map"); 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 (will be updated on timer tick) NHeatMapSeries heatMap = new NHeatMapSeries(); heatMap.Data.SetGridSize(m_SizeX, m_SizeY); heatMap.Data.SetValues(double.NaN); heatMap.Legend.Mode = SeriesLegendMode.SeriesLogic; // used to display palette information heatMap.Legend.PaletteLegendMode = PaletteLegendMode.GradientAxis; heatMap.Legend.PaletteScaleStepMode = PaletteScaleStepMode.SynchronizeWithScaleConfigurator; heatMap.Legend.PaletteLength = new NLength(170); NNumericScaleConfigurator numericScale = heatMap.Legend.PaletteScaleConfigurator as NNumericScaleConfigurator; numericScale.MajorTickMode = MajorTickMode.CustomStep; numericScale.CustomStep = 10; heatMap.Palette.Mode = PaletteMode.AutoMinMaxColor; heatMap.Palette.PositiveColor = Color.FromArgb(125, Color.Red); heatMap.Palette.ZeroColor = Color.FromArgb(125, Color.Blue); heatMap.Palette.SmoothPalette = true; chart.Series.Add(heatMap); // add background image NRangeSeries range = new NRangeSeries(); range.UseXValues = true; range.DataLabelStyle.Visible = false; range.Legend.Mode = SeriesLegendMode.None; range.Values.Add(0); range.Y2Values.Add(m_SizeY); range.XValues.Add(0); range.X2Values.Add(m_SizeX); Bitmap bitmap = new Bitmap(this.MapPathSecure(this.TemplateSourceDirectory + "/USMap.png")); range.FillStyle = new NImageFillStyle(bitmap); chart.Series.Add(range); // then create some dummy data CreateDymmyData(heatMap); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { WebExamplesUtilities.FillComboWithEnumValues(ViewRangeInflateModeDropDownList, typeof(ScaleViewRangeInflateMode)); ViewRangeInflateModeDropDownList.SelectedIndex = (int)ScaleViewRangeInflateMode.MajorTick; InflateMinCheckBox.Checked = true; InflateMaxCheckBox.Checked = true; WebExamplesUtilities.FillComboWithValues(LogicalInflateMinMaxDropDownList, 0, 200, 10); WebExamplesUtilities.FillComboWithValues(AbsoluteInflateMinMaxDropDownList, 0, 20, 2); } nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Panels.Clear(); // set a chart title NLabel header = new NLabel("Volume Change vs. Last Year<br/> <font size = '9pt'>Demonstrates different view range modes</font>"); header.TextStyle.TextFormat = TextFormat.XML; header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; header.DockMode = PanelDockMode.Top; header.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Center; header.Margins = new NMarginsL(10, 2, 10, 10); nChartControl1.Panels.Add(header); // add some data to the control NCartesianChart chart = new NCartesianChart(); chart.DockMode = PanelDockMode.Fill; chart.BoundsMode = BoundsMode.Stretch; NBarSeries bar = new NBarSeries(); bar.DataLabelStyle.Visible = false; NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Nevron); bar.Values.Add(100); bar.FillStyles[0] = new NColorFillStyle(palette.SeriesColors[0]); bar.Values.Add(200); bar.FillStyles[1] = new NColorFillStyle(palette.SeriesColors[0]); bar.Values.Add(-180); bar.FillStyles[3] = new NColorFillStyle(palette.SeriesColors[1]); bar.Values.Add(200); bar.FillStyles[4] = new NColorFillStyle(palette.SeriesColors[1]); bar.Values.Add(400); bar.FillStyles[5] = new NColorFillStyle(palette.SeriesColors[1]); chart.Series.Add(bar); chart.Margins = new NMarginsL(10, 0, 10, 10); // configure y axis NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; // add interlace 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); linearScale.StripStyles.Add(stripStyle); // configure the x axis NHierarchicalScaleConfigurator hierarchicalScale = new NHierarchicalScaleConfigurator(); hierarchicalScale.CreateSeparatorForEachLevel = false; // create utilization group NHierarchicalScaleNode utilization = new NHierarchicalScaleNode(0, "Cash Utilisation"); utilization.LabelStyle.TickMode = RangeLabelTickMode.Separators; utilization.LabelStyle.TextStyle.FontStyle.EmSize = new NLength(11); utilization.LabelStyle.TextStyle.FontStyle.Style = FontStyle.Bold; utilization.ChildNodes.Add(CreateSubScaleNode("Cash at ATM", true, false)); utilization.ChildNodes.Add(CreateSubScaleNode("Cash at desk", true, false)); hierarchicalScale.Nodes.Add(utilization); // create payments group NHierarchicalScaleNode payments = new NHierarchicalScaleNode(0, "Payments"); payments.LabelStyle.TickMode = RangeLabelTickMode.Separators; payments.LabelStyle.TextStyle.FontStyle.EmSize = new NLength(11); payments.LabelStyle.TextStyle.FontStyle.Style = FontStyle.Bold; payments.ChildNodes.Add(CreateSubScaleNode("Cheque", true, false)); payments.ChildNodes.Add(CreateSubScaleNode("Direct debit", true, false)); payments.ChildNodes.Add(CreateSubScaleNode("Wire transfer", true, true)); hierarchicalScale.Nodes.Add(payments); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = hierarchicalScale; nChartControl1.Panels.Add(chart); // update form controls NAxis yAxis = nChartControl1.Charts[0].Axis(StandardAxis.PrimaryY); NNumericScaleConfigurator scale = (NNumericScaleConfigurator)yAxis.ScaleConfigurator; scale.Title.Text = "Volume in Thousands USD"; scale.ViewRangeInflateMode = (ScaleViewRangeInflateMode)ViewRangeInflateModeDropDownList.SelectedIndex; scale.InflateViewRangeBegin = InflateMinCheckBox.Checked; scale.InflateViewRangeEnd = InflateMaxCheckBox.Checked; switch (scale.ViewRangeInflateMode) { case ScaleViewRangeInflateMode.MajorTick: break; case ScaleViewRangeInflateMode.Logical: double logicalInflate = LogicalInflateMinMaxDropDownList.SelectedIndex * 10; scale.LogicalInflate = new NRange1DD(logicalInflate, logicalInflate); break; case ScaleViewRangeInflateMode.Absolute: float absoluteInflate = AbsoluteInflateMinMaxDropDownList.SelectedIndex * 2; scale.AbsoluteInflate = new NRange1DL(new NLength(absoluteInflate, NGraphicsUnit.Point), new NLength(absoluteInflate, NGraphicsUnit.Point)); break; } // assign scale configurator to y axis yAxis.ScaleConfigurator = scale; // update controls state LogicalInflateMinMaxDropDownList.Enabled = scale.ViewRangeInflateMode == ScaleViewRangeInflateMode.Logical; AbsoluteInflateMinMaxDropDownList.Enabled = scale.ViewRangeInflateMode == ScaleViewRangeInflateMode.Absolute; }
public override void Initialize() { base.Initialize(); nChartControl1.Panels.Clear(); // set a chart title NLabel title = new NLabel("Bank Product and Service Volume Change vs. Last Year<br/> <font size = '9pt'>Demonstrates how to use the view range inflate mode property</font>"); title.TextStyle.TextFormat = TextFormat.XML; title.DockMode = PanelDockMode.Top; title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Center; title.ContentAlignment = ContentAlignment.BottomCenter; title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); title.Margins = new NMarginsL(10, 10, 10, 10); nChartControl1.Panels.Add(title); // add some data to the control NCartesianChart chart = new NCartesianChart(); chart.DockMode = PanelDockMode.Fill; chart.BoundsMode = BoundsMode.Stretch; NBarSeries bar = new NBarSeries(); bar.DataLabelStyle.Visible = false; NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Fresh); bar.Values.Add(100); bar.FillStyles[0] = new NColorFillStyle(palette.SeriesColors[0]); bar.Values.Add(200); bar.FillStyles[1] = new NColorFillStyle(palette.SeriesColors[0]); bar.Values.Add(1100); bar.FillStyles[2] = new NColorFillStyle(palette.SeriesColors[0]); bar.Values.Add(-200); bar.FillStyles[3] = new NColorFillStyle(palette.SeriesColors[1]); bar.Values.Add(200); bar.FillStyles[4] = new NColorFillStyle(palette.SeriesColors[1]); bar.Values.Add(1800); bar.FillStyles[5] = new NColorFillStyle(palette.SeriesColors[1]); bar.Values.Add(1000); bar.FillStyles[6] = new NColorFillStyle(palette.SeriesColors[1]); bar.Values.Add(-320); bar.FillStyles[7] = new NColorFillStyle(palette.SeriesColors[1]); chart.Series.Add(bar); chart.Margins = new NMarginsL(10, 0, 10, 10); // configure y axis NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator; // add interlace 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); linearScale.StripStyles.Add(stripStyle); // configure the x axis NHierarchicalScaleConfigurator hierarchicalScale = new NHierarchicalScaleConfigurator(); hierarchicalScale.CreateSeparatorForEachLevel = false; // create utilization group NHierarchicalScaleNode utilization = new NHierarchicalScaleNode(0, "Cash Utilisation"); utilization.LabelStyle.TickMode = RangeLabelTickMode.Separators; utilization.LabelStyle.TextStyle.FontStyle.EmSize = new NLength(13); utilization.LabelStyle.TextStyle.FontStyle.Style = FontStyle.Bold; utilization.ChildNodes.Add(CreateSubScaleNode("Cash at ATM", true, false)); utilization.ChildNodes.Add(CreateSubScaleNode("Cash at desk", true, false)); utilization.ChildNodes.Add(CreateSubScaleNode("Cash at other banks' ATM networks", true, false)); hierarchicalScale.Nodes.Add(utilization); // create payments group NHierarchicalScaleNode payments = new NHierarchicalScaleNode(0, "Payments"); payments.LabelStyle.TickMode = RangeLabelTickMode.Separators; payments.LabelStyle.TextStyle.FontStyle.EmSize = new NLength(13); payments.LabelStyle.TextStyle.FontStyle.Style = FontStyle.Bold; payments.ChildNodes.Add(CreateSubScaleNode("Cheque", true, false)); payments.ChildNodes.Add(CreateSubScaleNode("Direct debit", true, false)); payments.ChildNodes.Add(CreateSubScaleNode("External wire transfer", true, false)); payments.ChildNodes.Add(CreateSubScaleNode("Internal wire transfer", true, false)); payments.ChildNodes.Add(CreateSubScaleNode("Standing order ", true, true)); hierarchicalScale.Nodes.Add(payments); chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = hierarchicalScale; nChartControl1.Panels.Add(chart); // update form controls NAxis yAxis = nChartControl1.Charts[0].Axis(StandardAxis.PrimaryY); NNumericScaleConfigurator scale = (NNumericScaleConfigurator)yAxis.ScaleConfigurator; scale.Title.Text = "Volume in Thousands USD"; m_Updating = true; InflateViewRangeMinCheckBox.Checked = scale.InflateViewRangeBegin; InflateViewRangeMaxCheckBox.Checked = scale.InflateViewRangeEnd; ViewRangeInflateModeComboBox.FillFromEnum(typeof(ScaleViewRangeInflateMode)); ViewRangeInflateModeComboBox.SelectedIndex = (int)scale.ViewRangeInflateMode; LogicalInflateMinNumericUpDown.Value = (decimal)scale.LogicalInflate.Begin; LogicalInflateMaxNumericUpDown.Value = (decimal)scale.LogicalInflate.End; AbsoluteInflateMinNumericUpDown.Value = (decimal)scale.AbsoluteInflate.Begin.Value; AbsoluteInflateMaxNumericUpDown.Value = (decimal)scale.AbsoluteInflate.End.Value; m_Updating = false; UpdateScale(); }