protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel header = new NLabel("Axis Ruler Caps<br/> <font size = '9pt'>Demonstrates how to change the caps of the axis ruler</font>");

            header.DockMode                              = PanelDockMode.Top;
            header.TextStyle.FontStyle                   = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            header.TextStyle.ShadowStyle.Type            = ShadowType.LinearBlur;
            header.TextStyle.TextFormat                  = TextFormat.XML;
            header.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Left;
            header.FitAlignment                          = ContentAlignment.MiddleLeft;
            header.Margins = new NMarginsL(5, 0, 0, 5);

            nChartControl1.Panels.Add(header);

            NCartesianChart chart = new NCartesianChart();

            chart.DockMode   = PanelDockMode.Fill;
            chart.BoundsMode = BoundsMode.Stretch;
            chart.Margins    = new NMarginsL(5, 10, 10, 5);
            nChartControl1.Panels.Add(chart);

            Random random = new Random();

            // feed some random data
            NPointSeries point = new NPointSeries();

            point.DataLabelStyle.Visible = false;
            point.UseXValues             = true;
            point.Size = new NLength(5);
            point.BorderStyle.Width = new NLength(0);

            // fill in some random data
            for (int j = 0; j < 30; j++)
            {
                point.Values.Add(5 + random.Next(90));
                point.XValues.Add(5 + random.Next(90));
            }

            chart.Series.Add(point);

            // configure scales
            NLinearScaleConfigurator xScale = new NLinearScaleConfigurator();

            xScale.RoundToTickMax = true;
            xScale.RoundToTickMin = true;
            xScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            xScale.ScaleBreaks.Add(new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Orange)), null, new NLength(10)), new NRange1DD(29, 41)));

            // add an interlaced strip to the X axis
            NScaleStripStyle xInterlacedStrip = new NScaleStripStyle();

            xInterlacedStrip.SetShowAtWall(ChartWallType.Back, true);
            xInterlacedStrip.Interlaced = true;
            xInterlacedStrip.FillStyle  = new NColorFillStyle(Color.FromArgb(40, Color.LightGray));
            xScale.StripStyles.Add(xInterlacedStrip);

            NCartesianAxis xAxis = (NCartesianAxis)chart.Axis(StandardAxis.PrimaryX);

            xAxis.ScaleConfigurator = xScale;
            xAxis.View = new NRangeAxisView(new NRange1DD(0, 100));

            NDockAxisAnchor xAxisAnchor = new NDockAxisAnchor(AxisDockZone.FrontBottom);

            xAxisAnchor.BeforeSpace = new NLength(10);
            xAxis.Anchor            = xAxisAnchor;

            NLinearScaleConfigurator yScale = new NLinearScaleConfigurator();

            yScale.RoundToTickMax = true;
            yScale.RoundToTickMin = true;
            yScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            yScale.ScaleBreaks.Add(new NCustomScaleBreak(new NLineScaleBreakStyle(new NColorFillStyle(Color.FromArgb(124, Color.Orange)), null, new NLength(10)), new NRange1DD(29, 41)));

            // add an interlaced strip to the Y axis
            NScaleStripStyle yInterlacedStrip = new NScaleStripStyle();

            yInterlacedStrip.SetShowAtWall(ChartWallType.Back, true);
            yInterlacedStrip.Interlaced = true;
            yInterlacedStrip.FillStyle  = new NColorFillStyle(Color.FromArgb(40, Color.LightGray));
            yScale.StripStyles.Add(yInterlacedStrip);

            NCartesianAxis yAxis = (NCartesianAxis)chart.Axis(StandardAxis.PrimaryY);

            yAxis.ScaleConfigurator = yScale;
            yAxis.View = new NRangeAxisView(new NRange1DD(0, 100));

            NDockAxisAnchor yAxisAnchor = new NDockAxisAnchor(AxisDockZone.FrontLeft);

            yAxisAnchor.BeforeSpace = new NLength(10);
            yAxis.Anchor            = yAxisAnchor;

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);

            styleSheet.Apply(nChartControl1.Document);

            // update form controls
            if (!IsPostBack)
            {
                PaintOnScaleBreaksCheckBox.Checked = false;

                WebExamplesUtilities.FillComboWithEnumValues(BeginCapStyleDropDownList, typeof(CapStyle));
                BeginCapStyleDropDownList.SelectedIndex = (int)CapStyle.Ellipse;

                WebExamplesUtilities.FillComboWithEnumValues(ScaleBreakCapStyleDropDownList, typeof(CapStyle));
                ScaleBreakCapStyleDropDownList.SelectedIndex = (int)CapStyle.LeftCrossLine;

                WebExamplesUtilities.FillComboWithEnumValues(EndCapStyleDropDownList, typeof(CapStyle));
                EndCapStyleDropDownList.SelectedIndex = (int)CapStyle.Arrow;
            }

            UpdateRulerStyleForAxis(xAxis);
            UpdateRulerStyleForAxis(yAxis);
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Axis Reference Lines";

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

            chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear);

            // configure the y scale
            NLinearScale yScale = (NLinearScale)chart.Axes[ENCartesianAxis.PrimaryY].Scale;

            NScaleStrip stripStyle = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);

            stripStyle.Interlaced = true;
            yScale.Strips.Add(stripStyle);

            yScale.MajorGridLines.Visible = true;

            // Create a point series
            NPointSeries point = new NPointSeries();

            point.InflateMargins = true;
            point.UseXValues     = true;
            point.Name           = "Series 1";
            chart.Series.Add(point);

            NDataLabelStyle dataLabelStyle = new NDataLabelStyle();

            dataLabelStyle.Visible = false;
            point.DataLabelStyle   = dataLabelStyle;

            // Add some data
            double[] yValues = new double[] { 31, 67, 12, 84, 90 };
            double[] xValues = new double[] { 5, 36, 51, 76, 93 };

            for (int i = 0; i < yValues.Length; i++)
            {
                point.DataPoints.Add(new NPointDataPoint(xValues[i], yValues[i]));
            }

            // Add a constline for the left axis
            m_XReferenceLine        = new NAxisReferenceLine();
            m_XReferenceLine.Stroke = new NStroke(1, NColor.SteelBlue);
            m_XReferenceLine.Value  = 40;
            m_XReferenceLine.Text   = "X Reference Line";
            chart.Axes[ENCartesianAxis.PrimaryX].ReferenceLines.Add(m_XReferenceLine);

            // Add a constline for the bottom axis
            m_YReferenceLine        = new NAxisReferenceLine();
            m_YReferenceLine.Stroke = new NStroke(1, NColor.SteelBlue);
            m_YReferenceLine.Value  = 60;
            m_YReferenceLine.Text   = "Y Reference Line";
            chart.Axes[ENCartesianAxis.PrimaryY].ReferenceLines.Add(m_YReferenceLine);

            // apply style sheet
            chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, false));

            return(chartView);
        }
示例#3
0
        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;
        }
示例#4
0
        public override void Initialize()
        {
            base.Initialize();

            // set a chart title
            NLabel title = new NLabel("Gantt Chart");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);

            // no legend
            nChartControl1.Legends.Clear();

            // configure the chart
            NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

            chart.BoundsMode = BoundsMode.Stretch;
            chart.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft);
            chart.Axis(StandardAxis.Depth).Visible = false;

            // setup the value axis
            NRangeTimelineScaleConfigurator dateTimeScale = new NRangeTimelineScaleConfigurator();

            dateTimeScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back };

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

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

            chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = dateTimeScale;
            chart.Axis(StandardAxis.PrimaryY).Anchor            = new NDockAxisAnchor(AxisDockZone.FrontRight, true, 0, 100);

            // fill data
            DateTime start = DateTime.Now;
            DateTime end   = start + new TimeSpan(10, 0, 0, 0);

            TaskCollection tasks = new TaskCollection();

            tasks.Add(new Task("Write Proposal",
                               new DateTime(2001, 4, 1),
                               new DateTime(2001, 4, 5),
                               new uint[] { 1, 2 }));

            tasks.Add(new Task("Obtain Approval",
                               new DateTime(2001, 4, 12),
                               new DateTime(2001, 9, 4),
                               new uint[] { 9 }));

            tasks.Add(new Task("Requirements Analysis",
                               new DateTime(2001, 4, 9),
                               new DateTime(2001, 5, 5),
                               new uint[] { 3 }));

            tasks.Add(new Task("Design Phase",
                               new DateTime(2001, 5, 6),
                               new DateTime(2001, 5, 30),
                               new uint[] { 4 }));

            tasks.Add(new Task("Design Signoff",
                               new DateTime(2001, 6, 2),
                               new DateTime(2001, 6, 2),
                               new uint[] { 5 }));

            tasks.Add(new Task("Alpha Implementation",
                               new DateTime(2001, 6, 3),
                               new DateTime(2001, 7, 31),
                               new uint[] { 6 }));

            tasks.Add(new Task("Design Review",
                               new DateTime(2001, 8, 1),
                               new DateTime(2001, 8, 8),
                               new uint[] { 7 }));

            tasks.Add(new Task("Revised Design Signoff",
                               new DateTime(2001, 8, 10),
                               new DateTime(2001, 8, 10),
                               new uint[] { 8 }));

            tasks.Add(new Task("Beta Implementation",
                               new DateTime(2001, 8, 12),
                               new DateTime(2001, 9, 12),
                               new uint[] { 9 }));

            tasks.Add(new Task("Testing",
                               new DateTime(2001, 9, 13),
                               new DateTime(2001, 10, 31),
                               new uint[] { 10 }));

            tasks.Add(new Task("Final Implementation",
                               new DateTime(2001, 11, 1),
                               new DateTime(2001, 11, 15),
                               new uint[] { 11 }));

            tasks.Add(new Task("Signoff",
                               new DateTime(2001, 11, 28),
                               new DateTime(2001, 11, 30),
                               new uint[] { 12 }));

            tasks.ConfigureChart(chart);

            // apply layout
            ConfigureStandardLayout(chart, title, null);

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor);

            styleSheet.Apply(nChartControl1.Document);

            nChartControl1.Controller.Tools.Add(new NPanelSelectorTool());
            nChartControl1.Controller.Tools.Add(new NFloatBarDragPointTool());

            // init form controls
            ShowGanttConnectorLinesCheckBox.Checked = true;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            NThinChartControl1.StateId = "Chart1";

            if (!NThinChartControl1.Initialized)
            {
                // enable jittering (full scene antialiasing)
                NThinChartControl1.Settings.JitterMode            = JitterMode.Enabled;
                NThinChartControl1.ServerSettings.EnableTiledZoom = true;
                NThinChartControl1.Panels.Clear();

                // apply background image border
                NImageFrameStyle frame = new NImageFrameStyle();
                frame.Type              = ImageFrameType.Raised;
                frame.BackgroundColor   = Color.White;
                frame.BorderStyle.Color = Color.Gainsboro;
                NThinChartControl1.BackgroundStyle.FrameStyle = frame;
                NThinChartControl1.BackgroundStyle.FillStyle  = new NGradientFillStyle(Color.White, Color.GhostWhite);

                // set a chart title
                NLabel title = new NLabel("Toolbar Configuration");
                NThinChartControl1.Panels.Add(title);
                title.DockMode                   = PanelDockMode.Top;
                title.Padding                    = new NMarginsL(4, 6, 4, 6);
                title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
                title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;

                // configure the legend
                NLegend legend = new NLegend();
                NThinChartControl1.Panels.Add(legend);
                legend.DockMode = PanelDockMode.Right;
                legend.Padding  = new NMarginsL(1, 1, 3, 3);
                legend.FillStyle.SetTransparencyPercent(50);
                legend.OuterBottomBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel);
                legend.OuterLeftBorderStyle.Width   = new NLength(0, NGraphicsUnit.Pixel);
                legend.OuterRightBorderStyle.Width  = new NLength(0, NGraphicsUnit.Pixel);
                legend.OuterTopBorderStyle.Width    = new NLength(0, NGraphicsUnit.Pixel);
                legend.HorizontalBorderStyle.Width  = new NLength(0, NGraphicsUnit.Pixel);
                legend.VerticalBorderStyle.Width    = new NLength(0, NGraphicsUnit.Pixel);

                // configure the chart
                NCartesianChart chart = new NCartesianChart();
                NThinChartControl1.Panels.Add(chart);
                chart.Enable3D         = true;
                chart.Fit3DAxisContent = true;
                chart.DisplayOnLegend  = legend;
                chart.BoundsMode       = BoundsMode.Fit;
                chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft);
                chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1);
                chart.DockMode = PanelDockMode.Fill;
                chart.Padding  = new NMarginsL(
                    new NLength(3, NRelativeUnit.ParentPercentage),
                    new NLength(3, NRelativeUnit.ParentPercentage),
                    new NLength(3, NRelativeUnit.ParentPercentage),
                    new NLength(3, NRelativeUnit.ParentPercentage));
                chart.Wall(ChartWallType.Back).FillStyle = new NGradientFillStyle(Color.White, Color.Gray);

                // setup the X axis
                NAxis axisX = chart.Axis(StandardAxis.PrimaryX);
                axisX.ScrollBar.Visible = true;
                NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)axisX.ScaleConfigurator;
                scaleX.MajorTickMode = MajorTickMode.AutoMaxCount;
                scaleX.AutoLabels    = false;

                // add interlaced stripe for the Y axis
                NAxis axisY = chart.Axis(StandardAxis.PrimaryY);
                axisY.ScrollBar.Visible = true;
                NLinearScaleConfigurator scaleY     = (NLinearScaleConfigurator)axisY.ScaleConfigurator;
                NScaleStripStyle         stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1);
                stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left };
                scaleY.StripStyles.Add(stripStyle);

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

                // add a bar series and fill it with data
                NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);
                bar.Name        = "Simple Bar Chart";
                bar.BarShape    = BarShape.SmoothEdgeBar;
                bar.Legend.Mode = SeriesLegendMode.DataPoints;
                bar.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point);
                bar.DataLabelStyle.Visible            = false;

                AddDataPoint(scaleX, bar, 16, "Spain", @"http://en.wikipedia.org/wiki/Spain");
                AddDataPoint(scaleX, bar, 42, "France", @"http://en.wikipedia.org/wiki/France");
                AddDataPoint(scaleX, bar, 56, "Germany", @"http://en.wikipedia.org/wiki/Germany");
                AddDataPoint(scaleX, bar, 23, "Italy", @"http://en.wikipedia.org/wiki/Italy");
                AddDataPoint(scaleX, bar, 47, "UK", @"http://en.wikipedia.org/wiki/UK");
                AddDataPoint(scaleX, bar, 38, "Sweden", @"http://en.wikipedia.org/wiki/Sweden");

                // add the index of the bar to highlight
                NThinChartControl1.CustomData = 0;

                // apply style sheet
                NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor);
                styleSheet.Apply(bar);

                // configure toolbar
                NThinChartControl1.Toolbar.Visible = true;
                NThinChartControl1.Controller.SetActivePanel(chart);

                NThinChartControl1.AutoUpdateCallback = new NAutoUpdateCallback();

                //NThinChartControl1.Controller.EnableAutoUpdate = true;
                NTrackballTool tbt = new NTrackballTool();
                tbt.Exclusive = true;
                tbt.Enabled   = true;
                NThinChartControl1.Controller.Tools.Add(tbt);

                // add a data zoom tool
                NDataZoomTool dataZoomTool = new NDataZoomTool();
                dataZoomTool.Exclusive = true;
                dataZoomTool.Enabled   = false;
                NThinChartControl1.Controller.Tools.Add(dataZoomTool);

                // add a data pan tool
                NDataPanTool dataPanTool = new NDataPanTool();
                dataPanTool.Exclusive = true;
                dataPanTool.Enabled   = false;
                NThinChartControl1.Controller.Tools.Add(dataPanTool);

                // add a tooltip tool
                NThinChartControl1.Controller.Tools.Add(new NTooltipTool());
                // add a cursor change tool
                NThinChartControl1.Controller.Tools.Add(new NCursorTool());
                // add a browser redirect tool
                NThinChartControl1.Controller.Tools.Add(new NBrowserRedirectTool());

                NThinChartControl1.Toolbar.Visible = true;
                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NSaveStateAction()));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NSaveImageAction("Save as PDF", new NPdfImageFormat(), true, new NSize(), 300)));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NSaveImageAction("Save as SVG", new NSvgImageFormat(), true, new NSize(), 96)));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NSaveImageAction("Save as XAML", new NXamlImageFormat(), true, new NSize(), 96)));

                NSaveImageAction sia = new NSaveImageAction("Bitmap.bmp", new NBitmapImageFormat(), true, new NSize(), 96);
                sia.Tooltip = "Print or Save as Bitmap";
                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(sia));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarSeparator());

                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NTogglePanelSelectorToolAction()));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleDataZoomToolAction()));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleDataPanToolAction()));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleTrackballToolAction()));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarSeparator());

                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleAutoUpdateAction()));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleChart3DAction()));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleChartLightingAction()));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarSeparator());

                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleTooltipToolAction()));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleBrowserRedirectToolAction()));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleCursorToolAction()));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarSeparator());

                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new ShowDataLabelsAction()));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new HideDataLabelsAction()));

                NThinChartControl1.CustomRequestCallback = new CustomRequestCallback();
            }
        }
        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;
        }
