Example #1
0
        public override void Initialize()
        {
            base.Initialize();

            m_StandardFrameStyle = new NStandardFrameStyle();
            nChartControl1.BackgroundStyle.FrameStyle = m_StandardFrameStyle;

            NLabel title = new NLabel("Standard Background Frame");

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

            nChartControl1.BackgroundStyle.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant2, Color.AliceBlue, Color.LightGray);

            NChart chart = nChartControl1.Charts[0];

            NAreaSeries area = (NAreaSeries)chart.Series.Add(SeriesType.Area);

            area.DataLabelStyle.Visible = false;
            area.FillStyle = new NColorFillStyle(DarkOrange);
            area.Values.AddRange(monthValues);

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

            BackgroundFillStyleComboBox.Items.Add("Solid color");
            BackgroundFillStyleComboBox.Items.Add("Gradient");
            BackgroundFillStyleComboBox.Items.Add("Image");
            BackgroundFillStyleComboBox.Items.Add("Pattern");
            BackgroundFillStyleComboBox.Items.Add("AdvancedGradient");
            BackgroundFillStyleComboBox.SelectedIndex = 1;

            nStandardFrameStyleEditorUC1.Style         = (NStandardFrameStyle)nChartControl1.BackgroundStyle.FrameStyle;
            nStandardFrameStyleEditorUC1.StyleChanged += new EventHandler(this.OnStandardFrameStyleChanged);
        }
        public override void Initialize(NThinChartControl control)
        {
            control.BackgroundStyle.FrameStyle.Visible = false;
            control.Panels.Clear();
            control.Width  = 600;
            control.Height = 300;
            NStandardFrameStyle frame = control.BackgroundStyle.FrameStyle as NStandardFrameStyle;

            frame.InnerBorderWidth = new NLength(0);

            // set a chart title
            // set a chart title
            NLabel title = control.Labels.AddHeader("Auto Update");

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

            // setup Line chart
            NCartesianChart chart = new NCartesianChart();

            control.Panels.Add(chart);
            NRangeTimelineScaleConfigurator rangeTimeline = new NRangeTimelineScaleConfigurator();

            rangeTimeline.FirstRow.MinTickDistance = new NLength(40);
            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = rangeTimeline;

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

            scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;

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

            NLineSeries line = new NLineSeries();

            line.UseXValues             = true;
            line.DataLabelStyle.Visible = false;
            line.BorderStyle.Color      = Color.DarkOrange;
            line.BorderStyle.Width      = new NLength(2);
            chart.Series.Add(line);

            // generate some data
            GenerateNewData(control);

            ApplyLayoutTemplate(0, control, chart, title, null);

            // set auto update Callback
            control.AutoUpdateCallback = new NAutoUpdateCallback();

            // enable auto update
            control.ServerSettings.AutoUpdateInterval = 200;
            control.ServerSettings.EnableAutoUpdate   = true;
        }
