Exemple #1
0
        private void AddDataPoints(NBubbleSeries bubble)
        {
            NChartPalette palette = new NChartPalette();

            palette.SetPredefinedPalette(ChartPredefinedPalette.Dark);

            NColorFillStyle fs0 = new NColorFillStyle(palette.SeriesColors[0]);
            NColorFillStyle fs1 = new NColorFillStyle(palette.SeriesColors[1]);
            NColorFillStyle fs2 = new NColorFillStyle(palette.SeriesColors[2]);
            NColorFillStyle fs3 = new NColorFillStyle(palette.SeriesColors[3]);
            NColorFillStyle fs4 = new NColorFillStyle(palette.SeriesColors[4]);
            NColorFillStyle fs5 = new NColorFillStyle(palette.SeriesColors[5]);

            if (LightingFilterCheckBox.Checked)
            {
                fs0.ImageFiltersStyle.Filters.Add(CreateLightingImageFilter());
                fs1.ImageFiltersStyle.Filters.Add(CreateLightingImageFilter());
                fs2.ImageFiltersStyle.Filters.Add(CreateLightingImageFilter());
                fs3.ImageFiltersStyle.Filters.Add(CreateLightingImageFilter());
                fs4.ImageFiltersStyle.Filters.Add(CreateLightingImageFilter());
                fs5.ImageFiltersStyle.Filters.Add(CreateLightingImageFilter());
            }

            bubble.AddDataPoint(new NBubbleDataPoint(27, 51, 1147995904, "India", fs0));
            bubble.AddDataPoint(new NBubbleDataPoint(50, 67, 1321851888, "China", fs1));
            bubble.AddDataPoint(new NBubbleDataPoint(76, 22, 109955400, "Mexico", fs2));
            bubble.AddDataPoint(new NBubbleDataPoint(210, 9, 142008838, "Russia", fs3));
            bubble.AddDataPoint(new NBubbleDataPoint(360, 4, 305843000, "USA", fs4));
            bubble.AddDataPoint(new NBubbleDataPoint(470, 5, 33560000, "Canada", fs5));
        }
        public override void Initialize()
        {
            base.Initialize();

            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Exploded Pie Chart");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            title.ContentAlignment    = ContentAlignment.BottomCenter;
            title.Location            = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));

            NChart chart = new NPieChart();

            nChartControl1.Panels.Add(chart);

            chart.Enable3D = true;
            chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalElevated);
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre);

            chart.Size = new NSizeL(new NLength(60, NRelativeUnit.ParentPercentage),
                                    new NLength(60, NRelativeUnit.ParentPercentage));

            chart.Location = new NPointL(new NLength(20, NRelativeUnit.ParentPercentage),
                                         new NLength(20, NRelativeUnit.ParentPercentage));

            m_Pie = (NPieSeries)chart.Series.Add(SeriesType.Pie);
            m_Pie.PieEdgePercent = 30;

            m_Pie.AddDataPoint(new NDataPoint(12, "Cars"));
            m_Pie.AddDataPoint(new NDataPoint(42, "Trains"));
            m_Pie.AddDataPoint(new NDataPoint(56, "Airplanes"));
            m_Pie.AddDataPoint(new NDataPoint(23, "Buses"));

            for (int i = 0; i < m_Pie.Values.Count; i++)
            {
                m_Pie.Detachments.Add(0);
            }

            m_DefaultFillStyles = new NFillStyle[4];
            NChartPalette palette = new NChartPalette();

            palette.SetPredefinedPalette(ChartPredefinedPalette.Winter);

            m_DefaultFillStyles[0] = new NColorFillStyle(palette.SeriesColors[0]);
            m_DefaultFillStyles[1] = new NColorFillStyle(palette.SeriesColors[1]);
            m_DefaultFillStyles[2] = new NColorFillStyle(palette.SeriesColors[2]);
            m_DefaultFillStyles[3] = new NColorFillStyle(palette.SeriesColors[3]);

            for (int i = 0; i < m_DefaultFillStyles.Length; i++)
            {
                m_Pie.FillStyles[i] = m_DefaultFillStyles[i];
            }

            SetPieDefaultFillStyles();

            m_Pie.PieStyle = PieStyle.SmoothEdgePie;

            m_Pie.Legend.Mode   = SeriesLegendMode.DataPoints;
            m_Pie.Legend.Format = "<label> <percent>";

            // subscribe for control events
            nChartControl1.MouseDown += new MouseEventHandler(ChartControl_MouseDown);
            nChartControl1.MouseMove += new MouseEventHandler(ChartControl_MouseMove);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WebExamplesUtilities.FillComboWithEnumValues(ShapeStyleDropDownList, typeof(BarShape));
                ShapeStyleDropDownList.SelectedIndex = 0;

                WebExamplesUtilities.FillComboWithColorNames(ShapesColorDropDownList, KnownColor.DarkOrange);

                WebExamplesUtilities.FillComboWithPredefinedProjections(ProjectionDropDownList);
                ProjectionDropDownList.SelectedIndex = (int)PredefinedProjection.PerspectiveTilted;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Shape Series");

            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.Enable3D = true;
            chart.Depth    = 50;
            chart.Projection.SetPredefinedProjection((PredefinedProjection)ProjectionDropDownList.SelectedIndex);
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft);

            // setup X axis
            NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator();

            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX;
            scaleX.MajorGridStyle.ShowAtWalls       = new ChartWallType[] { ChartWallType.Back, ChartWallType.Floor };
            scaleX.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;

            // setup Y axis
            NLinearScaleConfigurator scaleY = new NLinearScaleConfigurator();

            chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = scaleY;
            scaleY.MajorGridStyle.ShowAtWalls       = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left };
            scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;

            // add interlaced stripe
            NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1);

            stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left };
            stripStyle.Interlaced  = true;
            scaleY.StripStyles.Add(stripStyle);

            // setup Z axis
            NLinearScaleConfigurator scaleZ = new NLinearScaleConfigurator();

            chart.Axis(StandardAxis.Depth).ScaleConfigurator = scaleZ;
            scaleZ.MajorGridStyle.ShowAtWalls       = new ChartWallType[] { ChartWallType.Left, ChartWallType.Floor };
            scaleZ.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;

            // setup shape series
            NShapeSeries shape = (NShapeSeries)chart.Series.Add(SeriesType.Shape);

            shape.Name = "Shape Series";
            shape.DataLabelStyle.Visible = false;

            // populate with random data
            shape.Values.FillRandomRange(Random, 10, -100, 100);
            shape.XValues.FillRandomRange(Random, 10, -100, 100);
            shape.ZValues.FillRandomRange(Random, 10, -100, 100);
            shape.YSizes.FillRandomRange(Random, 10, 5, 20);
            shape.XSizes.FillRandomRange(Random, 10, 5, 20);
            shape.ZSizes.FillRandomRange(Random, 10, 5, 20);

            shape.Shape     = (BarShape)ShapeStyleDropDownList.SelectedIndex;
            shape.FillStyle = new NColorFillStyle(WebExamplesUtilities.ColorFromDropDownList(ShapesColorDropDownList));

            shape.UseXValues = UseXValueCheckBox.Checked;
            shape.UseZValues = UseZValueCheckBox.Checked;

            if (DifferentColorsCheckBox.Checked)
            {
                ShapesColorDropDownList.Enabled = false;

                NChartPalette palette = new NChartPalette();
                palette.SetPredefinedPalette(ChartPredefinedPalette.Nevron);

                for (int i = 0; i < shape.Values.Count; i++)
                {
                    shape.FillStyles[i] = new NColorFillStyle(palette.SeriesColors[i % palette.SeriesColors.Count]);
                }
            }
            else
            {
                ShapesColorDropDownList.Enabled = true;
                shape.FillStyles.Clear();
                shape.FillStyle = new NColorFillStyle(WebExamplesUtilities.ColorFromDropDownList(ShapesColorDropDownList));
            }

            // apply layout
            ApplyLayoutTemplate(0, nChartControl1, chart, title, null);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // init form controls
                FormatDropDownList.Items.Add("[value] [label]");
                FormatDropDownList.Items.Add("[index] [cumulative]");
                FormatDropDownList.Items.Add("[percent] [total]");
                FormatDropDownList.SelectedIndex = 0;

                ModeDropDownList.Items.Add("Disabled");
                ModeDropDownList.Items.Add("Series");
                ModeDropDownList.Items.Add("DataPoints");
                ModeDropDownList.Items.Add("SeriesCustom");
                ModeDropDownList.SelectedIndex = 2;

                WebExamplesUtilities.FillComboWithEnumValues(PointShapeDropDownList, typeof(PointShape));
                PointShapeDropDownList.SelectedIndex = 0;

                WebExamplesUtilities.FillComboWithColorNames(ColorDropDownList, KnownColor.DarkOrange);

                DifferentColorsCheckBox.Checked = true;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = new NLabel("Series Legend");

            title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
            nChartControl1.Panels.Add(title);

            // setup chart
            NChart chart = nChartControl1.Charts[0];

            chart.Axis(StandardAxis.Depth).Visible = false;

            // 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);

            NPointSeries point = (NPointSeries)chart.Series.Add(SeriesType.Point);

            point.DataLabelStyle.Visible = false;
            point.InflateMargins         = true;
            point.PointShape             = (PointShape)PointShapeDropDownList.SelectedIndex;
            point.Legend.Mode            = (SeriesLegendMode)ModeDropDownList.SelectedIndex;

            point.AddDataPoint(new NDataPoint(16, "Agriculture"));
            point.AddDataPoint(new NDataPoint(42, "Construction"));
            point.AddDataPoint(new NDataPoint(56, "Manufacturing"));
            point.AddDataPoint(new NDataPoint(23, "Services"));
            point.AddDataPoint(new NDataPoint(47, "Healthcare"));
            point.AddDataPoint(new NDataPoint(38, "Finance"));

            // apply layout
            ApplyLayoutTemplate(0, nChartControl1, chart, title, nChartControl1.Legends[0]);

            if (DifferentColorsCheckBox.Checked)
            {
                NChartPalette palette = new NChartPalette();
                palette.SetPredefinedPalette(ChartPredefinedPalette.Nevron);

                for (int i = 0; i < point.Values.Count; i++)
                {
                    point.FillStyles[i] = new NColorFillStyle(palette.SeriesColors[i % palette.SeriesColors.Count]);
                }
                ColorDropDownList.Enabled = false;
            }
            else
            {
                point.FillStyle           = new NColorFillStyle(WebExamplesUtilities.ColorFromDropDownList(ColorDropDownList));
                ColorDropDownList.Enabled = true;
            }

            if (ModeDropDownList.SelectedIndex == 2)
            {
                FormatDropDownList.Enabled = true;
                point.Legend.Format        = WebExamplesUtilities.GetXmlFormatString(FormatDropDownList.SelectedItem.Text);
            }
            else
            {
                FormatDropDownList.Enabled = false;
            }
        }