示例#7
0
        public override void Initialize()
        {
            base.Initialize();

            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel title = new NLabel("Animation Themes");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            title.DockMode            = PanelDockMode.Top;
            title.Margins             = new NMarginsL(0, 10, 0, 0);
            nChartControl1.Panels.Add(title);

            NDockPanel contentPanel = new NDockPanel();

            nChartControl1.Panels.Add(contentPanel);

            contentPanel.DockMode = PanelDockMode.Fill;

            // configure the chart
            NCartesianChart chart = new NCartesianChart();

            contentPanel.ChildPanels.Add(chart);
            chart.Location = new NPointL(0, 0);
            chart.Size     = new NSizeL(new NLength(100, NRelativeUnit.ParentPercentage),
                                        new NLength(60, NRelativeUnit.ParentPercentage));
            chart.Enable3D = false;
            chart.Axis(StandardAxis.Depth).Visible = false;
            chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1);
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.BrightCameraLight);
            chart.Margins    = new NMarginsL(10, 10, 10, 10);
            chart.BoundsMode = BoundsMode.Stretch;
            chart.DockMode   = PanelDockMode.Top;

            // configure the legend
            NLegend legend = new NLegend();

            chart.ChildPanels.Add(legend);
            chart.DisplayOnLegend = legend;
            chart.PositionChildPanelsInContentBounds = true;
            legend.DockMode     = PanelDockMode.Top;
            legend.FitAlignment = ContentAlignment.BottomRight;
            legend.Location     = new NPointL(new NLength(100, NRelativeUnit.ParentPercentage), new NLength(0));
            legend.Margins      = new NMarginsL(0, 5, 5, 0);
            legend.OuterLeftBorderStyle.Width   = new NLength(0);
            legend.OuterRightBorderStyle.Width  = new NLength(0);
            legend.OuterTopBorderStyle.Width    = new NLength(0);
            legend.OuterBottomBorderStyle.Width = new NLength(0);
            legend.VerticalBorderStyle.Width    = new NLength(0);
            legend.FillStyle.SetTransparencyPercent(50);

            // configure axes
            NOrdinalScaleConfigurator ordinalScale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator;

            ordinalScale.AutoLabels = false;
            ordinalScale.Labels.Add("2004");
            ordinalScale.Labels.Add("2005");
            ordinalScale.Labels.Add("2006");
            ordinalScale.Labels.Add("2007");
            ordinalScale.Labels.Add("2008");
            ordinalScale.Labels.Add("2009");

            // add interlace stripe
            NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;

            linearScale.Title.Text = "Sales in Thousands USD";
            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);

            NDockPanel gaugesPanel = new NDockPanel();

            gaugesPanel.DockMode = PanelDockMode.Fill;
            gaugesPanel.Margins  = new NMarginsL(20, 0, 10, 0);
            gaugesPanel.PositionChildPanelsInContentBounds = true;
            contentPanel.ChildPanels.Add(gaugesPanel);

            string[] companyNames = new string[] { "Company A", "Company B", "Company C" };

            for (int i = 0; i < 3; i++)
            {
                NDockPanel gaugeContainer = new NDockPanel();
                gaugeContainer.Location = new NPointL(new NLength(i * 35, NRelativeUnit.ParentPercentage),
                                                      new NLength(0));
                gaugeContainer.Size = new NSizeL(new NLength(30, NRelativeUnit.ParentPercentage),
                                                 new NLength(100, NRelativeUnit.ParentPercentage));

                gaugeContainer.ChildPanels.Add(CreateGaugeLabel(companyNames[i]));
                gaugeContainer.ChildPanels.Add(CreateGauge());

                gaugesPanel.ChildPanels.Add(gaugeContainer);
            }

            // init form controls
            ChartTypeCombo.Items.Add("Bar");
            ChartTypeCombo.Items.Add("Line");
            ChartTypeCombo.Items.Add("Area");
            ChartTypeCombo.SelectedIndex = 0;

            AggregationComboBox.Items.Add("None");
            AggregationComboBox.Items.Add("Stacked");
            AggregationComboBox.Items.Add("Clustered");
            AggregationComboBox.SelectedIndex = 1;

            AnimationThemeTypeComboBox.FillFromEnum(typeof(AnimationThemeType));
            AnimationThemeTypeComboBox.SelectedIndex = (int)AnimationThemeType.ScaleAndFade;

            AxesAnimationDurationUpDown.Value       = (decimal)3;
            WallsAnimationDurationUpDown.Value      = (decimal)3;
            SeriesAnimationDurationUpDown.Value     = (decimal)3;
            IndicatorsAnimationDurationUpDown.Value = (decimal)3;

            GenerateNewDataButton_Click(null, null);

            CalculateIndicatorValues();
        }
示例#8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ExcelFormatDropDown.Items.Add("XLS");
                ExcelFormatDropDown.Items.Add("XLSX");
            }


            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Import from Excel File");

            title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
            title.ContentAlignment           = ContentAlignment.BottomRight;
            title.Location = new NPointL(
                new NLength(2, NRelativeUnit.ParentPercentage),
                new NLength(2, NRelativeUnit.ParentPercentage));

            NCartesianChart chart = new NCartesianChart();

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

            bar0.Legend.Mode = SeriesLegendMode.DataPoints;
            NBarSeries bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar);

            bar1.Legend.Mode  = SeriesLegendMode.DataPoints;
            bar1.MultiBarMode = MultiBarMode.Clustered;

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

            string fileName;

            if (ExcelFormatDropDown.SelectedIndex == 0)
            {
                // Import from XLS
                fileName = this.MapPathSecure(this.TemplateSourceDirectory + "\\Sample.xls");
            }
            else
            {
                // Import from XLSX
                fileName = this.MapPathSecure(this.TemplateSourceDirectory + "\\Sample.xlsx");
            }

            try
            {
                NExcelReader reader = new NExcelReader();
                DataTable    dt;

                if (ImportFromRangeCheckBox.Checked)
                {
                    // Import range
                    dt = reader.ReadRange(fileName, "Sample", "A1:E3").Tables[0];
                }
                else
                {
                    // Import whole sheet
                    dt = reader.ReadAll(fileName).Tables[0];
                }

                DataColumnCollection columns = dt.Columns;
                nChartControl1.DataBindingManager.AddBinding(0, 0, "Values", dt, columns[1].ColumnName);
                nChartControl1.DataBindingManager.AddBinding(0, 0, "Labels", dt, columns[0].ColumnName);
                nChartControl1.DataBindingManager.AddBinding(0, 0, "FillStyles", dt, columns[3].ColumnName);

                nChartControl1.DataBindingManager.AddBinding(0, 1, "Values", dt, columns[2].ColumnName);
                nChartControl1.DataBindingManager.AddBinding(0, 1, "Labels", dt, columns[0].ColumnName);
                nChartControl1.DataBindingManager.AddBinding(0, 1, "FillStyles", dt, columns[4].ColumnName);
            }
            catch (Exception)
            {
            }
        }
