コード例 #1
0
/*		private void GenerateData()
 *              {
 *                      NGridData data = m_HeatMap.Data;
 *
 *          int GridStepX = 10;
 *          int GridStepY = 10;
 *                      data.Size = new NSizeI(GridStepX, GridStepY);
 *
 *                      for (int row = 0; row < GridStepX; row++)
 *                      {
 *                              for (int col = 0; col < GridStepY; col++)
 *                              {
 *                                      int dx = 2 - row;
 *                                      int dy = 2 - col;
 *                                      double distance = Math.Sqrt(dx * dx + dy * dy);
 *
 *                                      data.SetValue(row, col, 5 - distance);
 *                              }
 *                      }
 *              }*/

        private void GenerateData()
        {
            NGridData data = m_HeatMap.Data;

            int GridStepX = 300;
            int GridStepY = 300;

            data.Size = new NSizeI(GridStepX, GridStepY);

            const double dIntervalX  = 10.0;
            const double dIntervalZ  = 10.0;
            double       dIncrementX = (dIntervalX / GridStepX);
            double       dIncrementZ = (dIntervalZ / GridStepY);

            double y, x, z;

            z = -(dIntervalZ / 2);

            for (int col = 0; col < GridStepX; col++, z += dIncrementZ)
            {
                x = -(dIntervalX / 2);

                for (int row = 0; row < GridStepY; row++, x += dIncrementX)
                {
                    y  = 10 - Math.Sqrt((x * x) + (z * z) + 2);
                    y += 3.0 * Math.Sin(x) * Math.Cos(z);

                    data.SetValue(row, col, y);
                }
            }
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Standard Heat Map";

            // configure chart
            NCartesianChart chart = (NCartesianChart)chartView.Surface.Charts[0];

            chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear);

            m_HeatMap = new NHeatMapSeries();
            chart.Series.Add(m_HeatMap);

            NGridData data = m_HeatMap.Data;

            m_HeatMap.Palette = new NColorValuePalette(new NColorValuePair[] { new NColorValuePair(0.0, NColor.Purple),
                                                                               new NColorValuePair(1.5, NColor.MediumSlateBlue),
                                                                               new NColorValuePair(3.0, NColor.CornflowerBlue),
                                                                               new NColorValuePair(4.5, NColor.LimeGreen),
                                                                               new NColorValuePair(6.0, NColor.LightGreen),
                                                                               new NColorValuePair(7.5, NColor.Yellow),
                                                                               new NColorValuePair(9.0, NColor.Orange),
                                                                               new NColorValuePair(10.5, NColor.Red) });

            int gridSizeX = 100;
            int gridSizeY = 100;

            data.Size = new NSizeI(gridSizeX, gridSizeY);
            double y, x, z;

            const double dIntervalX  = 10.0;
            const double dIntervalZ  = 10.0;
            double       dIncrementX = (dIntervalX / gridSizeX);
            double       dIncrementZ = (dIntervalZ / gridSizeY);

            z = -(dIntervalZ / 2);

            for (int j = 0; j < gridSizeY; j++, z += dIncrementZ)
            {
                x = -(dIntervalX / 2);

                for (int i = 0; i < gridSizeX; i++, x += dIncrementX)
                {
                    y  = 10 - Math.Sqrt((x * x) + (z * z) + 2);
                    y += 3.0 * Math.Sin(x) * Math.Cos(z);

                    data.SetValue(i, j, y);
                }
            }

            return(chartView);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Standard Heat Maps";

            // configure chart
            NCartesianChart chart = (NCartesianChart)chartView.Surface.Charts[0];

            chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear);

            NHeatMapSeries heatMap = new NHeatMapSeries();

            chart.Series.Add(heatMap);

            NGridData data = heatMap.Data;

            heatMap.Palette = new NTwoColorPalette(NColor.Green, NColor.Red);

            int gridSizeX = 100;
            int gridSizeY = 100;

            data.Size = new NSizeI(gridSizeX, gridSizeY);

            int centerX = gridSizeX / 2;
            int centerY = gridSizeY / 2;

            int    radius = gridSizeX / 2;
            Random rand   = new Random();

            for (int y = 0; y < gridSizeY; y++)
            {
                for (int x = 0; x < gridSizeX; x++)
                {
                    int dx = x - centerX;
                    int dy = y - centerY;

                    double pointDistance = Math.Sqrt(dx * dx + dy * dy);

                    if (pointDistance < radius)
                    {
                        // assign value
                        data.SetValue(x, y, pointDistance + rand.Next(20));
                    }
                    else
                    {
                        data.SetValue(x, y, double.NaN);
                    }
                }
            }

            return(chartView);
        }