Example #3
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (nChartControl1.RequiresInitialization)
            {
                nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
                nChartControl1.Panels.Clear();
                NStandardFrameStyle frame = nChartControl1.BackgroundStyle.FrameStyle as NStandardFrameStyle;
                frame.InnerBorderWidth = new NLength(0);

                // set a chart title
                NLabel header = nChartControl1.Labels.AddFooter("Auto Refresh");
                header.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
                header.TextStyle.FillStyle = new NColorFillStyle(Color.FromArgb(60, 90, 108));
                header.ContentAlignment    = ContentAlignment.BottomRight;
                header.Location            = new NPointL(new NLength(3, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));

                // setup Line chart
                NCartesianChart chart = new NCartesianChart();

                chart.Location   = new NPointL(new NLength(3, NRelativeUnit.ParentPercentage), new NLength(3, NRelativeUnit.ParentPercentage));
                chart.Size       = new NSizeL(new NLength(100, NRelativeUnit.ParentPercentage), new NLength(65, NRelativeUnit.ParentPercentage));
                chart.BoundsMode = BoundsMode.Stretch;

                chart.Margins = new NMarginsL(5, 10, 5, 10);
                SetupLineChart(chart);

                nChartControl1.Panels.Add(chart);

                NRadialGaugePanel minRadialGauge = CreateGaugePanel();
                minRadialGauge.Size     = new NSizeL(new NLength(30, NRelativeUnit.ParentPercentage), new NLength(35, NRelativeUnit.ParentPercentage));
                minRadialGauge.Location = new NPointL(new NLength(3, NRelativeUnit.ParentPercentage), new NLength(63, NRelativeUnit.ParentPercentage));
                NNeedleValueIndicator minIndicator = CreateIndicator();
                DecorateGaugeAxis(minRadialGauge, new NRange1DD(0, 100), Color.Blue, Color.DarkBlue);
                minRadialGauge.Indicators.Add(minIndicator);
                minRadialGauge.ChildPanels.Add(CreateGaugeLabel("Min"));
                nChartControl1.Panels.Add(minRadialGauge);

                NRadialGaugePanel maxRadialGauge = CreateGaugePanel();
                maxRadialGauge.Size     = new NSizeL(new NLength(30, NRelativeUnit.ParentPercentage), new NLength(35, NRelativeUnit.ParentPercentage));
                maxRadialGauge.Location = new NPointL(new NLength(35, NRelativeUnit.ParentPercentage), new NLength(63, NRelativeUnit.ParentPercentage));
                DecorateGaugeAxis(maxRadialGauge, new NRange1DD(300, 400), Color.Red, Color.DarkRed);
                NNeedleValueIndicator maxIndicator = CreateIndicator();
                maxRadialGauge.Indicators.Add(maxIndicator);
                maxRadialGauge.ChildPanels.Add(CreateGaugeLabel("Max"));
                nChartControl1.Panels.Add(maxRadialGauge);

                NRadialGaugePanel avgRadialGauge = CreateGaugePanel();
                avgRadialGauge.Size     = new NSizeL(new NLength(30, NRelativeUnit.ParentPercentage), new NLength(35, NRelativeUnit.ParentPercentage));
                avgRadialGauge.Location = new NPointL(new NLength(68, NRelativeUnit.ParentPercentage), new NLength(63, NRelativeUnit.ParentPercentage));
                DecorateGaugeAxis(avgRadialGauge, new NRange1DD(100, 300), Color.Green, Color.DarkGreen);
                NNeedleValueIndicator avgIndicator = CreateIndicator();
                avgRadialGauge.Indicators.Add(avgIndicator);
                avgRadialGauge.ChildPanels.Add(CreateGaugeLabel("Avg"));
                nChartControl1.Panels.Add(avgRadialGauge);

                // generate some data
                GenerateNewData();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!NThinChartControl1.Initialized)
            {
                NThinChartControl1.BackgroundStyle.FrameStyle.Visible = false;
                NThinChartControl1.Panels.Clear();
                NStandardFrameStyle frame = NThinChartControl1.BackgroundStyle.FrameStyle as NStandardFrameStyle;
                frame.InnerBorderWidth = new NLength(0);

                // set a chart title
                // set a chart title
                NLabel title = NThinChartControl1.Labels.AddHeader("Auto Update");
                title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
                title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;

                // setup Line chart
                NCartesianChart chart = new NCartesianChart();
                NThinChartControl1.Panels.Add(chart);
                NRangeTimelineScaleConfigurator rangeTimeline = new NRangeTimelineScaleConfigurator();
                rangeTimeline.FirstRow.MinTickDistance = new NLength(40);
                chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = rangeTimeline;

                // setup Y axis
                NLinearScaleConfigurator scaleY = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
                scaleY.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot;

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

                NLineSeries line = new NLineSeries();
                line.UseXValues             = true;
                line.DataLabelStyle.Visible = false;
                line.BorderStyle.Color      = Color.DarkOrange;
                line.BorderStyle.Width      = new NLength(2);
                chart.Series.Add(line);

                // generate some data
                GenerateNewData();

                NThinChartControl1.AutoUpdateCallback = new NAutoUpdateCallback();
                ApplyLayoutTemplate(0, NThinChartControl1, chart, title, null);

                NThinChartControl1.ServerSettings.EnableTiledZoom    = true;
                NThinChartControl1.ServerSettings.AutoUpdateInterval = 200;
                NThinChartControl1.ServerSettings.EnableAutoUpdate   = true;
            }

            if (!IsPostBack)
            {
                AutoUpdateIntervalTextBox.Text = NThinChartControl1.ServerSettings.AutoUpdateInterval.ToString();
            }
        }
        private NChartControl CreateModifiedChartControl()
        {
            // create a duplicate of this chart control
            MemoryStream memoryStream = new MemoryStream();

            nChartControl1.Serializer.SaveControlStateToStream(memoryStream, PersistencyFormat.Binary, null);

            memoryStream.Seek(0, SeekOrigin.Begin);
            NChartControl chartControl = new NChartControl();

            chartControl.Serializer.LoadControlStateFromStream(memoryStream, PersistencyFormat.Binary, null);

            INObjectConverter fillStyleConverter = null;

            // apply a chart attribute converter
            if (ConvertToGrayScaleRadioButton.Checked)
            {
                fillStyleConverter = new NFillStyleToGrayScaleConverter();
            }
            else
            {
                fillStyleConverter = new NFillStyleColorToHatchConverter();
            }

            INObjectConverter[] converters = new INObjectConverter[] { fillStyleConverter,
                                                                       new NStrokeStyleToGrayScaleConverter(),
                                                                       new NShadowStyleToGrayScaleConverter(),
                                                                       new NLightModelToGrayScaleConverter() };


            NNodeTreeAttributeConverter grayScaleConverter = new NNodeTreeAttributeConverter();

            grayScaleConverter.Converters = converters;
            grayScaleConverter.Convert(chartControl.Document);

            if (PrintBackgroundFrameCheckBox.Checked == false)
            {
                NStandardFrameStyle standardFrameStyle = new NStandardFrameStyle();
                standardFrameStyle.InnerBorderWidth = new NLength(0);

                chartControl.BackgroundStyle.FrameStyle = standardFrameStyle;
            }

            chartControl.Refresh();

            return(chartControl);
        }