示例#9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!NThinChartControl1.Initialized)
            {
                // enable jittering (full scene antialiasing)
                NThinChartControl1.Settings.JitterMode = JitterMode.Enabled;
                NThinChartControl1.Panels.Clear();

                // apply background image border
                NImageFrameStyle frame = new NImageFrameStyle();
                frame.Type              = ImageFrameType.Raised;
                frame.BackgroundColor   = Color.White;
                frame.BorderStyle.Color = Color.Gainsboro;
                NThinChartControl1.BackgroundStyle.FrameStyle = frame;
                NThinChartControl1.BackgroundStyle.FillStyle  = new NGradientFillStyle(Color.White, Color.GhostWhite);

                // set a chart title
                NLabel title = new NLabel("Postback Tool");
                NThinChartControl1.Panels.Add(title);
                title.DockMode                   = PanelDockMode.Top;
                title.Padding                    = new NMarginsL(4, 6, 4, 6);
                title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
                title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;

                // configure the legend
                NLegend legend = new NLegend();
                NThinChartControl1.Panels.Add(legend);
                legend.DockMode = PanelDockMode.Right;
                legend.Padding  = new NMarginsL(1, 1, 3, 3);
                legend.FillStyle.SetTransparencyPercent(50);
                legend.OuterBottomBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel);
                legend.OuterLeftBorderStyle.Width   = new NLength(0, NGraphicsUnit.Pixel);
                legend.OuterRightBorderStyle.Width  = new NLength(0, NGraphicsUnit.Pixel);
                legend.OuterTopBorderStyle.Width    = new NLength(0, NGraphicsUnit.Pixel);
                legend.HorizontalBorderStyle.Width  = new NLength(0, NGraphicsUnit.Pixel);
                legend.VerticalBorderStyle.Width    = new NLength(0, NGraphicsUnit.Pixel);

                // configure the chart
                NCartesianChart chart = new NCartesianChart();
                NThinChartControl1.Panels.Add(chart);
                chart.Enable3D         = true;
                chart.Fit3DAxisContent = true;
                chart.DisplayOnLegend  = legend;
                chart.BoundsMode       = BoundsMode.Fit;
                chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft);
                chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1);
                chart.DockMode = PanelDockMode.Fill;
                chart.Padding  = new NMarginsL(
                    new NLength(3, NRelativeUnit.ParentPercentage),
                    new NLength(3, NRelativeUnit.ParentPercentage),
                    new NLength(3, NRelativeUnit.ParentPercentage),
                    new NLength(3, NRelativeUnit.ParentPercentage));

                // setup the X axis
                NAxis axisX = chart.Axis(StandardAxis.PrimaryX);
                NOrdinalScaleConfigurator scaleX = (NOrdinalScaleConfigurator)axisX.ScaleConfigurator;
                scaleX.MajorTickMode = MajorTickMode.AutoMaxCount;

                // add interlaced stripe for the Y axis
                NAxis axisY = chart.Axis(StandardAxis.PrimaryY);
                NLinearScaleConfigurator scaleY     = (NLinearScaleConfigurator)axisY.ScaleConfigurator;
                NScaleStripStyle         stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1);
                stripStyle.Interlaced  = true;
                stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back, ChartWallType.Left };
                scaleY.StripStyles.Add(stripStyle);

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

                // add a bar series and fill it with data
                NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);
                bar.Name        = "Simple Bar Chart";
                bar.BarShape    = BarShape.SmoothEdgeBar;
                bar.Legend.Mode = SeriesLegendMode.DataPoints;
                bar.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point);
                bar.DataLabelStyle.Visible            = false;

                bar.AddDataPoint(new NDataPoint(16, "Spain"));
                bar.AddDataPoint(new NDataPoint(42, "France"));
                bar.AddDataPoint(new NDataPoint(56, "Germany"));
                bar.AddDataPoint(new NDataPoint(23, "Italy"));
                bar.AddDataPoint(new NDataPoint(47, "UK"));
                bar.AddDataPoint(new NDataPoint(38, "Sweden"));

                for (int i = 0; i < bar.Values.Count; i++)
                {
                    bar.InteractivityStyles[i] = new NInteractivityStyle("Click on bar to make it red");
                }

                // apply style sheet
                NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor);
                styleSheet.Apply(bar);

                NThinChartControl1.Controller.Tools.Add(new NPostbackTool());
            }

            NThinChartControl1.Postback += new NPostbackEventHandler(NThinChartControl1_Postback);
            NThinChartControl1.Controller.Tools.Clear();

            NTooltipTool tooltipTool = new NTooltipTool();

            NThinChartControl1.Controller.Tools.Add(tooltipTool);

            NPostbackTool postbackTool = new NPostbackTool();

            postbackTool.PostbackOnlyOnInteractiveItems = PostbackOnlyOnInteractiveItemsCheckBox.Checked;
            NThinChartControl1.Controller.Tools.Add(postbackTool);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel title = new NLabel("Chart Aspect 2D");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.DockMode            = PanelDockMode.Top;
            title.Margins             = new NMarginsL(10, 10, 10, 0);
            nChartControl1.Panels.Add(title);

            NCartesianChart chart = new NCartesianChart();

            nChartControl1.Panels.Add(chart);

            chart.DockMode      = PanelDockMode.Fill;
            chart.Margins       = new NMarginsL(30, 10, 10, 30);
            chart.Padding       = new NMarginsL(0);
            chart.BoundsMode    = BoundsMode.Stretch;
            chart.UsePlotAspect = true;
            chart.Width         = chart.Height = 50;

            // switch all axes to linear mode
            NLinearScaleConfigurator xScale = new NLinearScaleConfigurator();

            xScale.Title.Text = "X Scale Title";
            xScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            xScale.LabelStyle.KeepInsideRuler = true;
            xScale.LabelStyle.Angle           = new NScaleLabelAngle(ScaleLabelAngleMode.View, 90, false);
            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = xScale;

            NLinearScaleConfigurator yScale = new NLinearScaleConfigurator();

            yScale.Title.Text = "Y Scale Title";
            yScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            yScale.LabelStyle.KeepInsideRuler = true;
            chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = yScale;

            chart.Axis(StandardAxis.SecondaryX).ScaleConfigurator = new NLinearScaleConfigurator();
            chart.Axis(StandardAxis.SecondaryY).ScaleConfigurator = new NLinearScaleConfigurator();

            // cross secondary X and Y axes
            chart.Axis(StandardAxis.SecondaryX).Anchor = new NCrossAxisAnchor(AxisOrientation.Horizontal, new NValueAxisCrossing(chart.Axis(StandardAxis.PrimaryY), 0));
            chart.Axis(StandardAxis.SecondaryY).Anchor = new NCrossAxisAnchor(AxisOrientation.Vertical, new NValueAxisCrossing(chart.Axis(StandardAxis.PrimaryX), 0));

            // show secondary axes
            chart.Axis(StandardAxis.SecondaryX).Visible = true;
            chart.Axis(StandardAxis.SecondaryY).Visible = true;

            // turn off labels for cross axes
            NLinearScaleConfigurator secondaryScaleX = chart.Axis(StandardAxis.SecondaryX).ScaleConfigurator as NLinearScaleConfigurator;

            secondaryScaleX.AutoLabels = false;

            NLinearScaleConfigurator secondaryScaleY = chart.Axis(StandardAxis.SecondaryY).ScaleConfigurator as NLinearScaleConfigurator;

            secondaryScaleY.AutoLabels = false;

            // add some dummy data
            NPointSeries point = new NPointSeries();

            chart.Series.Add(point);
            point.DataLabelStyle.Visible = false;
            point.UseXValues             = true;

            point.DisplayOnAxis((int)StandardAxis.SecondaryX, true);
            point.DisplayOnAxis((int)StandardAxis.SecondaryY, true);
            point.Size = new NLength(1);
            point.BorderStyle.Width = new NLength(0);
            point.ClusterMode       = ClusterMode.Enabled;

            // add some random data in the range [-100, 100]
            Random rand = new Random();

            for (int i = 0; i < 3000; i++)
            {
                point.Values.Add(rand.Next(200) - 100);
                point.XValues.Add(rand.Next(200) - 100);
            }


            if (!IsPostBack)
            {
                // init form controls
                WebExamplesUtilities.FillComboWithValues(XProportionDropDownList, 1, 5, 1);
                XProportionDropDownList.SelectedIndex = 0;

                WebExamplesUtilities.FillComboWithValues(YProportionDropDownList, 1, 5, 1);
                YProportionDropDownList.SelectedIndex = 0;

                FitAxisContentCheckBox.Checked  = true;
                UsePlotAspectCheckBox.Checked   = true;
                ShowContentAreaCheckBox.Checked = false;
            }

            chart.Width            = (XProportionDropDownList.SelectedIndex + 1) * 10;
            chart.Height           = (YProportionDropDownList.SelectedIndex + 1) * 10;
            chart.UsePlotAspect    = UsePlotAspectCheckBox.Checked;
            chart.Fit2DAxisContent = FitAxisContentCheckBox.Checked;

            UsePlotAspectCheckBox.Enabled = FitAxisContentCheckBox.Checked;
            bool enableProportion = UsePlotAspectCheckBox.Checked && !FitAxisContentCheckBox.Checked;

            XProportionDropDownList.Enabled = enableProportion;
            YProportionDropDownList.Enabled = enableProportion;

            if (ShowContentAreaCheckBox.Checked)
            {
                chart.BorderStyle = new NStrokeBorderStyle();
            }
            else
            {
                chart.BorderStyle = null;
            }
        }
示例#11
0
        public void InitNChart(ref NChartControl ncc, out NCartesianChart chart)
        {
            // 2D line chart
            ncc.Settings.RenderDevice = RenderDevice.GDI;

            // Add tools to chart controller
            ncc.Controller.Tools.Add(new NSelectorTool());
            ncc.Controller.Tools.Add(new NDataZoomTool());
            //ncc.Controller.Tools.Add(new NDataPanTool());
            ncc.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(OnChartMouseDoubleClick);
            ncc.MouseMove += new System.Windows.Forms.MouseEventHandler(OnChartMouseMove);

            chart = (NCartesianChart)ncc.Charts[0];

            // Set range selections property
            NRangeSelection rangeSelection = new NRangeSelection();

            // Reset Axis when zoom out
            rangeSelection.ZoomOutResetsAxis = true;
            chart.RangeSelections.Add(rangeSelection);

            // Set chart axis property
            chart.Axis(StandardAxis.Depth).Visible = false;
            SetMapProperty();
        }
示例#12
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Legend Layout";

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

            chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);

            // add interlace stripe
            NLinearScale linearScale = chart.Axes[ENCartesianAxis.PrimaryY].Scale as NLinearScale;
            NScaleStrip  strip       = new NScaleStrip(new NColorFill(ENNamedColor.Beige), null, true, 0, 0, 1, 1);

            strip.Interlaced = true;
            linearScale.Strips.Add(strip);

            // add a bar series
            NBarSeries bar1 = new NBarSeries();

            bar1.Name            = "Bar1";
            bar1.MultiBarMode    = ENMultiBarMode.Series;
            bar1.LegendView.Mode = ENSeriesLegendMode.DataPoints;
            bar1.DataLabelStyle  = new NDataLabelStyle(false);
            bar1.ValueFormatter  = new NNumericValueFormatter("0.###");
            chart.Series.Add(bar1);

            // add another bar series
            NBarSeries bar2 = new NBarSeries();

            bar2.Name            = "Bar2";
            bar2.MultiBarMode    = ENMultiBarMode.Clustered;
            bar2.LegendView.Mode = ENSeriesLegendMode.DataPoints;
            bar2.DataLabelStyle  = new NDataLabelStyle(false);
            bar2.ValueFormatter  = new NNumericValueFormatter("0.###");
            chart.Series.Add(bar2);

            // add another bar series
            NBarSeries bar3 = new NBarSeries();

            bar3.Name            = "Bar2";
            bar3.MultiBarMode    = ENMultiBarMode.Clustered;
            bar3.LegendView.Mode = ENSeriesLegendMode.DataPoints;
            bar3.DataLabelStyle  = new NDataLabelStyle(false);
            bar3.ValueFormatter  = new NNumericValueFormatter("0.###");
            chart.Series.Add(bar3);

            Random random = new Random();

            for (int i = 0; i < 5; i++)
            {
                bar1.DataPoints.Add(new NBarDataPoint(random.Next(10, 100)));
                bar2.DataPoints.Add(new NBarDataPoint(random.Next(10, 100)));
                bar3.DataPoints.Add(new NBarDataPoint(random.Next(10, 100)));
            }

            chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, false));

            return(chartView);
        }
示例#13
0
        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)
        {
            NStockSeries stock;

            if (!IsPostBack)
            {
                // set a chart title
                nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

                NLabel title = nChartControl1.Labels.AddHeader("Stock Data Grouping");
                title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
                title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;

                // no legend
                nChartControl1.Legends.Clear();

                // setup chart
                NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];
                chart.BoundsMode = BoundsMode.Stretch;

                NRangeSelection rs = new NRangeSelection();
                rs.VerticalValueSnapper = new NAxisRulerMinMaxSnapper();
                chart.RangeSelections.Add(rs);

                // setup X axis
                NValueTimelineScaleConfigurator scaleX = new NValueTimelineScaleConfigurator();
                scaleX.FirstRow.GridStyle.ShowAtWalls   = new ChartWallType[] { ChartWallType.Back };
                scaleX.FirstRow.GridStyle.LineStyle     = new NStrokeStyle(1, Color.FromArgb(225, 225, 225));
                scaleX.FirstRow.UseGridStyle            = true;
                scaleX.FirstRow.InnerTickStyle.Visible  = false;
                scaleX.SecondRow.GridStyle.ShowAtWalls  = new ChartWallType[] { ChartWallType.Back };
                scaleX.SecondRow.GridStyle.LineStyle    = new NStrokeStyle(1, Color.FromArgb(215, 215, 215));
                scaleX.SecondRow.UseGridStyle           = true;
                scaleX.SecondRow.InnerTickStyle.Visible = false;
                scaleX.ThirdRow.GridStyle.ShowAtWalls   = new ChartWallType[] { ChartWallType.Back };
                scaleX.ThirdRow.GridStyle.LineStyle     = new NStrokeStyle(1, Color.FromArgb(205, 205, 205));
                scaleX.ThirdRow.UseGridStyle            = true;
                scaleX.ThirdRow.InnerTickStyle.Visible  = false;

                // calendar
                NWeekDayRule wdr = new NWeekDayRule(WeekDayBit.All);
                wdr.Saturday = false;
                wdr.Sunday   = false;
                scaleX.Calendar.Rules.Add(wdr);
                scaleX.EnableCalendar = true;

                // set configurator
                chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX;
                chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true;

                // setup Y axis
                NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
                scaleY.OuterMajorTickStyle.Length  = new NLength(3, NGraphicsUnit.Point);
                scaleY.InnerMajorTickStyle.Visible = false;

                NFillStyle       stripFill  = new NColorFillStyle(Color.FromArgb(234, 233, 237));
                NScaleStripStyle stripStyle = new NScaleStripStyle(stripFill, null, true, 1, 0, 1, 1);
                stripStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back };
                stripStyle.Interlaced  = true;
                scaleY.StripStyles.Add(stripStyle);

                // setup stock series
                stock = (NStockSeries)chart.Series.Add(SeriesType.Stock);
                stock.DataLabelStyle.Visible   = false;
                stock.UpFillStyle              = new NColorFillStyle(Color.White);
                stock.UpStrokeStyle.Color      = Color.Black;
                stock.DownFillStyle            = new NColorFillStyle(Color.Crimson);
                stock.DownStrokeStyle.Color    = Color.Crimson;
                stock.HighLowStrokeStyle.Color = Color.Black;
                stock.CandleWidth              = new NLength(1.2f, NRelativeUnit.ParentPercentage);
                stock.UseXValues            = true;
                stock.InflateMargins        = true;
                stock.DataLabelStyle.Format = "open - <open>\r\nclose - <close>";

                // add some stock items
                const int numDataPoints = 1000;
                WebExamplesUtilities.GenerateOHLCData(stock, 100.0, numDataPoints, new NRange1DD(60, 140));
                FillStockDates(stock, numDataPoints, DateTime.Now - new TimeSpan((int)(numDataPoints * 1.2), 0, 0, 0));

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

                // update form controls
                CustomDateTimeSpanDropDownList.Items.Add("1 Week");
                CustomDateTimeSpanDropDownList.Items.Add("2 Weeks");
                CustomDateTimeSpanDropDownList.Items.Add("1 Month");
                CustomDateTimeSpanDropDownList.Items.Add("3 Months");

                WebExamplesUtilities.FillComboWithEnumNames(GroupingModeDropDownList, typeof(StockGroupingMode));

                CustomDateTimeSpanDropDownList.SelectedIndex = 2;
                GroupingModeDropDownList.SelectedIndex       = (int)StockGroupingMode.SynchronizeWithMajorTick;

                WebExamplesUtilities.FillComboWithPercents(GroupPercendWidthDropDownList, 10);
                GroupPercendWidthDropDownList.SelectedIndex = 2;

                WebExamplesUtilities.FillComboWithValues(MinGroupDistanceDropDownList, 2, 20, 2);
                MinGroupDistanceDropDownList.SelectedIndex = 2;
            }
            else
            {
                stock = (NStockSeries)nChartControl1.Charts[0].Series[0];
            }

            MinGroupDistanceDropDownList.Enabled   = false;
            CustomDateTimeSpanDropDownList.Enabled = false;
            GroupPercendWidthDropDownList.Enabled  = true;

            switch (GroupingModeDropDownList.SelectedIndex)
            {
            case (int)StockGroupingMode.None:
                stock.GroupingMode = StockGroupingMode.None;
                GroupPercendWidthDropDownList.Enabled = false;
                break;

            case (int)StockGroupingMode.AutoDateTimeSpan:
                stock.GroupingMode = StockGroupingMode.AutoDateTimeSpan;
                MinGroupDistanceDropDownList.Enabled = true;
                break;

            case (int)StockGroupingMode.CustomDateTimeSpan:
                stock.GroupingMode = StockGroupingMode.CustomDateTimeSpan;
                CustomDateTimeSpanDropDownList.Enabled = true;
                break;

            case (int)StockGroupingMode.SynchronizeWithMajorTick:
                stock.GroupingMode = StockGroupingMode.SynchronizeWithMajorTick;
                break;

            default:
                break;
            }

            stock.MinAutoGroupLength = new NLength((float)MinGroupDistanceDropDownList.SelectedIndex * 2 + 2, NGraphicsUnit.Point);

            switch (CustomDateTimeSpanDropDownList.SelectedIndex)
            {
            case 0:                     // 1 Week
                stock.CustomGroupStep = new NDateTimeSpan(1, NDateTimeUnit.Week);
                break;

            case 1:                     // 2 Weeks
                stock.CustomGroupStep = new NDateTimeSpan(2, NDateTimeUnit.Week);
                break;

            case 2:                     // 1 Month
                stock.CustomGroupStep = new NDateTimeSpan(1, NDateTimeUnit.Month);
                break;

            case 3:                     // 3 Months
                stock.CustomGroupStep = new NDateTimeSpan(3, NDateTimeUnit.Month);
                break;
            }

            stock.GroupPercentWidth = (float)GroupPercendWidthDropDownList.SelectedIndex * 10;
        }