Exemple #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                FillModeDropDownList.Items.Add("Uniform");
                FillModeDropDownList.Items.Add("Individual");
                FillModeDropDownList.SelectedIndex = 1;

                WebExamplesUtilities.FillComboWithColorNames(BarColorDropDownList, KnownColor.DarkOrange);

                WebExamplesUtilities.FillComboWithValues(CycleCountDropDownList, 2, 6, 1);
                CycleCountDropDownList.SelectedIndex = 4;

                WebExamplesUtilities.FillComboWithValues(BarCountDropDownList, 3, 20, 1);
                BarCountDropDownList.SelectedIndex = 3;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Series Appearance");

            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.Enable3D = true;
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft);
            chart.Axis(StandardAxis.Depth).Visible = false;

            // 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);

            NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);

            bar.Name = "Bar Series";
            bar.DataLabelStyle.Visible = false;
            bar.Values.FillRandom(Random, BarCountDropDownList.SelectedIndex + 3);

            switch (FillModeDropDownList.SelectedIndex)
            {
            case 0:     // Uniform
                BarColorDropDownList.Enabled   = true;
                CycleCountDropDownList.Enabled = false;

                bar.FillStyle = new NColorFillStyle(WebExamplesUtilities.ColorFromDropDownList(BarColorDropDownList));
                break;

            case 1:                     // Individual
                BarColorDropDownList.Enabled   = false;
                CycleCountDropDownList.Enabled = true;

                bar.FillStyles.Clear();

                NChartPalette palette = new NChartPalette();
                palette.SetPredefinedPalette(ChartPredefinedPalette.Nevron);

                int cycleCount   = CycleCountDropDownList.SelectedIndex + 1;
                int currentColor = 0;

                for (int i = 0; i < bar.Values.Count; i++)
                {
                    bar.FillStyles[i] = new NColorFillStyle(palette.SeriesColors[currentColor]);
                    currentColor++;

                    if (currentColor > cycleCount)
                    {
                        currentColor = 0;
                    }
                }
                break;
            }

            // apply layout
            ApplyLayoutTemplate(0, nChartControl1, chart, title, null);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WebExamplesUtilities.FillComboWithEnumValues(PointShapeDropDownList, typeof(PointShape));
                PointShapeDropDownList.SelectedIndex = 0;

                DataLabelFormatDropDownList.Items.Add("Value and Label");
                DataLabelFormatDropDownList.Items.Add("Value");
                DataLabelFormatDropDownList.Items.Add("Label");
                DataLabelFormatDropDownList.SelectedIndex = 0;

                WebExamplesUtilities.FillComboWithValues(PointSizeDropDownList, 0, 10, 1);
                PointSizeDropDownList.SelectedIndex = 4;

                WebExamplesUtilities.FillComboWithColorNames(PointColorDropDownList, KnownColor.Orange);

                DifferentColorsCheckBox.Checked     = true;
                LeftAxisRoundToTickCheckBox.Checked = true;
                ShowDataLabelsCheckBox.Checked      = true;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Point Chart");

            title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;

            // setup chart
            NChart chart = nChartControl1.Charts[0];

            chart.BoundsMode = BoundsMode.Stretch;

            // setup Y axis
            NLinearScaleConfigurator linearScaleConfigurator = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;

            linearScaleConfigurator.RoundToTickMin = LeftAxisRoundToTickCheckBox.Checked;
            linearScaleConfigurator.RoundToTickMax = LeftAxisRoundToTickCheckBox.Checked;

            // 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);
            linearScaleConfigurator.StripStyles.Add(stripStyle);

            // hide the depth axis
            chart.Axis(StandardAxis.Depth).Visible = false;

            // setup point series
            NPointSeries point = (NPointSeries)chart.Series.Add(SeriesType.Point);

            point.Name          = "Point Series";
            point.Legend.Format = "<label>";
            point.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(7);
            point.PointShape     = (PointShape)PointShapeDropDownList.SelectedIndex;
            point.Size           = new NLength((float)PointSizeDropDownList.SelectedIndex, NRelativeUnit.ParentPercentage);
            point.InflateMargins = InflateMarginsCheckBox.Checked;

            point.AddDataPoint(new NDataPoint(23, "A"));
            point.AddDataPoint(new NDataPoint(67, "B"));
            point.AddDataPoint(new NDataPoint(47, "C"));
            point.AddDataPoint(new NDataPoint(12, "D"));
            point.AddDataPoint(new NDataPoint(56, "E"));
            point.AddDataPoint(new NDataPoint(78, "F"));

            // apply layout
            ApplyLayoutTemplate(0, nChartControl1, chart, title, null);

            if (DifferentColorsCheckBox.Checked)
            {
                PointColorDropDownList.Enabled = false;

                NChartPalette palette = new NChartPalette();
                palette.SetPredefinedPalette(ChartPredefinedPalette.Nevron);

                for (int i = 0; i < point.Values.Count; i++)
                {
                    point.FillStyles[i] = new NColorFillStyle(palette.SeriesColors[i % palette.SeriesColors.Count]);
                }

                point.Legend.Mode = SeriesLegendMode.DataPoints;
            }
            else
            {
                PointColorDropDownList.Enabled = true;
                point.FillStyles.Clear();
                point.FillStyle   = new NColorFillStyle(WebExamplesUtilities.ColorFromDropDownList(PointColorDropDownList));
                point.Legend.Mode = SeriesLegendMode.Series;
            }

            if (ShowDataLabelsCheckBox.Checked)
            {
                point.DataLabelStyle.Visible        = true;
                DataLabelFormatDropDownList.Enabled = true;

                switch (DataLabelFormatDropDownList.SelectedIndex)
                {
                case 0:
                    point.DataLabelStyle.Format = "<value> <label>";
                    break;

                case 1:
                    point.DataLabelStyle.Format = "<value>";
                    break;

                case 2:
                    point.DataLabelStyle.Format = "<label>";
                    break;
                }
            }
            else
            {
                point.DataLabelStyle.Visible        = false;
                DataLabelFormatDropDownList.Enabled = false;
            }
        }