public override void Do(IDemoChartControl chartControl)
        {
            List <RenderData> renderDatas = new List <RenderData>();

            for (int i = 0; i < SeriesCount; i++)
            {
                // Create custom data reader.
                var dataReader = new CustomSeriesDataReader(PointCount, 1f, i);
                dataReaders.Add(dataReader);

                // Create series.
                Color4 color  = DemoHelper.RandomizeColor();
                var    series = new Series
                {
                    // Set data reader.
                    Reader = dataReader,
                    // Set series line color.
                    Color = color,
                    // Set series line thickness.
                    Thickness = 2f,
                    // Set series line pattern style.
                    PatternStyle = PatternStyle.Solid,
                    // Set series marker style.
                    MarkerStyle = markers[i % markers.Length],
                    // Set marker size.
                    MarkerSize = 12,
                    // Set marker color.
                    MarkerColor = color,
                    // Set name.
                    Name = $"Line {i}"
                };
                renderDatas.Add(series);
            }

            // Setup chart view settings.
            chartControl.ContextView.Camera2D.Projection = Projection2DTypes.XPosYPos;
            chartControl.ContextView.Mode2D = true;

            // Tell the chart that we wanna update view on bounds change.
            chartControl.ViewResetOptions.ResetOnDataChanged = true;

            // Setup chart data source.
            chartControl.DataSource = renderDatas;

            // Start animation.
            animationHelper.Start(value => value, value =>
            {
                foreach (CustomSeriesDataReader dataReader in dataReaders)
                {
                    dataReader.RandomizePoint();
                }
            }, 0f, 0f, 25);
        }
Ejemplo n.º 2
0
        public override void Do(IDemoChartControl chartControl)
        {
            // Create mesh for rendering. We need a cube.
            Mesh cubeMesh = CubeMeshFactory.GenerateCube();

            // Generates cube transformation matrixes and it's colors.
            Matrix4F[] transformations = new Matrix4F[TotalBarCount];
            Color4[]   colors          = new Color4[TotalBarCount];
            int        index           = 0;

            for (int x = 0; x < GridSize; x++)
            {
                for (int y = 0; y < GridSize; y++)
                {
                    // Randomize block height.
                    float height = (float)random.NextDouble() * MaxHeight;
                    // Compute current bar transformation matrix.
                    // Scaling matrix is used for size scaling. Translation matrix is used for positioning.
                    transformations[index] = Matrix4F.Scaling(BlockSize, BlockSize, height) *
                                             Matrix4F.Translation(GridStep * x, GridStep * y, height / 2);
                    // Randomize color.
                    colors[index] = DemoHelper.RandomizeColor();
                    index++;
                }
            }

            // Create presentation object.
            var primitiveCollection = new MultiColorPrimitiveCollection
            {
                // Set mesh.
                Mesh = cubeMesh,
                // Set name.
                Name = "Bars",
                // Set custom material.
                Material = new RenderMaterial(0.35f, 0.5f, 0.6f, 0.0f, 0.0f)
            };

            // Set transforms.
            primitiveCollection.SetTransformsAndColor(transformations, colors);

            // Set chart options.
            chartControl.Axes.IsAxes3DVisible = true;

            // Set data source.
            chartControl.DataSource = primitiveCollection;
        }