示例#15
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Image Export Example";

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

            chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XYLinear);

            // setup X axis
            NLinearScale xScale = (NLinearScale)chart.Axes[ENCartesianAxis.PrimaryX].Scale;

            xScale.MajorGridLines.Visible = true;

            // setup Y axis
            NLinearScale yScale = (NLinearScale)chart.Axes[ENCartesianAxis.PrimaryY].Scale;

            yScale.MajorGridLines.Visible = true;

            // add interlaced stripe
            NScaleStrip strip = new NScaleStrip(new NColorFill(NColor.Beige), null, true, 0, 0, 1, 1);

            strip.Interlaced = true;
            yScale.Strips.Add(strip);

            // setup shape series
            NRangeSeries range = new NRangeSeries();

            chart.Series.Add(range);

            range.DataLabelStyle = new NDataLabelStyle(false);
            range.UseXValues     = true;
            range.Fill           = new NColorFill(NColor.DarkOrange);
            range.Stroke         = new NStroke(NColor.DarkRed);

            // fill data
            double[] intervals = new double[] { 5, 5, 5, 5, 5, 5, 5, 5, 5, 15, 30, 60 };
            double[] values    = new double[] { 4180, 13687, 18618, 19634, 17981, 7190, 16369, 3212, 4122, 9200, 6461, 3435 };

            int    count = Math.Min(intervals.Length, values.Length);
            double x     = 0;

            for (int i = 0; i < count; i++)
            {
                double interval = intervals[i];
                double value    = values[i];

                double x1 = x;
                double y1 = 0;

                x += interval;
                double x2 = x;
                double y2 = value / interval;

                range.DataPoints.Add(new NRangeDataPoint(x1, y1, x2, y2));
            }

            chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, false));

            return(chartView);
        }
        public override void Initialize()
        {
            base.Initialize();

            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Custom Scale Decorations");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            title.SendToBack();
            title.Margins  = new NMarginsL(20, 10, 20, 20);
            title.DockMode = PanelDockMode.Top;

            NCartesianChart chart = new NCartesianChart();

            nChartControl1.Panels.Add(chart);
            chart.BoundsMode          = BoundsMode.Stretch;
            chart.DockMode            = PanelDockMode.Fill;
            chart.Margins             = new NMarginsL(20, 2, 20, 20);
            chart.BackgroundFillStyle = new NColorFillStyle(Color.FromArgb(231, 231, 233));
            chart.MaxDockZoneMargins  = new NMarginsL(100000, 100000, 100000, 100000);

            NStrokeBorderStyle strokeBorder = new NStrokeBorderStyle();

            strokeBorder.StrokeStyle.Color = Color.FromArgb(192, 192, 192);
            chart.BorderStyle = strokeBorder;

            int dpCount = 8;

            double[]     bar1Values = new double[dpCount];
            double[]     bar2Values = new double[dpCount];
            NLabelInfo[] xLabels    = new NLabelInfo[dpCount];

            // add some dummy data
            Random rand = new Random();

            for (int i = 0; i < dpCount; i++)
            {
                bar1Values[i] = rand.Next(100);
                bar2Values[i] = rand.Next(100);
                xLabels[i]    = new NLabelInfo(i, "Label" + i.ToString(), Color.FromArgb(100, 100, 100), i % 2 == 0 ? Color.Red : Color.Orange);
            }

            NLabelInfo[] yLabels = new NLabelInfo[9];
            for (int i = 0; i < 9; i++)
            {
                yLabels[i].Text      = ((i + 1) * 10).ToString() + "%";
                yLabels[i].Value     = (i + 1) * 10;
                yLabels[i].ForeColor = Color.FromArgb(100, 100, 100);
                yLabels[i].BackColor = Color.Transparent;
            }

            // add two bars series in cluster mode
            NBarSeries bar1 = new NBarSeries();

            bar1.Values.AddRange(bar1Values);
            bar1.DataLabelStyle.Visible = false;
            bar1.MultiBarMode           = MultiBarMode.Clustered;
            bar1.FillStyle = new NColorFillStyle(Color.FromArgb(21, 153, 215));
            bar1.FillStyle.ImageFiltersStyle.Filters.Add(new NBevelAndEmbossImageFilter());
            bar1.WidthPercent = 50;
            bar1.GapPercent   = 20;
            chart.Series.Add(bar1);

            NBarSeries bar2 = new NBarSeries();

            bar2.Values.AddRange(bar2Values);
            bar2.DataLabelStyle.Visible = false;
            bar2.MultiBarMode           = MultiBarMode.Clustered;
            bar2.FillStyle = new NColorFillStyle(Color.FromArgb(113, 127, 138));
            bar2.FillStyle.ImageFiltersStyle.Filters.Add(new NBevelAndEmbossImageFilter());
            bar2.WidthPercent = 50;
            bar2.GapPercent   = 20;
            chart.Series.Add(bar2);

            // add custom labels to the x axis
            NLinearScaleConfigurator xScale = new NLinearScaleConfigurator();

            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = xScale;
            chart.Axis(StandardAxis.PrimaryX).View = new NRangeAxisView(new NRange1DD(-0.5, xLabels.Length - 0.5), true, true);
            xScale.LabelStyle.TextStyle.FillStyle  = new NColorFillStyle(Color.FromArgb(100, 100, 100));
            xScale.AutoLabels = false;
            xScale.OuterMajorTickStyle.Visible  = false;
            xScale.InnerMajorTickStyle.Visible  = false;
            xScale.LabelStyle.Offset            = new NLength(10);
            xScale.RulerStyle.BorderStyle.Width = new NLength(0);
            xScale.RulerStyle.Height            = new NLength(0);

            NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.FromArgb(240, 240, 240)), null, true, 0, 0, 1, 1);

            stripStyle.Interlaced = true;
            stripStyle.SetShowAtWall(ChartWallType.Back, true);
            stripStyle.SetShowAtWall(ChartWallType.Left, true);
            xScale.StripStyles.Add(stripStyle);

            // hide the back wall
            chart.Wall(ChartWallType.Back).Visible = false;

            // configure the Y axis
            chart.Axis(StandardAxis.PrimaryY).View = new NRangeAxisView(new NRange1DD(0, 100), true, true);
            NLinearScaleConfigurator yScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;

            yScale.AutoLabels    = false;
            yScale.MajorTickMode = MajorTickMode.CustomTicks;
            yScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            yScale.MajorGridStyle.LineStyle.Color = Color.FromArgb(192, 192, 192);
            yScale.OuterMajorTickStyle.Visible    = false;
            yScale.InnerMajorTickStyle.Visible    = false;
            yScale.RulerStyle.BorderStyle.Width   = new NLength(0);
            yScale.RulerStyle.Height             = new NLength(0);
            yScale.CreateNewLevelForCustomLabels = true;

            // add labels
            NAxis xAxis = chart.Axis(StandardAxis.PrimaryX);
            NAxis yAxis = chart.Axis(StandardAxis.PrimaryY);

            AddLabels(xAxis, true, xLabels);
            AddLabels(yAxis, true, yLabels);

            // create cross
            NCustomWallDecorator xDecorator = new NCustomWallDecorator();

            xDecorator.WallDecorations.Add(new NGridLine(-0.5, new NStrokeStyle(Color.FromArgb(190, 190, 190)), new ChartWallType[] { ChartWallType.Back }, true));
            xAxis.Scale.WallDecorators.Add(xDecorator);

            NCustomWallDecorator yDecorator = new NCustomWallDecorator();

            yDecorator.WallDecorations.Add(new NGridLine(0, new NStrokeStyle(Color.FromArgb(190, 190, 190)), new ChartWallType[] { ChartWallType.Back }, true));
            yAxis.Scale.WallDecorators.Add(yDecorator);
        }
        void SetupChartLayout(string titleText)
        {
            nChartControl1.Panels.Clear();

            NLabel title = new NLabel();
            nChartControl1.Panels.Add(title);
            title.Dock = DockStyle.Top;
            title.Padding = new NMarginsL(5, 8, 5, 4);
            title.Text = titleText;
            title.TextStyle.FontStyle = new NFontStyle("Verdana", 12, FontStyle.Bold | FontStyle.Italic);
            title.TextStyle.FillStyle = new NColorFillStyle(Color.FromArgb(68, 90, 108));

            NLegend legend = new NLegend();
            nChartControl1.Panels.Add(legend);
            legend.Dock = DockStyle.Bottom;
            legend.Data.ExpandMode = LegendExpandMode.ColsOnly;
            legend.Data.MarkSize = new NSizeL(new NLength(8), new NLength(8));
            legend.Data.CellMargins = new NMarginsL(5, 3, 5, 3);
            legend.Padding = new NMarginsL(1, 1, 1, 7);

            NChart chart = new NCartesianChart();
            nChartControl1.Panels.Add(chart);
            chart.DisplayOnLegend = legend;
            chart.Wall(ChartWallType.Back).FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant2, Color.White, Color.FromArgb(233, 233, 255));
            chart.BoundsMode = BoundsMode.Stretch;
            chart.Dock = DockStyle.Fill;
            chart.PositionChildPanelsInContentBounds = true;
            chart.Padding = new NMarginsL(
                    new NLength(6, NRelativeUnit.ParentPercentage),
                    new NLength(6, NRelativeUnit.ParentPercentage),
                    new NLength(6, NRelativeUnit.ParentPercentage),
                    new NLength(6, NRelativeUnit.ParentPercentage));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!NThinChartControl1.Initialized)
            {
                // enable jittering (full scene antialiasing)
                NThinChartControl1.Settings.JitterMode = JitterMode.Enabled;

                NThinChartControl1.BackgroundStyle.FrameStyle.Visible = false;
                NThinChartControl1.Panels.Clear();

                // add header
                NLabel header = NThinChartControl1.Labels.AddHeader("General Thin Web Functionality");
                header.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
                header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
                header.Margins  = new NMarginsL(10, 10, 10, 10);
                header.DockMode = PanelDockMode.Top;

                NChart chart = new NCartesianChart();
                NThinChartControl1.Panels.Add(chart);
                chart.BoundsMode = BoundsMode.Stretch;
                chart.DockMode   = PanelDockMode.Fill;
                chart.Margins    = new NMarginsL(10, 0, 10, 10);

                // setup X axis
                NRangeTimelineScaleConfigurator scaleX = new NRangeTimelineScaleConfigurator();
                // set configurator
                chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX;

                // enable the scrollbar
                chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true;

                // setup primary Y axis
                NAxis axis = chart.Axis(StandardAxis.PrimaryY);
                NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)axis.ScaleConfigurator;

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

                // line series for the function
                NLineSeries line = (NLineSeries)chart.Series.Add(SeriesType.Line);
                line.DataLabelStyle.Visible = false;
                line.BorderStyle.Color      = Color.Red;
                line.BorderStyle.Width      = new NLength(2, NGraphicsUnit.Pixel);
                line.UseXValues             = true;

                Color customColor = Color.FromArgb(100, 100, 150);

                // setup the stock series
                NStockSeries stock = (NStockSeries)chart.Series.Add(SeriesType.Stock);
                stock.DataLabelStyle.Visible   = false;
                stock.CandleStyle              = CandleStyle.Bar;
                stock.CandleWidth              = new NLength(1, NRelativeUnit.ParentPercentage);
                stock.HighLowStrokeStyle.Color = customColor;
                stock.UpStrokeStyle.Color      = customColor;
                stock.DownStrokeStyle.Color    = customColor;
                stock.UpFillStyle              = new NColorFillStyle(Color.White);
                stock.DownFillStyle            = new NColorFillStyle(customColor);
                stock.OpenValues.Name          = "open";
                stock.HighValues.Name          = "high";
                stock.LowValues.Name           = "low";
                stock.CloseValues.Name         = "close";
                stock.UseXValues = true;

                GenerateData(stock);
                NFunctionCalculator functionCalculator = new NFunctionCalculator();
                BuildExpression(functionCalculator, stock, line);

                line.XValues = (NDataSeriesDouble)stock.XValues.Clone();
                line.Values  = functionCalculator.Calculate();

                NThinChartControl1.ServerSettings.EnableTiledZoom = true;

                // configure toolbar
                NThinChartControl1.Toolbar.Visible = true;
                NThinChartControl1.Controller.SetActivePanel(chart);

                // add a data zoom tool
                NDataZoomTool dataZoomTool = new NDataZoomTool();
                dataZoomTool.Exclusive      = true;
                dataZoomTool.Enabled        = true;
                dataZoomTool.AllowYAxisZoom = false;
                NThinChartControl1.Controller.Tools.Add(dataZoomTool);

                // add a data pan tool
                NDataPanTool dataPanTool = new NDataPanTool();
                dataPanTool.Exclusive = true;
                dataPanTool.Enabled   = false;
                NThinChartControl1.Controller.Tools.Add(dataPanTool);

                // add a tooltip tool
                NThinChartControl1.Controller.Tools.Add(new NTooltipTool());
                // add a cursor change tool
                NThinChartControl1.Controller.Tools.Add(new NCursorTool());

                NThinChartControl1.Toolbar.Visible = true;
                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NSaveImageAction("Save as PNG", new NPngImageFormat(), true, new NSize(0, 0), 96)));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarSeparator());

                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleDataZoomToolAction()));
                NThinChartControl1.Toolbar.Items.Add(new NToolbarButton(new NToggleDataPanToolAction()));
            }
        }
