/// <summary> /// Generates random data /// </summary> /// <param name="pointSeries"></param> /// <param name="heatMapSeries"></param> private void GenerateData(NPointSeries pointSeries, NTriangulatedHeatMapSeries heatMapSeries) { NPointD[] points = new NPointD[] { new NPointD(0.1, 0.1), new NPointD(1.5, 1.0), new NPointD(2.5, 5), new NPointD(4, 0), new NPointD(2.5, 3.4), new NPointD(1.3, 5) }; double[] pointsIntensity = new double[] { 30, 10, 30, 20, 40, 20 }; Random rand = new Random(); for (double x = 0.0; x <= 5; x += 0.5) { for (double y = 0.0; y <= 5; y += 0.5) { double pointX; double pointY; if (x == 0 || y == 0 || x == 5 || y == 5) { pointX = x; pointY = y; } else { pointX = x + rand.NextDouble() * 0.2; pointY = y + rand.NextDouble() * 0.2; } double intensity = 0; for (int i = 0; i < points.Length; i++) { double dx = points[i].X - pointX; double dy = points[i].Y - pointY; double distance = Math.Sqrt(dx * dx + dy * dy); intensity += pointsIntensity[i] / (1 + distance * distance); } heatMapSeries.Values.Add(intensity); heatMapSeries.XValues.Add(pointX); heatMapSeries.YValues.Add(pointY); } } pointSeries.Values.AddRange(heatMapSeries.YValues); pointSeries.XValues.AddRange(heatMapSeries.XValues); }
/// <summary> /// Called to initialize the example /// </summary> /// <param name="chartControl"></param> public override void Create() { // set a chart title NLabel title = new NLabel("Triangulated Heat Map Contour Labels"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); NChart chart = nChartControl1.Charts[0]; chart.BoundsMode = BoundsMode.Stretch; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator(); // create the heat map // create the heat map m_HeatMap = new NTriangulatedHeatMapSeries(); chart.Series.Add(m_HeatMap); m_HeatMap.Palette.Add(0.0, Color.Purple); m_HeatMap.Palette.Add(1.5, Color.MediumSlateBlue); m_HeatMap.Palette.Add(3.0, Color.CornflowerBlue); m_HeatMap.Palette.Add(4.5, Color.LimeGreen); m_HeatMap.Palette.Add(6.0, Color.LightGreen); m_HeatMap.Palette.Add(7.5, Color.Yellow); m_HeatMap.Palette.Add(9.0, Color.Orange); m_HeatMap.Palette.Add(10.5, Color.Red); m_HeatMap.ContourDisplayMode = ContourDisplayMode.Contour; m_HeatMap.Legend.Mode = SeriesLegendMode.SeriesLogic; m_HeatMap.Legend.Format = "<zone_value>"; m_HeatMap.ContourLabelStyle.Visible = true; m_HeatMap.ContourLabelStyle.AllowLabelToFlip = false; m_HeatMap.ContourLabelStyle.TextStyle.BackplaneStyle.Visible = false; m_HeatMap.ContourLabelStyle.ClipContour = true; GenerateData(); ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); ShowContourLabelsCheckBox.IsChecked = true; AllowLabelsToFlipCheckBox.IsChecked = false; ShowLabelBackgroundCheckBox.IsChecked = false; ClipContourCheckBox.IsChecked = true; }
public override void Initialize() { base.Initialize(); // set a chart title NLabel title = new NLabel("Triangulated Heat Map"); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic); title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue); NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0]; chart.RangeSelections.Add(new NRangeSelection()); chart.BoundsMode = BoundsMode.Stretch; NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); scaleX.RoundToTickMin = false; scaleX.RoundToTickMax = false; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator(); scaleY.RoundToTickMin = false; scaleY.RoundToTickMax = false; chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = scaleY; // create a point series (used to show the incoming points XY values) m_Points = new NPointSeries(); chart.Series.Add(m_Points); m_Points.UseXValues = true; m_Points.BorderStyle.Width = new NLength(0); m_Points.FillStyle = new NColorFillStyle(Color.Black); m_Points.Size = new NLength(2); m_Points.DataLabelStyle.Visible = false; // create the heat map m_HeatMap = new NTriangulatedHeatMapSeries(); chart.Series.Add(m_HeatMap); m_HeatMap.Palette.Add(0.0, Color.Purple); m_HeatMap.Palette.Add(1.5, Color.MediumSlateBlue); m_HeatMap.Palette.Add(3.0, Color.CornflowerBlue); m_HeatMap.Palette.Add(4.5, Color.LimeGreen); m_HeatMap.Palette.Add(6.0, Color.LightGreen); m_HeatMap.Palette.Add(7.5, Color.Yellow); m_HeatMap.Palette.Add(9.0, Color.Orange); m_HeatMap.Palette.Add(10.5, Color.Red); m_HeatMap.ContourDisplayMode = ContourDisplayMode.Contour; m_HeatMap.Legend.Mode = SeriesLegendMode.SeriesLogic; m_HeatMap.Legend.Format = "<zone_value>"; GenerateData(); ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NDataZoomTool()); // init form controls ContourDisplayModeCombo.FillFromEnum(typeof(ContourDisplayMode)); ContourColorModeCombo.FillFromEnum(typeof(ContourColorMode)); ContourDisplayModeCombo.SelectedIndex = (int)ContourDisplayMode.Contour; ContourColorModeCombo.SelectedIndex = (int)ContourColorMode.Uniform; ContourDotSizeNumericUpDown.Value = (decimal)2; ShowFillCheckBox.Checked = true; SmoothPaletteCheckBox.Checked = true; }
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); NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); scaleX.RoundToTickMin = false; scaleX.RoundToTickMax = false; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator(); scaleY.RoundToTickMin = false; scaleY.RoundToTickMax = false; chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = scaleY; // create the heat map // create the heat map NTriangulatedHeatMapSeries heatMap = new NTriangulatedHeatMapSeries(); 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.ContourDisplayMode = ContourDisplayMode.Contour; heatMap.Legend.Mode = SeriesLegendMode.SeriesLogic; heatMap.Legend.Format = "<zone_value>"; 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) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Panels.Clear(); // set a chart title NLabel title = new NLabel("Triangulated 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); NCartesianChart chart = new NCartesianChart(); nChartControl1.Panels.Add(chart); chart.DockMode = PanelDockMode.Fill; chart.BoundsMode = BoundsMode.Stretch; chart.Margins = new NMarginsL(5); NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator(); scaleX.RoundToTickMin = false; scaleX.RoundToTickMax = false; chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX; NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator(); scaleY.RoundToTickMin = false; scaleY.RoundToTickMax = false; chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = scaleY; // create a point series (used to show the incoming points XY values) NPointSeries point = new NPointSeries(); chart.Series.Add(point); point.UseXValues = true; point.BorderStyle.Width = new NLength(0); point.FillStyle = new NColorFillStyle(Color.Black); point.Size = new NLength(2); point.DataLabelStyle.Visible = false; // create the heat map NTriangulatedHeatMapSeries heatMap = new NTriangulatedHeatMapSeries(); 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.ContourDisplayMode = ContourDisplayMode.Contour; heatMap.Legend.Mode = SeriesLegendMode.SeriesLogic; heatMap.Legend.Format = "<zone_value>"; GenerateData(point, heatMap); }