Example #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                StandardBorderDropDownList.Items.Add("None");
                StandardBorderDropDownList.Items.Add("SingleFixed");
                StandardBorderDropDownList.Items.Add("Sunken");
                StandardBorderDropDownList.Items.Add("Raised");
                StandardBorderDropDownList.Items.Add("SunkenRaised");
                StandardBorderDropDownList.Items.Add("RaisedSunken");

                WebExamplesUtilities.FillComboWithColorNames(BorderColorDropDownList, KnownColor.White);
                WebExamplesUtilities.FillComboWithValues(BevelWidthDropDownList, 1, 10, 1);
                WebExamplesUtilities.FillComboWithValues(BorderWidthDownList, 1, 10, 1);

                StandardBorderDropDownList.SelectedIndex = 2;
            }

            nChartControl1.Settings.JitterMode = JitterMode.Enabled;

            // set an image frame
            NStandardFrameStyle standardFrameStyle = new NStandardFrameStyle();

            standardFrameStyle.SetPredefinedFrameStyle((PredefinedStandardFrame)(StandardBorderDropDownList.SelectedIndex));
            standardFrameStyle.InnerBevelWidth  = new NLength(BevelWidthDropDownList.SelectedIndex + 1, NGraphicsUnit.Pixel);
            standardFrameStyle.OuterBevelWidth  = new NLength(BevelWidthDropDownList.SelectedIndex + 1, NGraphicsUnit.Pixel);
            standardFrameStyle.OuterBorderColor = WebExamplesUtilities.ColorFromDropDownList(BorderColorDropDownList);
            standardFrameStyle.OuterBorderWidth = new NLength(BorderWidthDownList.SelectedIndex + 1, NGraphicsUnit.Pixel);

            nChartControl1.BackgroundStyle.FrameStyle = standardFrameStyle;
            nChartControl1.BackgroundStyle.FillStyle  = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.LightSteelBlue, Color.White);

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Standard Border");

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

            // configure the chart
            NChart chart = nChartControl1.Charts[0];

            chart.Enable3D = true;
            chart.Depth    = 50;
            chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted);
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft);

            NStandardScaleConfigurator scaleX = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;

            scaleX.MajorTickMode = MajorTickMode.AutoMaxCount;

            NStandardScaleConfigurator scaleZ = (NStandardScaleConfigurator)chart.Axis(StandardAxis.Depth).ScaleConfigurator;

            scaleZ.MajorTickMode = MajorTickMode.AutoMaxCount;

            // add the first bar
            NBarSeries bar1 = (NBarSeries)chart.Series.Add(SeriesType.Bar);

            bar1.MultiBarMode           = MultiBarMode.Series;
            bar1.Name                   = "Bar1";
            bar1.DataLabelStyle.Visible = false;
            bar1.BorderStyle.Color      = Color.Crimson;
            bar1.FillStyle              = new NColorFillStyle(Color.Crimson);
            bar1.Values.FillRandomRange(Random, 5, 10, 40);

            // add the second bar
            NBarSeries bar2 = (NBarSeries)chart.Series.Add(SeriesType.Bar);

            bar2.MultiBarMode           = MultiBarMode.Series;
            bar2.Name                   = "Bar2";
            bar2.DataLabelStyle.Visible = false;
            bar2.BorderStyle.Color      = Color.PaleGreen;
            bar2.FillStyle              = new NColorFillStyle(Color.PaleGreen);
            bar2.Values.FillRandomRange(Random, 5, 30, 60);

            // add the third bar
            NBarSeries bar3 = (NBarSeries)chart.Series.Add(SeriesType.Bar);

            bar3.MultiBarMode           = MultiBarMode.Series;
            bar3.Name                   = "Bar3";
            bar3.DataLabelStyle.Visible = false;
            bar3.BorderStyle.Color      = Color.CornflowerBlue;
            bar3.FillStyle              = new NColorFillStyle(Color.CornflowerBlue);
            bar3.Values.FillRandomRange(Random, 5, 50, 80);

            // apply layout
            ApplyLayoutTemplate(0, nChartControl1, chart, title, nChartControl1.Legends[0]);
        }
        NDrawingDocument CreateDocument(int bookId)
        {
            NDrawingDocument document = new NDrawingDocument();

            //	setup the document
            document.AutoBoundsPadding         = new Nevron.Diagram.NMargins(0f, 7f, 7f, 7f);
            document.Style.FillStyle           = new NColorFillStyle(Color.White);
            document.Style.TextStyle.FillStyle = new NColorFillStyle(Color.DarkGray);
            document.Style.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Left;
            document.Style.StrokeStyle = new NStrokeStyle(0, Color.White);
            NStandardFrameStyle frame = document.BackgroundStyle.FrameStyle as NStandardFrameStyle;

            frame.InnerBorderColor   = Color.Gray;
            document.MeasurementUnit = NGraphicsUnit.Pixel;

            //	set up the shape factories
            NBasicShapesFactory bookItemsFactory = new NBasicShapesFactory(document);

            bookItemsFactory.DefaultSize = new NSizeF(320, 200);

            NCustomToolsData.NBookEntry[] books = NCustomToolsData.CreateBooks();
            NCustomToolsData.NBookEntry   book  = null;
            int length = books.Length;

            for (int i = 0; i < length; i++)
            {
                if (books[i].Id == bookId)
                {
                    book = books[i];
                    break;
                }
            }
            if (bookId == -1 || book == null)
            {
                document.Style.StrokeStyle = new NStrokeStyle(1, Color.Red);
                document.ActiveLayer.AddChild(bookItemsFactory.CreateShape(BasicShapes.Pentagram));
                document.SizeToContent();
                return(document);
            }

            //	create a table layout, which will align te thumbnail and the text lines
            //	in two columns
            NTableLayout mainLayout = new NTableLayout();

            mainLayout.Direction                = LayoutDirection.LeftToRight;
            mainLayout.ConstrainMode            = CellConstrainMode.Ordinal;
            mainLayout.MaxOrdinal               = 2;
            mainLayout.VerticalContentPlacement = ContentPlacement.Near;

            //	create a stack layout, which will align the text lines in rows
            NStackLayout textLayout = new NStackLayout();

            textLayout.Direction = LayoutDirection.TopToBottom;
            textLayout.HorizontalContentPlacement = ContentPlacement.Near;
            textLayout.VerticalSpacing            = 13;

            //	create a stack layout, which will align the stars in 5 columns
            NStackLayout starsLayout = new NStackLayout();

            starsLayout.Direction = LayoutDirection.LeftToRight;
            starsLayout.VerticalContentPlacement = ContentPlacement.Center;
            starsLayout.HorizontalSpacing        = 1;

            NLayoutContext layoutContext = new NLayoutContext();

            layoutContext.GraphAdapter         = new NShapeGraphAdapter();
            layoutContext.BodyAdapter          = new NShapeBodyAdapter(document);
            layoutContext.BodyContainerAdapter = new NDrawingBodyContainerAdapter(document);

            //	create the shapes for the book image and text lines
            NShape bookImageShape = bookItemsFactory.CreateShape(BasicShapes.Rectangle);

            bookImageShape.Width  = 240f;
            bookImageShape.Height = 240f;
            NImageFillStyle fs1 = new NImageFillStyle(HttpContext.Current.Server.MapPath(@"~\Images\CustomTools\" + book.ImageFile));

            fs1.TextureMappingStyle.MapLayout = MapLayout.Centered;
            NStyle.SetFillStyle(bookImageShape, fs1);

            NShape bookTitleShape = bookItemsFactory.CreateShape(BasicShapes.Rectangle);

            bookTitleShape.Text   = book.Title;
            bookTitleShape.Width  = 160f;
            bookTitleShape.Height = 32f;

            NShape bookAuthorShape = bookItemsFactory.CreateShape(BasicShapes.Rectangle);

            bookAuthorShape.Text   = "by " + book.Author;
            bookAuthorShape.Width  = 160f;
            bookAuthorShape.Height = 32f;

            NShape bookPriceShape = bookItemsFactory.CreateShape(BasicShapes.Rectangle);

            bookPriceShape.Text   = "Price: $" + book.Price.ToString();
            bookPriceShape.Width  = 160f;
            bookPriceShape.Height = 32f;

            //	create the star shapes
            NNodeList starShapes = new NNodeList();

            for (int i = 0; i < 5; i++)
            {
                NShape star = bookItemsFactory.CreateShape(BasicShapes.Pentagram);
                star.Width  = 10f;
                star.Height = 10f;
                if (i < book.Rating)
                {
                    star.Style.FillStyle = new NColorFillStyle(Color.Orange);
                }
                else
                {
                    star.Style.FillStyle = new NColorFillStyle(Color.LightGray);
                }
                starShapes.Add(star);
            }

            //	prepare to layout
            NBatchGroup bgroup = new NBatchGroup(document);

            //	create the stars group
            NGroup starsGroup = new NGroup();

            // group the star shapes
            bgroup.Build(starShapes);
            bgroup.Group(null, false, out starsGroup);

            // collect the text shapes
            NNodeList textShapes = new NNodeList();

            textShapes.Add(bookTitleShape);
            textShapes.Add(bookAuthorShape);
            textShapes.Add(bookPriceShape);
            textShapes.Add(starsGroup);

            //	create the text group
            NGroup textGroup = new NGroup();

            // group the text shapes
            bgroup.Build(textShapes);
            bgroup.Group(null, false, out textGroup);

            // collect the main layout shapes
            NNodeList mainElements = new NNodeList();

            mainElements.Add(bookImageShape);
            mainElements.Add(textGroup);

            //	create the main group
            NGroup mainGroup = new NGroup();

            // group the main elements
            bgroup.Build(mainElements);
            bgroup.Group(null, false, out mainGroup);

            document.ActiveLayer.AddChild(mainGroup);

            // size all text shapes to text
            bookTitleShape.SizeToText(new NMarginsF(6f, 0f, 6f, 0f));
            bookAuthorShape.SizeToText(new NMarginsF(6f, 0f, 6f, 0f));
            bookPriceShape.SizeToText(new NMarginsF(6f, 0f, 6f, 0f));

            // layout the star shapes
            starsLayout.Layout(starShapes, layoutContext);
            starsGroup.UpdateModelBounds();

            // perform layout on the text
            textLayout.Layout(textShapes, layoutContext);
            textGroup.UpdateModelBounds();

            // layout all elements
            mainLayout.Layout(mainElements, layoutContext);
            mainGroup.UpdateModelBounds();

            // correct the text left padding
            bookTitleShape.Location  = new NPointF(bookTitleShape.Location.X - 6f, bookTitleShape.Location.Y);
            bookAuthorShape.Location = new NPointF(bookAuthorShape.Location.X - 6f, bookAuthorShape.Location.Y);
            bookPriceShape.Location  = new NPointF(bookPriceShape.Location.X - 6f, bookPriceShape.Location.Y);

            document.SizeToContent();
            return(document);
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                LogarithmBaseTextBox.Text = "10";

                LabelFormatDropDownList.Items.Add("Default");
                LabelFormatDropDownList.Items.Add("Scientific");
                LabelFormatDropDownList.SelectedIndex = 0;
                RoundToTickMin.Checked = true;
                RoundToTickMax.Checked = true;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

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

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

            // configure the chart
            m_Chart            = nChartControl1.Charts[0];
            m_Chart.BoundsMode = BoundsMode.Fit;

            m_Chart.Location = new NPointL(
                new NLength(5, NRelativeUnit.ParentPercentage),
                new NLength(15, NRelativeUnit.ParentPercentage));
            m_Chart.Size = new NSizeL(
                new NLength(90, NRelativeUnit.ParentPercentage),
                new NLength(80, NRelativeUnit.ParentPercentage));
            m_Chart.BoundsMode = BoundsMode.Stretch;

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

            NLogarithmicScaleConfigurator logarithmicScale = new NLogarithmicScaleConfigurator();

            logarithmicScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            logarithmicScale.MinorGridStyle.LineStyle.Pattern = LinePattern.Dot;
            logarithmicScale.MinorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            logarithmicScale.MinorTickCount = 3;
            logarithmicScale.MajorTickMode  = MajorTickMode.CustomStep;

            // add a strip line style
            NScaleStripStyle stripStyle = new NScaleStripStyle();

            stripStyle.FillStyle = new NColorFillStyle(Color.Beige);
            stripStyle.SetShowAtWall(ChartWallType.Back, true);
            stripStyle.SetShowAtWall(ChartWallType.Left, true);
            stripStyle.Interlaced = true;
            logarithmicScale.StripStyles.Add(stripStyle);

            logarithmicScale.CustomStep = 1;

            m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = logarithmicScale;

            m_Line                        = (NLineSeries)m_Chart.Series.Add(SeriesType.Line);
            m_Line.Legend.Mode            = SeriesLegendMode.None;
            m_Line.InflateMargins         = false;
            m_Line.MarkerStyle.Visible    = true;
            m_Line.MarkerStyle.PointShape = PointShape.Cylinder;
            m_Line.MarkerStyle.Width      = new NLength(0.7f, NRelativeUnit.ParentPercentage);
            m_Line.MarkerStyle.Height     = new NLength(0.7f, NRelativeUnit.ParentPercentage);
            m_Line.MarkerStyle.AutoDepth  = true;
            m_Line.DataLabelStyle.Format  = "<value>";
            m_Line.DataLabelStyle.ArrowStrokeStyle.Color = Color.CornflowerBlue;

            NStandardFrameStyle frameStyle = m_Line.DataLabelStyle.TextStyle.BackplaneStyle.StandardFrameStyle;

            frameStyle.InnerBorderColor = Color.CornflowerBlue;

            m_Line.Values.Add(12);
            m_Line.Values.Add(100);
            m_Line.Values.Add(250);
            m_Line.Values.Add(500);
            m_Line.Values.Add(1500);
            m_Line.Values.Add(5500);
            m_Line.Values.Add(9090);

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

            styleSheet.Apply(nChartControl1.Document);

            UpdateScale();
        }
Example #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Clear the chart panels
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            NStandardFrameStyle controlFrameStyle = new NStandardFrameStyle();

            controlFrameStyle.OuterBorderWidth        = new NLength(0);
            controlFrameStyle.InnerBorderWidth        = new NLength(0);
            nChartControl1.BackgroundStyle.FrameStyle = controlFrameStyle;
            nChartControl1.Panels.Clear();

            // Create a background style to assign to the new panels
            NBackgroundStyle backroundStyle = new NBackgroundStyle();

            backroundStyle.FillStyle = new NColorFillStyle(Color.Transparent);
            NImageFrameStyle frameStyle = new NImageFrameStyle();

            frameStyle.BorderStyle = new NStrokeStyle(0, Color.White);
            //frameStyle.BorderStyle.Color = Color.Gray;
            frameStyle.BackgroundColor = Color.Transparent;
            frameStyle.Type            = ImageFrameType.Raised;
            backroundStyle.FrameStyle  = frameStyle;

            //Create a shadow style to assign to some items
            NShadowStyle shadowStyle = new NShadowStyle();

            shadowStyle.Type       = ShadowType.LinearBlur;
            shadowStyle.Color      = Color.FromArgb(80, 0, 0, 0);
            shadowStyle.FadeLength = new NLength(1);
            shadowStyle.Offset     = new NPointL(2, 2);

            // Create the label background panel
            NBackgroundDecoratorPanel labelBackgroundPanel = new NBackgroundDecoratorPanel();

            labelBackgroundPanel.Size            = new NSizeL(new NLength(0, NGraphicsUnit.Pixel), new NLength(15, NRelativeUnit.ParentPercentage));
            labelBackgroundPanel.DockMode        = PanelDockMode.Top;
            labelBackgroundPanel.DockMargins     = new NMarginsL(new NLength(3, NGraphicsUnit.Point), new NLength(3, NGraphicsUnit.Point), new NLength(3, NGraphicsUnit.Point), new NLength(3, NGraphicsUnit.Point));
            labelBackgroundPanel.BackgroundStyle = (NBackgroundStyle)backroundStyle.Clone();
            nChartControl1.Panels.Add(labelBackgroundPanel);

            // Create the legend background panel
            NBackgroundDecoratorPanel legendBackgroundPanel = new NBackgroundDecoratorPanel();

            legendBackgroundPanel.Size            = new NSizeL(new NLength(30, NRelativeUnit.ParentPercentage), new NLength(0, NGraphicsUnit.Pixel));
            legendBackgroundPanel.DockMode        = PanelDockMode.Right;
            legendBackgroundPanel.BackgroundStyle = (NBackgroundStyle)backroundStyle.Clone();
            legendBackgroundPanel.DockMargins     = new NMarginsL(new NLength(3, NGraphicsUnit.Point), new NLength(3, NGraphicsUnit.Point), new NLength(3, NGraphicsUnit.Point), new NLength(3, NGraphicsUnit.Point));
            nChartControl1.Panels.Add(legendBackgroundPanel);

            // Create the chart background panel
            NBackgroundDecoratorPanel chartBackgroundPanel = new NBackgroundDecoratorPanel();

            chartBackgroundPanel.BackgroundStyle = (NBackgroundStyle)backroundStyle.Clone();
            chartBackgroundPanel.DockMode        = PanelDockMode.Fill;
            chartBackgroundPanel.DockMargins     = new NMarginsL(new NLength(3, NGraphicsUnit.Point), new NLength(3, NGraphicsUnit.Point), new NLength(3, NGraphicsUnit.Point), new NLength(3, NGraphicsUnit.Point));
            nChartControl1.Panels.Add(chartBackgroundPanel);

            // Create the header label and host it in the label background panel
            NLabel header = new NLabel("Background Decorator Panel");

            header.TextStyle.FontStyle   = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            header.TextStyle.ShadowStyle = (NShadowStyle)shadowStyle.Clone();
            header.TextStyle.FillStyle   = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.LightBlue, Color.DarkSlateBlue);
            header.ContentAlignment      = ContentAlignment.MiddleCenter;
            header.DockMode    = PanelDockMode.Fill;
            header.BoundsMode  = BoundsMode.Fit;
            header.Location    = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));
            header.DockMargins = new NMarginsL(frameStyle.LightEffectSize, frameStyle.LightEffectSize, frameStyle.LightEffectSize, frameStyle.LightEffectSize);
            labelBackgroundPanel.ChildPanels.Add(header);

            // Create the legend and host it in the legend background panel
            NLegend legend = new NLegend();

            legend.DockMode         = PanelDockMode.Fill;
            legend.ContentAlignment = ContentAlignment.MiddleCenter;
            legend.DockMargins      = new NMarginsL(frameStyle.LightEffectSize, frameStyle.LightEffectSize, frameStyle.LightEffectSize, frameStyle.LightEffectSize);
            legend.FillStyle        = new NColorFillStyle(new NArgbColor(0, Color.White));
            NStrokeStyle borderStyle = new NStrokeStyle(0, Color.White);

            legend.HorizontalBorderStyle  = borderStyle;
            legend.VerticalBorderStyle    = borderStyle;
            legend.OuterBottomBorderStyle = borderStyle;
            legend.OuterLeftBorderStyle   = borderStyle;
            legend.OuterRightBorderStyle  = borderStyle;
            legend.OuterTopBorderStyle    = borderStyle;
            legendBackgroundPanel.ChildPanels.Add(legend);

            // Create a cartesian chart and host it in the chart background panel
            NChart chart = new NCartesianChart();

            chartBackgroundPanel.ChildPanels.Add(chart);

            chart.Axis(StandardAxis.Depth).Visible = false;
            chart.DisplayOnLegend = legend;
            chart.BoundsMode      = BoundsMode.Stretch;
            chart.DockMode        = PanelDockMode.Fill;
            chart.Margins         = new NMarginsL(2, 10, 2, 2);

            // add bar and change bar color
            NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);

            bar.Name                   = "Bar Series";
            bar.FillStyle              = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant2, Color.DarkRed, Color.Red);
            bar.BorderStyle.Width      = new NLength(0, NGraphicsUnit.Pixel);
            bar.ShadowStyle            = (NShadowStyle)shadowStyle.Clone();
            bar.DataLabelStyle.Visible = false;

            bar.AddDataPoint(new NDataPoint(10, "Electronics", new NColorFillStyle(Color.Tomato)));
            bar.AddDataPoint(new NDataPoint(20, "Medical", new NColorFillStyle(Color.Orange)));
            bar.AddDataPoint(new NDataPoint(30, "Clothing", new NColorFillStyle(Color.Yellow)));
            bar.AddDataPoint(new NDataPoint(25, "Energy", new NColorFillStyle(Color.YellowGreen)));
            bar.AddDataPoint(new NDataPoint(29, "Financial", new NColorFillStyle(Color.ForestGreen)));
            bar.Legend.Mode = SeriesLegendMode.DataPoints;
            bar.Legend.TextStyle.ShadowStyle = (NShadowStyle)shadowStyle.Clone();

            // init form controls
            if (!IsPostBack)
            {
                DockTitleDropDownList.Items.Add("Top");
                DockTitleDropDownList.Items.Add("Bottom");
                DockTitleDropDownList.SelectedIndex = 0;

                DockLegendDropDownList.Items.Add("Left");
                DockLegendDropDownList.Items.Add("Right");
                DockLegendDropDownList.SelectedIndex = 1;
            }
            else
            {
                if (DockTitleDropDownList.SelectedIndex == 0)
                {
                    labelBackgroundPanel.DockMode = PanelDockMode.Top;
                }
                else
                {
                    labelBackgroundPanel.DockMode = PanelDockMode.Bottom;
                }

                if (DockLegendDropDownList.SelectedIndex == 0)
                {
                    legendBackgroundPanel.DockMode = PanelDockMode.Left;
                }
                else
                {
                    legendBackgroundPanel.DockMode = PanelDockMode.Right;
                }
            }
        }