示例#19
0
        private void InitMap(NChartControl nChartControl)
        {
            // configure the chart
            NCartesianChart chart = (NCartesianChart)nChartControl.Charts[0];

            chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalTop);
            chart.BoundsMode       = BoundsMode.Stretch;
            chart.Enable3D         = true;
            chart.Fit3DAxisContent = false;

            // No Legend & No Update
            nChartControl.Legends.Clear();
            nChartControl.ServiceManager.LegendUpdateService.UpdateAutoLegends();
            nChartControl.ServiceManager.LegendUpdateService.Stop();

            chart.Width  = _gridSizeX;
            chart.Height = 20;
            chart.Depth  = _gridSizeY;

            // Wall Setup
            NChartWall backWall = chart.Wall(ChartWallType.Back);

            backWall.Visible = false;

            NChartWall leftWall = chart.Wall(ChartWallType.Left);

            leftWall.Visible = false;

            // setup axes
            //NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;
            //ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);
            //ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            //ordinalScale.DisplayDataPointsBetweenTicks = false;

            //ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.Depth).ScaleConfigurator;
            //ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);
            //ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true);
            //ordinalScale.DisplayDataPointsBetweenTicks = false;

            NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator();

            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale;
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            linearScale.RoundToTickMax = false;
            linearScale.RoundToTickMin = false;

            linearScale = new NLinearScaleConfigurator();
            chart.Axis(StandardAxis.Depth).ScaleConfigurator = linearScale;
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true);
            linearScale.RoundToTickMax = false;
            linearScale.RoundToTickMin = false;

            linearScale = new NLinearScaleConfigurator();
            chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale;
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true);
            linearScale.RoundToTickMax = false;
            linearScale.RoundToTickMin = false;

            chart.Axis(StandardAxis.SecondaryY).Anchor = new NDockAxisAnchor(AxisDockZone.FrontLeft, false, 50.0f, 50.0f);

            // Axis Visable Setup.
            //chart.Axis(StandardAxis.PrimaryX).Visible = false;
            chart.Axis(StandardAxis.PrimaryY).Visible = false;
            //chart.Axis(StandardAxis.Depth).Visible = false;

            for (int i = 0; i < _gridSizeY; i++)
            {
                // add the first line
                NBarSeries bar = new NBarSeries();
                chart.Series.Add(bar);

                bar.WidthPercent = 100.0f;
                bar.DepthPercent = 100.0f;

                bar.EnableDepthSort        = false;
                bar.DataLabelStyle.Visible = false;

                //bar.Values.ValueFormatter = new NNumericValueFormatter("0.0");
                bar.Values.EmptyDataPoints.ValueMode = EmptyDataPointsValueMode.Skip;

                //bar.Values.Clear();
                bar.FillStyles.StorageType = IndexedStorageType.Array;
                bar.DataPointOriginIndex   = 0;

                // turn off bar border to improve performance
                bar.BorderStyle.Width = new NLength(0.5f);
            }
            nChartControl.Settings.RenderSurface = RenderSurface.Window;

            nChartControl.Controller.Tools.Add(new NPanelSelectorTool());
            nChartControl.Controller.Tools.Add(new NTrackballTool());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Settings.JitterMode         = JitterMode.Enabled;
            nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.HighSpeed;

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

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

            // setup chart
            NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

            chart.Enable3D = true;
            chart.Width    = 55.0f;
            chart.Depth    = 55.0f;
            chart.Height   = 45.0f;
            chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted);
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyCameraLight);

            SetupAxisAnchorsAndWalls(chart);

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

            scaleY.RoundToTickMax = false;
            NAxis axisY = chart.Axis(StandardAxis.PrimaryY);

            axisY.View = new NRangeAxisView(new NRange1DD(0, 100), true, false);
            axisY.ScaleConfigurator = scaleY;

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

            scaleX.RoundToTickMin = false;
            scaleX.RoundToTickMax = false;
            NAxis axisX = chart.Axis(StandardAxis.PrimaryX);

            axisX.ScaleConfigurator = scaleX;

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

            scaleZ.MajorGridStyle.ShowAtWalls = new ChartWallType[0];
            scaleZ.RoundToTickMin             = false;
            scaleZ.RoundToTickMax             = false;
            NAxis axisZ = chart.Axis(StandardAxis.Depth);

            axisZ.ScaleConfigurator = scaleZ;

            // add a surface series
            NGridSurfaceSeries surface = new NGridSurfaceSeries();

            chart.Series.Add(surface);
            surface.Name        = "Surface";
            surface.Legend.Mode = SeriesLegendMode.None;
            surface.FillStyle   = new NColorFillStyle(Color.FromArgb(160, 170, 212));
            surface.FillMode    = SurfaceFillMode.Uniform;
            surface.FrameMode   = SurfaceFrameMode.None;
            surface.DrawFlat    = false;
            surface.ShadingMode = ShadingMode.Smooth;
            SetupCommonSurfaceProperties(surface);

            // add a surface series
            NGridSurfaceSeries contour = new NGridSurfaceSeries();

            chart.Series.Add(contour);
            contour.Name        = "Contour";
            contour.Legend.Mode = SeriesLegendMode.SeriesLogic;
            contour.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point);
            contour.FillMode    = SurfaceFillMode.Zone;
            contour.FrameMode   = SurfaceFrameMode.Contour;
            contour.DrawFlat    = true;
            contour.ShadingMode = ShadingMode.Flat;
            SetupCommonSurfaceProperties(contour);

            contour.AutomaticPalette = false;
            contour.Palette.Clear();
            contour.Palette.Add(250, Color.FromArgb(112, 211, 162));
            contour.Palette.Add(311, Color.FromArgb(113, 197, 212));
            contour.Palette.Add(328, Color.FromArgb(114, 162, 212));
            contour.Palette.Add(344, Color.FromArgb(196, 185, 206));
            contour.Palette.Add(358, Color.FromArgb(161, 130, 191));
            contour.Palette.Add(370, Color.FromArgb(198, 170, 165));
            contour.Palette.Add(400, Color.FromArgb(255, 0, 0));

            // fill both surfaces with the same data
            FillData(surface, contour);

            // apply layout
            ApplyLayoutTemplate(0, nChartControl1, chart, title, nChartControl1.Legends[0]);
        }
        public override void Initialize()
        {
            base.Initialize();

            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel header = new NLabel("Company Sales by Region<br/><font size = '9pt'>Demonstrates how to use custom range labels to denote ranges on a scale</font>");

            header.DockMode             = PanelDockMode.Top;
            header.Margins              = new NMarginsL(0, 10, 0, 10);
            header.TextStyle.FontStyle  = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            header.TextStyle.TextFormat = TextFormat.XML;
            header.ContentAlignment     = ContentAlignment.BottomRight;
            header.Location             = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));
            nChartControl1.Panels.Add(header);

            NLegend legend = new NLegend();

            legend.Margins      = new NMarginsL(10, 0, 10, 0);
            legend.DockMode     = PanelDockMode.Right;
            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(10, 0, 0, 10);
            chart.Axis(StandardAxis.Depth).Visible = false;

            // add range selection
            NRangeSelection rangeSelection = new NRangeSelection();

            rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper();
            chart.RangeSelections.Add(rangeSelection);

            // add the first bar
            m_Bar1                       = (NBarSeries)chart.Series.Add(SeriesType.Bar);
            m_Bar1.Name                  = "Coca Cola";
            m_Bar1.MultiBarMode          = MultiBarMode.Series;
            m_Bar1.DataLabelStyle.Format = "<value>";

            // add the second bar
            m_Bar2                       = (NBarSeries)chart.Series.Add(SeriesType.Bar);
            m_Bar2.Name                  = "Pepsi";
            m_Bar2.MultiBarMode          = MultiBarMode.Clustered;
            m_Bar2.DataLabelStyle.Format = "<value>";

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);

            styleSheet.Apply(nChartControl1.Document);

            // add custom labels to the X axis
            NAxis xAxis = chart.Axis(StandardAxis.PrimaryX);

            xAxis.ScrollBar.Visible = true;
            NOrdinalScaleConfigurator ordinalScale = xAxis.ScaleConfigurator as NOrdinalScaleConfigurator;

            ordinalScale.AutoLabels = false;
            ordinalScale.OuterMajorTickStyle.Visible = false;
            ordinalScale.InnerMajorTickStyle.Visible = false;

            // add custom labels to the Y axis
            chart.Axis(StandardAxis.PrimaryY).View = new NRangeAxisView(new NRange1DD(0, 320));
            NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;

            linearScale.RoundToTickMax = false;
            NCustomRangeLabel rangeLabel = new NCustomRangeLabel(new NRange1DD(240, 320), "Target Volume");

            rangeLabel.Style.TickMode = RangeLabelTickMode.Center;
            rangeLabel.Style.WrapText = true;
            rangeLabel.Style.Angle    = new NScaleLabelAngle(ScaleLabelAngleMode.Scale, 0);
            linearScale.CustomLabels.Add(rangeLabel);

            // 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 interactivity
            nChartControl1.Controller.Tools.Add(new NPanelSelectorTool());
            nChartControl1.Controller.Tools.Add(new NAxisScrollTool());
            nChartControl1.Controller.Tools.Add(new NDataZoomTool());

            // init form controls
            LabelTickModeComboBox.FillFromEnum(typeof(RangeLabelTickMode));
            LabelVisibilityModeComboBox.FillFromEnum(typeof(ScaleLabelVisibilityMode));
            LabelFitModeComboBox.FillFromEnum(typeof(RangeLabelFitMode));

            NRangeScaleLabelStyle defaultStyle = new NRangeScaleLabelStyle();

            LabelTickModeComboBox.SelectedIndex       = (int)defaultStyle.TickMode;
            LabelVisibilityModeComboBox.SelectedIndex = (int)defaultStyle.VisibilityMode;
            LabelFitModeComboBox.SelectedIndex        = (int)defaultStyle.FitMode;
            LabelAngleNumericUpDown.Value             = (decimal)defaultStyle.Angle.CustomAngle;
            TickPaddingNumericUpDown.Value            = (decimal)defaultStyle.TickPadding.Value;
            TickOffsetNumericUpDown.Value             = (decimal)defaultStyle.TickOffset.Value;
            TextOffsetNumericUpDown.Value             = (decimal)defaultStyle.Offset.Value;
            TextPaddingNumericUpDown.Value            = (decimal)defaultStyle.TextPadding.Value;

            // add some data
            NorthAmericaCheckBox.Checked = true;
            EuropeCheckBox.Checked       = true;
            AsiaCheckBox.Checked         = true;
            SouthAmericaCheckBox.Checked = true;
        }
示例#22
0
        public override void Initialize()
        {
            base.Initialize();

            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel header = new NLabel("Legend Row and Column Interlacing");

            header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            header.ContentAlignment    = ContentAlignment.BottomRight;
            header.Location            = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));
            header.DockMode            = PanelDockMode.Top;
            header.Margins             = new NMarginsL(10, 10, 10, 10);
            nChartControl1.Panels.Add(header);

            m_bUpdate = false;

            // configure the legend
            NLegend legend = new NLegend();

            legend.UseAutomaticSize = true;
            legend.Margins          = new NMarginsL(10, 10, 10, 10);
            nChartControl1.Panels.Add(legend);

            legend.Mode            = LegendMode.Automatic;
            legend.Location        = new NPointL(new NLength(90, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage));
            legend.Data.ExpandMode = LegendExpandMode.RowsFixed;
            legend.Data.RowCount   = 12;
            legend.FillStyle.SetTransparencyPercent(100);
            legend.OuterLeftBorderStyle.Width   = new NLength(0);
            legend.OuterTopBorderStyle.Width    = new NLength(0);
            legend.OuterRightBorderStyle.Width  = new NLength(0);
            legend.OuterBottomBorderStyle.Width = new NLength(0);
            legend.HorizontalBorderStyle.Width  = new NLength(0);
            legend.VerticalBorderStyle.Width    = new NLength(0);

            legend.DockMode = PanelDockMode.Right;

            m_RowInterlaceStyle           = new NLegendInterlaceStyle();
            m_RowInterlaceStyle.Type      = LegendInterlaceStyleType.Row;
            m_RowInterlaceStyle.FillStyle = new NColorFillStyle(Color.FromArgb(125, Color.DimGray));
            legend.InterlaceStyles.Add(m_RowInterlaceStyle);

            m_ColInterlaceStyle           = new NLegendInterlaceStyle();
            m_ColInterlaceStyle.Type      = LegendInterlaceStyleType.Col;
            m_ColInterlaceStyle.FillStyle = new NColorFillStyle(Color.FromArgb(125, Color.Gainsboro));
            legend.InterlaceStyles.Add(m_ColInterlaceStyle);

            // init form controls depending on control style
            // configure layout
            ExpandModeComboBox.Items.Add("Rows only");
            ExpandModeComboBox.Items.Add("Cols only");
            ExpandModeComboBox.Items.Add("Rows fixed");
            ExpandModeComboBox.Items.Add("Cols fixed");
            ExpandModeComboBox.SelectedIndex = (int)legend.Data.ExpandMode;
            RowCountUpDown.Value             = (decimal)legend.Data.RowCount;
            ColCountUpDown.Value             = (decimal)legend.Data.ColCount;

            // configure horizontal interlacing
            legend.InterlaceStyles.Clear();

            // configure the chart
            NChart chart = new NCartesianChart();

            nChartControl1.Panels.Add(chart);
            chart.DisplayOnLegend = legend;
            chart.BoundsMode      = BoundsMode.Fit;
            chart.DockMode        = PanelDockMode.Fill;
            chart.Margins         = new NMarginsL(10, 10, 10, 10);

            for (int i = 0; i < 4; i++)
            {
                // create bar series
                NBarSeries series = (NBarSeries)chart.Series.Add(SeriesType.Bar);
                series.Name = "Series " + i.ToString();
                series.Values.FillRandomRange(Random, 6, 50, 90);
                series.Legend.Format          = series.Name + " <value>";
                series.Legend.Mode            = SeriesLegendMode.DataPoints;
                series.MultiBarMode           = MultiBarMode.Stacked;
                series.DataLabelStyle.Visible = false;
            }

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);

            styleSheet.Apply(nChartControl1.Document);

            RowInterlacingEnabledCheckBox.Checked     = true;
            RowInterlacingBeginNumericUpDown.Value    = (decimal)m_RowInterlaceStyle.Begin;
            RowInterlacingEndNumericUpDown.Value      = (decimal)m_RowInterlaceStyle.End;
            RowInterlacingInfiniteCheckBox.Checked    = m_RowInterlaceStyle.Infinite;
            RowInterlacingLengthNumericUpDown.Value   = (decimal)m_RowInterlaceStyle.Length;
            RowInterlacingIntervalNumericUpDown.Value = (decimal)m_RowInterlaceStyle.Interval;

            // configure vertical interlacing
            ColumnInterlacingEnabledCheckBox.Checked     = true;
            ColumnInterlacingBeginNumericUpDown.Value    = (decimal)m_ColInterlaceStyle.Begin;
            ColumnInterlacingEndNumericUpDown.Value      = (decimal)m_ColInterlaceStyle.End;
            ColumnInterlacingInfiniteCheckBox.Checked    = m_ColInterlaceStyle.Infinite;
            ColumnInterlacingLengthNumericUpDown.Value   = (decimal)m_ColInterlaceStyle.Length;
            ColumnInterlacingIntervalNumericUpDown.Value = (decimal)m_ColInterlaceStyle.Interval;

            m_bUpdate = true;

            ConfigureLegend();
        }
示例#23
0
        /// <summary>
        /// Creates a sample bar chart given title, values and labels
        /// </summary>
        /// <param name="area"></param>
        /// <param name="size"></param>
        /// <param name="title"></param>
        /// <param name="values"></param>
        /// <param name="labels"></param>
        /// <returns></returns>
        private NParagraph CreateBarChart(bool area, NSize size, string title, double[] values, string[] labels)
        {
            NChartView chartView = new NChartView();

            chartView.Surface.CreatePredefinedChart(ENPredefinedChartType.Cartesian);
            chartView.PreferredSize = size;

            // configure title
            chartView.Surface.Titles[0].Text        = title;
            chartView.Surface.Titles[0].Margins     = NMargins.Zero;
            chartView.Surface.Legends[0].Visibility = ENVisibility.Hidden;
            chartView.BorderThickness = NMargins.Zero;

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

            chart.Padding = new NMargins(20);

            // configure axes
            chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);
            chart.Margins = NMargins.Zero;

            if (area)
            {
                NAreaSeries areaSeries = new NAreaSeries();
                areaSeries.LegendView.Mode = ENSeriesLegendMode.None;
                areaSeries.DataLabelStyle  = new NDataLabelStyle(false);

                chart.Series.Add(areaSeries);

                for (int i = 0; i < values.Length; i++)
                {
                    areaSeries.DataPoints.Add(new NAreaDataPoint(values[i]));
                }
            }
            else
            {
                NBarSeries barSeries = new NBarSeries();
                barSeries.LegendView.Mode = ENSeriesLegendMode.None;
                barSeries.DataLabelStyle  = new NDataLabelStyle(false);

                chart.Series.Add(barSeries);

                for (int i = 0; i < values.Length; i++)
                {
                    barSeries.DataPoints.Add(new NBarDataPoint(values[i]));
                }
            }

            NOrdinalScale scaleX = (NOrdinalScale)chart.Axes[ENCartesianAxis.PrimaryX].Scale;

            scaleX.Labels.TextProvider = new NOrdinalScaleLabelTextProvider(labels);
            scaleX.MajorTickMode       = ENMajorTickMode.CustomStep;
            scaleX.CustomStep          = 1;

            NParagraph paragraph = new NParagraph();

            NWidgetInline chartInline = new NWidgetInline();

            chartInline.Content = chartView;
            paragraph.Inlines.Add(chartInline);

            return(paragraph);
        }
示例#24
0
        public override void Initialize()
        {
            base.Initialize();

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Time Span Scale");

            title.TextStyle.TextFormat = TextFormat.XML;
            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));

            // no legend
            nChartControl1.Legends.Clear();

            // setup chart
            NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

            chart.BoundsMode = BoundsMode.Stretch;

            // add a range selection, snapped to the vertical axis min/max values
            NRangeSelection rangeSelection = new NRangeSelection();

            rangeSelection.VerticalValueSnapper = new NAxisRulerMinMaxSnapper();
            chart.RangeSelections.Add(rangeSelection);

            // add interlaced stripe to the Y axis
            NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;
            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);

            // Add a line series
            m_Line = new NLineSeries();
            chart.Series.Add(m_Line);

            m_Line.UseXValues = true;

            m_Line.UseXValues             = true;
            m_Line.DataLabelStyle.Visible = false;
            m_Line.SamplingMode           = SeriesSamplingMode.Enabled;

            // create a date time scale
            m_TimeSpanScale = new NTimeSpanScaleConfigurator();
            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = m_TimeSpanScale;

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);

            styleSheet.Apply(nChartControl1.Document);

            NAxis xAxis = chart.Axis(StandardAxis.PrimaryX);

            xAxis.ScrollBar.Visible = true;

            // init form controls
            EnableUnitSensitiveFormattingCheckBox.Checked = true;
            MillisecondCheckBox.Checked = true;
            SecondCheckBox.Checked      = true;
            MinuteCheckBox.Checked      = true;
            HourCheckBox.Checked        = true;
            DayCheckBox.Checked         = true;
            WeekCheckBox.Checked        = true;

            UpdateDateTimeScale();

            StepUnitComboBox.Items.Add("Millisecond");
            StepUnitComboBox.Items.Add("Second");
            StepUnitComboBox.Items.Add("Minute");
            StepUnitComboBox.Items.Add("Hour");
            StepUnitComboBox.Items.Add("Day");
            StepUnitComboBox.Items.Add("Week");
            StepUnitComboBox.SelectedIndex = 2;

            timer1.Start();
            nChartControl1.Refresh();
        }
示例#25
0
        public override void Initialize()
        {
            base.Initialize();

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Multiple Axes Zooming and Scrolling");

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

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

            chart.RangeSelections.Add(new NRangeSelection());

            // 2D line chart
            chart.BoundsMode = BoundsMode.Stretch;

            // configure axis paging and set a mimimum range length on the axisthis will prevent the user from zooming too much
            chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true;

            NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Fresh);
            Color         color1  = palette.SeriesColors[0];
            Color         color2  = palette.SeriesColors[3];

            NAxis primaryY = chart.Axis(StandardAxis.PrimaryY);

            primaryY.ScaleConfigurator.Title.Text = "Primary Y Axis";
            ApplyColorToAxis(primaryY, color1);
            primaryY.ScrollBar.Visible        = true;
            primaryY.Scale.RulerRangeChanged += new EventHandler(Scale_RulerRangeChanged);

            NAxis secondaryY = chart.Axis(StandardAxis.SecondaryY);

            secondaryY.ScaleConfigurator.Title.Text = "Secondary Y Axis";
            ApplyColorToAxis(secondaryY, color2);
            secondaryY.Visible = true;

            NLineSeries line1 = new NLineSeries();

            line1.BorderStyle.Color = color1;
            line1.BorderStyle.Width = new NLength(2);
            chart.Series.Add(line1);

            line1.DataLabelStyle.Visible = false;

            NLineSeries line2 = new NLineSeries();

            line2.BorderStyle.Color = color2;
            line2.BorderStyle.Width = new NLength(2);
            chart.Series.Add(line2);

            line2.DataLabelStyle.Visible = false;
            line2.DisplayOnAxis(StandardAxis.PrimaryY, false);
            line2.DisplayOnAxis(StandardAxis.SecondaryY, true);

            for (int i = 0; i < 720; i++)
            {
                double angle = i * NMath.Degree2Rad;

                double value1 = Math.Sin(angle);
                double value2 = Math.Sin(angle + 40) * 100;

                line1.Values.Add(value1);
                line2.Values.Add(value2);
            }

            nChartControl1.Controller.Tools.Add(new NSelectorTool());
            nChartControl1.Controller.Tools.Add(new NAxisScrollTool());
            nChartControl1.Controller.Tools.Add(new NDataZoomTool());
            nChartControl1.Controller.Tools.Add(new NDataPanTool());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Settings.JitterMode = JitterMode.Enabled;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Float Bar Connector Lines");

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

            // no legend
            nChartControl1.Legends.Clear();

            // configure the chart
            NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

            chart.BoundsMode = BoundsMode.Stretch;
            chart.SetPredefinedChartStyle(PredefinedChartStyle.HorizontalLeft);
            chart.Axis(StandardAxis.Depth).Visible = false;

            // setup the value axis
            NRangeTimelineScaleConfigurator dateTimeScale = new NRangeTimelineScaleConfigurator();

            dateTimeScale.MajorGridStyle.ShowAtWalls = new ChartWallType[] { ChartWallType.Back };

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

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

            chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = dateTimeScale;
            chart.Axis(StandardAxis.PrimaryY).Anchor            = new NDockAxisAnchor(AxisDockZone.FrontRight, true, 0, 100);

            // fill data
            DateTime start = DateTime.Now;
            DateTime end   = start + new TimeSpan(10, 0, 0, 0);

            TaskCollection tasks = new TaskCollection();

            tasks.Add(new Task("Write Proposal",
                               new DateTime(2001, 4, 1),
                               new DateTime(2001, 4, 5),
                               new uint[] { 1, 2 }));

            tasks.Add(new Task("Obtain Approval",
                               new DateTime(2001, 4, 12),
                               new DateTime(2001, 9, 4),
                               new uint[] { 9 }));

            tasks.Add(new Task("Requirements Analysis",
                               new DateTime(2001, 4, 9),
                               new DateTime(2001, 5, 5),
                               new uint[] { 3 }));

            tasks.Add(new Task("Design Phase",
                               new DateTime(2001, 5, 6),
                               new DateTime(2001, 5, 30),
                               new uint[] { 4 }));

            tasks.Add(new Task("Design Signoff",
                               new DateTime(2001, 6, 2),
                               new DateTime(2001, 6, 2),
                               new uint[] { 5 }));

            tasks.Add(new Task("Alpha Implementation",
                               new DateTime(2001, 6, 3),
                               new DateTime(2001, 7, 31),
                               new uint[] { 6 }));

            tasks.Add(new Task("Design Review",
                               new DateTime(2001, 8, 1),
                               new DateTime(2001, 8, 8),
                               new uint[] { 7 }));

            tasks.Add(new Task("Revised Design Signoff",
                               new DateTime(2001, 8, 10),
                               new DateTime(2001, 8, 10),
                               new uint[] { 8 }));

            tasks.Add(new Task("Beta Implementation",
                               new DateTime(2001, 8, 12),
                               new DateTime(2001, 9, 12),
                               new uint[] { 9 }));

            tasks.Add(new Task("Testing",
                               new DateTime(2001, 9, 13),
                               new DateTime(2001, 10, 31),
                               new uint[] { 10 }));

            tasks.Add(new Task("Final Implementation",
                               new DateTime(2001, 11, 1),
                               new DateTime(2001, 11, 15),
                               new uint[] { 11 }));

            tasks.Add(new Task("Signoff",
                               new DateTime(2001, 11, 28),
                               new DateTime(2001, 11, 30),
                               new uint[] { 12 }));

            tasks.ConfigureChart(chart);

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);

            styleSheet.Apply(nChartControl1.Document);

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

            NFloatBarSeries floatBar = (NFloatBarSeries)nChartControl1.Charts[0].Series[0];

            floatBar.ShowGanttConnectorLines = ShowGanttConnectorLinesCheckBox.Checked;
        }
        /// <summary>
        /// Called to initialize the example
        /// </summary>
        /// <param name="chartControl"></param>
        public override void Create()
        {
            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader(this.Title);

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

            // no legend
            nChartControl1.Legends.Clear();

            // do not update automatic legends
            nChartControl1.ServiceManager.LegendUpdateService.UpdateAutoLegends();
            nChartControl1.ServiceManager.LegendUpdateService.Stop();

            // configure the chart
            NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

            chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted);
            chart.BoundsMode       = BoundsMode.Fit;
            chart.Enable3D         = true;
            chart.Fit3DAxisContent = false;

            // make the aspect 6:1:2
            chart.Width  = 60;
            chart.Height = 20;
            chart.Depth  = 20;

            // configure the y axis
            NAxis yAxis = chart.Axis(StandardAxis.PrimaryY);

            yAxis.View = new NRangeAxisView(new NRange1DD(0, m_MaxValue));

            NLinearScaleConfigurator linearScale = yAxis.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);

            linearScale.MajorGridStyle.LineStyle.Color = Color.LightSteelBlue;
            linearScale.InnerMinorTickStyle.Visible    = false;
            linearScale.InnerMajorTickStyle.Visible    = false;
            linearScale.LabelFitModes = new LabelFitMode[0];

            // configure the x axis
            NAxis xAxis = chart.Axis(StandardAxis.PrimaryX);

            linearScale = new NLinearScaleConfigurator();
            linearScale.LabelFitModes  = new LabelFitMode[0];
            xAxis.ScaleConfigurator    = linearScale;
            linearScale.RoundToTickMax = false;
            linearScale.RoundToTickMin = false;
            linearScale.InnerMinorTickStyle.Visible = false;
            linearScale.InnerMajorTickStyle.Visible = false;

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

            // apply layout
            ConfigureStandardLayout(chart, title, null);

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);

            styleSheet.Apply(nChartControl1.Document);

            nChartControl1.Controller.Tools.Add(new NPanelSelectorTool());
            nChartControl1.Controller.Tools.Add(new NTrackballTool());

            GridSizeXComboBox.Items.Add("10");
            GridSizeXComboBox.Items.Add("50");
            GridSizeXComboBox.Items.Add("100");

            GridSizeYComboBox.Items.Add("10");
            GridSizeYComboBox.Items.Add("50");
            GridSizeYComboBox.Items.Add("100");

            GridSizeXComboBox.SelectedIndex = 2;
            GridSizeYComboBox.SelectedIndex = 2;

            UseHardwareAccelerationCheckBox.IsChecked = true;
            nChartControl1.Settings.RenderSurface     = RenderSurface.Window;
            StartTimer();

            ConfigureStandardLayout(chart, title, null);
        }
示例#28
0
        public override void Initialize()
        {
            base.Initialize();

            nChartControl1.Panels.Clear();

            // setup chart 1
            NChart chart1 = new NCartesianChart();

            nChartControl1.Charts.Add(chart1);
            chart1.BoundsMode = BoundsMode.Stretch;
            chart1.Wall(ChartWallType.Back).FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.FromArgb(220, 220, 235));

            // setup X axis
            NAxis axisX = chart1.Axis(StandardAxis.PrimaryX);
            NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator();

            scaleX.InnerMajorTickStyle.Visible           = false;
            scaleX.MajorGridStyle.ShowAtWalls            = new ChartWallType[] { ChartWallType.Back };
            axisX.ScaleConfigurator                      = scaleX;
            ((NDockAxisAnchor)axisX.Anchor).AxisDockZone = AxisDockZone.FrontTop;

            // setup Y axis
            chart1.Axis(StandardAxis.PrimaryY).ScaleConfigurator.InnerMajorTickStyle.Visible = false;

            // add a line series
            NLineSeries line1 = new NLineSeries();

            chart1.Series.Add(line1);
            line1.DataLabelStyle.Visible = false;
            line1.BorderStyle            = new NStrokeStyle(2, Color.Peru);
            line1.FillStyle = new NColorFillStyle(Color.Peru);

            // setup chart 2
            NChart chart2 = new NCartesianChart();

            nChartControl1.Charts.Add(chart2);
            chart2.BoundsMode = BoundsMode.Stretch;
            chart2.Wall(ChartWallType.Back).FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant2, Color.White, Color.FromArgb(220, 220, 235));

            // setup X axis
            scaleX = new NLinearScaleConfigurator();
            scaleX.InnerMajorTickStyle.Visible = false;
            scaleX.MajorGridStyle.ShowAtWalls  = new ChartWallType[] { ChartWallType.Back };
            chart2.Axis(StandardAxis.PrimaryX).ScaleConfigurator = scaleX;

            // setup Y axis
            chart2.Axis(StandardAxis.PrimaryY).ScaleConfigurator.InnerMajorTickStyle.Visible = false;

            // add a line series
            NLineSeries line2 = new NLineSeries();

            chart2.Series.Add(line2);
            line2.DataLabelStyle.Visible = false;
            line2.BorderStyle            = new NStrokeStyle(2, Color.Olive);
            line2.FillStyle = new NColorFillStyle(Color.Olive);

            // fill some data
            for (int i = 0; i < 100; i++)
            {
                line1.Values.Add(Math.Sin(i * 0.05) * (Random.NextDouble() + 1.0));
                line2.Values.Add(Math.Cos(i * 0.1) * (Random.NextDouble() + 1.0));
            }

            // init form controls
            LeftMarginScrollBar.Value   = 10;
            TopMarginScrollBar.Value    = 12;
            RightMarginScrollBar.Value  = 90;
            BottomMarginScrollBar.Value = 88;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
            }

            nChartControl1.Panels.Clear();
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = new NLabel("Flash Interactivity");

            title.TextStyle.FontStyle            = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.DockMode                       = PanelDockMode.Top;
            title.InteractivityStyle.UrlLink.Url = "http://www.apple.com";
            nChartControl1.Panels.Add(title);

            NDockPanel contentPanel = new NDockPanel();

            nChartControl1.Panels.Add(contentPanel);

            contentPanel.DockMode = PanelDockMode.Fill;

            // configure the chart
            NCartesianChart chart = new NCartesianChart();

            contentPanel.ChildPanels.Add(chart);
            chart.Location = new NPointL(0, 0);
            chart.Size     = new NSizeL(new NLength(100, NRelativeUnit.ParentPercentage),
                                        new NLength(60, NRelativeUnit.ParentPercentage));
            chart.Enable3D = false;
            chart.Axis(StandardAxis.Depth).Visible = false;
            chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective1);
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.BrightCameraLight);
            chart.Margins    = new NMarginsL(5, 5, 5, 5);
            chart.BoundsMode = BoundsMode.Stretch;
            chart.DockMode   = PanelDockMode.Fill;

            // configure axes
            NOrdinalScaleConfigurator ordinalScale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator;

            ordinalScale.AutoLabels = false;
            ordinalScale.Labels.Add("2004");
            ordinalScale.Labels.Add("2005");
            ordinalScale.Labels.Add("2006");
            ordinalScale.Labels.Add("2007");
            ordinalScale.Labels.Add("2008");
            ordinalScale.Labels.Add("2009");

            // add interlace stripe
            NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;

            linearScale.Title.Text      = "Sales in Thousands USD";
            linearScale.MinTickDistance = new NLength(15);
            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);

            // create  series
            NBarSeries bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar);
            NBarSeries bar2 = (NBarSeries)chart.Series.Add(SeriesType.Bar);
            NBarSeries bar3 = (NBarSeries)chart.Series.Add(SeriesType.Bar);

            bar1.MultiBarMode = MultiBarMode.Clustered;
            bar2.MultiBarMode = MultiBarMode.Clustered;
            bar3.MultiBarMode = MultiBarMode.Clustered;

            // configure common settings
            bar1.Name = "Apple";
            bar2.InteractivityStyle.UrlLink.Url = "http://www.apple.com";
            bar1.DataLabelStyle.Visible         = false;

            bar2.Name = "Nokia";
            bar2.InteractivityStyle.UrlLink.Url = "http://www.nokia.com";
            bar2.DataLabelStyle.Visible         = false;

            bar3.Name = "HTC";
            bar3.InteractivityStyle.UrlLink.Url = "http://www.htc.com";
            bar3.DataLabelStyle.Visible         = false;

            // fill with random data
            bar1.Values.FillRandomRange(Random, 6, 10, 100);
            bar2.Values.FillRandomRange(Random, 6, 10, 100);
            bar3.Values.FillRandomRange(Random, 6, 10, 100);

            // apply style sheet
            NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);

            styleSheet.Apply(nChartControl1.Document);

            // apply animation theme
            NAnimationTheme animationTheme = new NAnimationTheme();

            animationTheme.AnimateSeriesSequentially     = true;
            animationTheme.AnimateDataPointsSequentially = false;
            animationTheme.AnimateChartsSequentially     = false;

            animationTheme.WallsAnimationDuration  = 1;
            animationTheme.AxesAnimationDuration   = 1;
            animationTheme.SeriesAnimationDuration = 1;

            animationTheme.AnimationThemeType = AnimationThemeType.ScaleAndFade;
            //	animationTheme.Apply(nChartControl1.Document);

            NImageResponse swfResponse = new NImageResponse();

            swfResponse.ImageFormat = new NSwfImageFormat();

            nChartControl1.ImageAcquisitionMode = ClientSideImageAcquisitionMode.TempFile;
            nChartControl1.ServerSettings.BrowserResponseSettings.DefaultResponse = swfResponse;
        }
        /// <summary>
        /// Called to initialize the example
        /// </summary>
        /// <param name="chartControl"></param>
        public override void Create()
        {
            nChartControl1.Panels.Clear();

            // create a guide line to align the chart bottoms
            NSideGuideline bottomChartGuideline = new NSideGuideline(PanelSide.Bottom);

            nChartControl1.Document.RootPanel.Guidelines.Add(bottomChartGuideline);

            // top panel
            NDockPanel topPanel = new NDockPanel();

            topPanel.DockMode = PanelDockMode.Top;
            topPanel.Size     = new NSizeL(new NLength(0), new NLength(20, NRelativeUnit.ParentPercentage));

            // bottom panel
            NDockPanel bottomPanel = new NDockPanel();

            bottomPanel.DockMode = PanelDockMode.Bottom;
            bottomPanel.Size     = new NSizeL(new NLength(0), new NLength(20, NRelativeUnit.ParentPercentage));

            // center panel
            NDockPanel centerPanel = new NDockPanel();

            centerPanel.DockMode = PanelDockMode.Fill;

            // left panel
            NDockPanel leftPanel = new NDockPanel();

            leftPanel.DockMode = PanelDockMode.Left;
            leftPanel.Size     = new NSizeL(new NLength(40.0f, NGraphicsUnit.Point), new NLength(0));

            // right panel
            NDockPanel rightPanel = new NDockPanel();

            rightPanel.DockMode = PanelDockMode.Right;
            rightPanel.Size     = new NSizeL(new NLength(40.0f, NGraphicsUnit.Point), new NLength(0));

            // middle panel
            NDockPanel middlePanel = new NDockPanel();

            middlePanel.DockMode = PanelDockMode.Right;
            middlePanel.Size     = new NSizeL(new NLength(10.0f, NGraphicsUnit.Point), new NLength(0));

            // right chart panel
            NDockPanel rightChartPanel = new NDockPanel();

            rightChartPanel.Size     = new NSizeL(new NLength(10.0f, NRelativeUnit.ParentPercentage), new NLength(0));
            rightChartPanel.DockMode = PanelDockMode.Right;

            // left chart panel
            NDockPanel leftChartPanel = new NDockPanel();

            leftChartPanel.Size     = new NSizeL(new NLength(10.0f, NRelativeUnit.ParentPercentage), new NLength(0));
            leftChartPanel.DockMode = PanelDockMode.Fill;

            // chart title
            NLabel title = new NLabel("Data Distribution");

            title.TextStyle.FontStyle         = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic);
            title.TextStyle.FillStyle         = new NColorFillStyle(GreyBlue);
            title.TextStyle.ShadowStyle.Type  = ShadowType.Solid;
            title.TextStyle.ShadowStyle.Color = Color.White;
            title.DockMode = PanelDockMode.Top;
            title.Padding  = new NMarginsL(5, 8, 5, 4);

            // create point chart
            NChart pointChart = new NCartesianChart();

            pointChart.BoundsMode = BoundsMode.Stretch;
            pointChart.DockMode   = PanelDockMode.Fill;
            bottomChartGuideline.Targets.Add(pointChart);

            // create box and whiskers chart
            NChart boxChart = new NCartesianChart();

            boxChart.BoundsMode = BoundsMode.Stretch;
            boxChart.DockMode   = PanelDockMode.Fill;
            bottomChartGuideline.Targets.Add(boxChart);

            // arrange panels
            nChartControl1.Panels.Add(topPanel);
            nChartControl1.Panels.Add(bottomPanel);
            nChartControl1.Panels.Add(centerPanel);

            centerPanel.ChildPanels.Add(rightPanel);
            centerPanel.ChildPanels.Add(rightChartPanel);
            centerPanel.ChildPanels.Add(middlePanel);
            centerPanel.ChildPanels.Add(leftPanel);
            centerPanel.ChildPanels.Add(leftChartPanel);

            topPanel.ChildPanels.Add(title);
            leftChartPanel.ChildPanels.Add(pointChart);
            rightChartPanel.ChildPanels.Add(boxChart);

            SetupCharts(pointChart, boxChart);

            UpdateBoxAndWhiskers();
        }
        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);

            // create the heat map
            NHeatMapSeries heatMap = new NHeatMapSeries();

            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.XValuesMode = HeatMapValuesMode.OriginAndStep;
            heatMap.YValuesMode = HeatMapValuesMode.OriginAndStep;

            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>";
            }
        }
示例#32
0
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Import from CSV File");

            title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
            title.ContentAlignment           = ContentAlignment.BottomRight;
            title.Location = new NPointL(
                new NLength(2, NRelativeUnit.ParentPercentage),
                new NLength(2, NRelativeUnit.ParentPercentage));

            NCartesianChart chart = new NCartesianChart();

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

            bar0.Legend.Mode = SeriesLegendMode.DataPoints;
            //bar0.FillStyle = new NColorFillStyle(Color.Aquamarine);
            NBarSeries bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar);

            bar1.Legend.Mode = SeriesLegendMode.DataPoints;
            //bar0.FillStyle = new NColorFillStyle(Color.BurlyWood);
            bar1.MultiBarMode = MultiBarMode.Clustered;

            string csvFile = this.MapPathSecure(this.TemplateSourceDirectory + "\\Sample.csv");

            NCsvReader reader = new NCsvReader();

            reader.CellSeparator   = ',';
            reader.LineSeparators  = new char[] { '\r', '\n' };
            reader.HasHeader       = false;
            reader.EscapeCharacter = '\\';
            reader.TrimCell        = true;

            reader.Columns.Add(new NStringCsvColumn("String Column"));
            reader.Columns.Add(new NDoubleCsvColumn("Double Column"));
            reader.Columns.Add(new NDecimalCsvColumn("Decimal Column"));
            reader.Columns.Add(new NColorCsvColumn("Color0 Column"));
            reader.Columns.Add(new NColorCsvColumn("Color1 Column"));

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

            // import
            try
            {
                DataTable dt = reader.LoadDataTableFromFile(csvFile);
                nChartControl1.DataBindingManager.AddBinding(0, 0, "Values", dt, "Double Column");
                nChartControl1.DataBindingManager.AddBinding(0, 0, "Labels", dt, "String Column");
                nChartControl1.DataBindingManager.AddBinding(0, 0, "FillStyles", dt, "Color0 Column");

                nChartControl1.DataBindingManager.AddBinding(0, 1, "Values", dt, "Decimal Column");
                nChartControl1.DataBindingManager.AddBinding(0, 1, "Labels", dt, "String Column");
                nChartControl1.DataBindingManager.AddBinding(0, 1, "FillStyles", dt, "Color1 Column");
            }
            catch (Exception)
            {
            }
        }
        /// <summary>
        /// Builds the attribute chart
        /// </summary>
        /// <param name="attributes">statistics for an attribute chart</param>
        private void BuildChart(IAttributeChartStats stats)
        {
            int nppoints = stats.Statistic.Length;
            double xstart = stats.TimeStart;
            double xincrement = stats.TimeSampleInterval;

            this.nControlChart.Panels.Clear();

            //
            // Set up chart title.
            //
            NLabel title = new NLabel();
            this.nControlChart.Panels.Add(title);
            title.Dock = DockStyle.Top;
            title.Padding = new NMarginsL(5, 8, 5, 4);
            title.Text = stats.ChartTitle;
            title.TextStyle.FontStyle = new NFontStyle("Verdana", 12, FontStyle.Bold | FontStyle.Italic);
            title.TextStyle.FillStyle = new NColorFillStyle(Color.FromArgb(68, 90, 108));

            //
            // Set up the chart
            //
            NChart chart = new NCartesianChart();
            this.nControlChart.Charts.Add(chart);
            chart.BoundsMode = BoundsMode.Stretch;
            chart.Dock = DockStyle.Fill;
            chart.Wall(ChartWallType.Back).FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant2, Color.White, Color.FromArgb(233, 233, 255));
            chart.Padding = new NMarginsL(
                    new NLength(6, NRelativeUnit.ParentPercentage),
                    new NLength(6, NRelativeUnit.ParentPercentage),
                    new NLength(6, NRelativeUnit.ParentPercentage),
                    new NLength(6, NRelativeUnit.ParentPercentage));

            SetupChartAxes(chart, stats);

            //
            // First set up a point series for the outliers so it's on-top in z-order.
            //
            NPointSeries outlierPoints = new NPointSeries();
            chart.Series.Add(outlierPoints);

            // Name the series
            outlierPoints.Name = "Control Limit Violations";

            // Tell the series to regard the X values
            outlierPoints.UseXValues = true;

            // Points must fit in the chart area
            outlierPoints.InflateMargins = true;

            // No data labels
            outlierPoints.DataLabelStyle.Visible = false;

            // Set the point appearance properties
            outlierPoints.FillStyle = new NColorFillStyle(Color.Red);
            outlierPoints.BorderStyle = new NStrokeStyle(1.0f, Color.Black);
            outlierPoints.PointShape = PointShape.Cross;
            outlierPoints.Size = new NLength(6.0f);

            // Add the statistic
            for (int i = 0; i < nppoints; i++)
            {
                double statValue = stats.Statistic[i];

                // Do not display a marker if the point is an outlier
                if ((statValue > stats.UCL[i]) || (statValue < stats.LCL[i]))
                {
                    outlierPoints.XValues.Add(xstart + xincrement * i);
                    outlierPoints.Values.Add(statValue);
                }
            }

            //
            // Set up the statistic line series
            //
            NLineSeries line = new NLineSeries();
            chart.Series.Add(line);
            line.Name = "Statistic";
            line.UseXValues = true;
            line.InflateMargins = true;
            line.DataLabelStyle.Visible = false;
            line.BorderStyle = new NStrokeStyle(1.6f, Color.Tomato);

            // Set up the marker style for the regular points
            line.MarkerStyle.Visible = true;
            line.MarkerStyle.FillStyle = new NColorFillStyle(Color.SkyBlue);
            line.MarkerStyle.BorderStyle = new NStrokeStyle(1.0f, Color.Tomato);
            line.MarkerStyle.PointShape = PointShape.Sphere;
            line.MarkerStyle.Width = new NLength(4.0f);
            line.MarkerStyle.Height = new NLength(4.0f);

            // Add the statistic
            for (int i = 0; i < nppoints; i++)
            {
                line.XValues.Add(xstart + xincrement * i);

                double statValue = stats.Statistic[i];

                // Do not display a marker if the point is an outlier
                if ((statValue > stats.UCL[i]) || (statValue < stats.LCL[i]))
                {
                    NMarkerStyle outlierMarker = new NMarkerStyle();
                    outlierMarker.Visible = false;
                    line.MarkerStyles[i] = outlierMarker;
                }
            }

            line.Values.AddRange(stats.Statistic.DataBlock.Data);

            //
            // Set up the UCL and LCL lines
            //
            if (stats.ConstControlLimits)
            {
                bool showLCL = (stats.LCL.Length > 0);
                bool showUCL = (stats.UCL.Length > 0);

                if (showLCL)
                {
                    double lclValue = stats.LCL[0];

                    // Set up the LCL const line
                    NAxisConstLine lcl = new NAxisConstLine();
                    lcl.StrokeStyle = new NStrokeStyle(1.0f, Color.Gray, LinePattern.Dash);
                    lcl.Value = lclValue;
                    lcl.ShowAtWalls = new ChartWallType[] { ChartWallType.Back };
                    chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(lcl);

                    // Show LCL label
                    SetValueLabel(chart, lclValue, "LCL", true);
                }

                if (showUCL)
                {
                    double uclValue = stats.UCL[0];

                    // Set up the UCL const line
                    NAxisConstLine ucl = new NAxisConstLine();
                    ucl.Value = uclValue;
                    ucl.StrokeStyle = new NStrokeStyle(1.0f, Color.Gray, LinePattern.Dash);
                    ucl.ShowAtWalls = new ChartWallType[] { ChartWallType.Back };
                    chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(ucl);

                    // Show UCL label
                    SetValueLabel(chart, uclValue, "UCL", true);
                }

                // Ensure that the UCL and LCL values are visible
                NRange1DD clRange = new NRange1DD();

                if (showLCL && showUCL)
                {
                    clRange.Begin = stats.LCL[0];
                    clRange.End = stats.UCL[0];
                }
                else if (showLCL)
                {
                    clRange.End = clRange.Begin = stats.LCL[0];
                }
                else if (showUCL)
                {
                    clRange.End = clRange.Begin = stats.UCL[0];
                }

                clRange.Inflate(0.5);

                chart.Axis(StandardAxis.PrimaryY).UpdateScale();
                chart.Axis(StandardAxis.PrimaryY).SynchronizeScaleWithConfigurator = false;

                // custom tick inflator
                NCustomRangeInflator inflator = new NCustomRangeInflator(new NRange1DD[] { clRange });
                inflator.InflateBegin = true;
                inflator.InflateEnd = true;
                chart.Axis(StandardAxis.PrimaryY).Scale.ContentRangeInflators.Add(inflator);
            }
            else
            {
                // Set up the UCL line series
                AddStepLineSeries(chart, "UCL", stats.UCL, xstart, xincrement);

                // Set up the LCL line series
                AddStepLineSeries(chart, "LCL", stats.LCL, xstart, xincrement);

                // Show UCL label
                if (stats.UCL.Length > 0)
                {
                    int lastIndexUCL = stats.UCL.Length - 1;
                    SetValueLabel(chart, stats.UCL[lastIndexUCL], "UCL", false);
                }

                // Show LCL label
                if (stats.LCL.Length > 0)
                {
                    int lastIndexLCL = stats.LCL.Length - 1;
                    SetValueLabel(chart, stats.LCL[lastIndexLCL], "LCL", false);
                }
            }

            //
            // Set up the center line
            //
            NAxisConstLine cl1 = new NAxisConstLine();
            cl1.StrokeStyle = new NStrokeStyle(1.0f, Color.DodgerBlue, LinePattern.Dot);
            cl1.Value = stats.CenterLine;
            cl1.ShowAtWalls = new ChartWallType[] { ChartWallType.Back };
            chart.Axis(StandardAxis.PrimaryY).ConstLines.Add(cl1);

            // Show CL label
            SetValueLabel(chart, stats.CenterLine, "CL", true);
        }
示例#34
0
 public void DrawExpPoints3D(int x1, int x2)
 {
     pointsChart.Values.Clear();
     pointsChart.XValues.Clear();
     pointsChart.ZValues.Clear();
     pointsChart.MarkerStyle.Visible = false;
     pointsChart.Size = new NLength(1F, NRelativeUnit.ParentPercentage);
     pointsChart.DataLabelStyle.Visible = false;
     pointsChart.BorderStyle.Width = new NLength(1);
     chart = (NCartesianChart)nChartControl1.Charts[0];
     chart.Series.Add(pointsChart);
     chart.Enable3D = true;
     pointsChart.UseXValues = true;
     pointsChart.UseZValues = true;
     for (int row = 0; row < dgwExperiment.RowCount; row++)
     {
         pointsChart.Values.Add(
             Convert.ToDouble(dgwExperiment.Rows[row].Cells[dgwExperiment.ColumnCount - 1].Value));
         pointsChart.XValues.Add(Convert.ToDouble(dgwExperiment.Rows[row].Cells[x1].Value));
         pointsChart.ZValues.Add(Convert.ToDouble(dgwExperiment.Rows[row].Cells[x2].Value));
     }
 }