Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        private void UpdateLegendItems()
        {
            if (nChartControl1 == null)
            {
                return;
            }

            NLegend legend = nChartControl1.Legends[0];

            legend.Data.Items.Clear();

            Array         markShapes = Enum.GetValues(typeof(LegendMarkShape));
            NChartPalette palette    = new NChartPalette(ChartPredefinedPalette.Fresh);

            for (int i = 0; i < markShapes.Length; i++)
            {
                NLegendItemCellData licd      = new NLegendItemCellData();
                LegendMarkShape     markShape = (LegendMarkShape)markShapes.GetValue(i);

                licd.Text          = "Some very long text about mark shape [" + markShape.ToString() + "]";
                licd.MarkShape     = markShape;
                licd.MarkFillStyle = new NColorFillStyle(palette.SeriesColors[i % palette.SeriesColors.Count]);

                licd.TextFitMode  = (LegendTextFitMode)TextFitModeComboBox.SelectedIndex;
                licd.MaxTextWidth = new NLength((float)MaximumLegendItemWidthUpDown.Value);

                legend.Data.Items.Add(licd);
            }

            nChartControl1.Refresh();
        }
        private void CreateCustomLegend3(NDockPanel container)
        {
            NLegend markShapesBackground = CreateLegend(container, "Mark Shapes (Margins, Background)");

            Array         markShapes = Enum.GetValues(typeof(LegendMarkShape));
            NChartPalette palette    = new NChartPalette(ChartPredefinedPalette.Fresh);

            for (int i = 0; i < markShapes.Length; i++)
            {
                NLegendItemCellData licd      = new NLegendItemCellData();
                LegendMarkShape     markShape = (LegendMarkShape)markShapes.GetValue(i);

                licd.Text = markShape.ToString();
                licd.TextStyle.FillStyle        = new NColorFillStyle(Color.White);
                licd.TextStyle.FontStyle.EmSize = new NLength(10 + i);
                licd.MarkShape             = markShape;
                licd.MarkFillStyle         = new NColorFillStyle(Color.White);
                licd.MarkBorderStyle.Width = new NLength(0);
                licd.MarkLineStyle.Width   = new NLength(0);
                licd.BackgroundFillStyle   = new NColorFillStyle(palette.SeriesColors[i % palette.SeriesColors.Count]);

                markShapesBackground.Data.Items.Add(licd);
            }

            // increase teh margins around each cell
            markShapesBackground.Data.CellMargins = new NMarginsL(10, 10, 10, 10);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // confgigure chart
            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel title = new NLabel("Legend Item Text Fit Mode");

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

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

            legend.Header.Text     = "Maximum Legend Item Text Size";
            legend.Mode            = LegendMode.Manual;
            legend.Data.ExpandMode = LegendExpandMode.HorzWrap;
            legend.DockMode        = PanelDockMode.Top;
            legend.Margins         = new NMarginsL(20, 20, 20, 20);
            nChartControl1.Panels.Add(legend);

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

            styleSheet.Apply(nChartControl1.Document);

            // init controls

            if (!IsPostBack)
            {
                WebExamplesUtilities.FillComboWithEnumNames(LegendItemTextFitModeDropDownList, typeof(LegendTextFitMode));
                WebExamplesUtilities.FillComboWithValues(LegendItemMaximumWidthDropDownList, 50, 150, 50);
            }

            // Update legend items
            Array         markShapes = Enum.GetValues(typeof(LegendMarkShape));
            NChartPalette palette    = new NChartPalette(ChartPredefinedPalette.Nevron);

            for (int i = 0; i < markShapes.Length; i++)
            {
                NLegendItemCellData licd      = new NLegendItemCellData();
                LegendMarkShape     markShape = (LegendMarkShape)markShapes.GetValue(i);

                licd.Text          = "Some very long text about mark shape [" + markShape.ToString() + "]";
                licd.MarkShape     = markShape;
                licd.MarkFillStyle = new NColorFillStyle(palette.SeriesColors[i % palette.SeriesColors.Count]);

                licd.TextFitMode  = (LegendTextFitMode)LegendItemTextFitModeDropDownList.SelectedIndex;
                licd.MaxTextWidth = new NLength((float)(LegendItemMaximumWidthDropDownList.SelectedIndex + 1) * 50);

                legend.Data.Items.Add(licd);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // confgigure chart
            nChartControl1.Panels.Clear();

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

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

            NDockPanel container = new NDockPanel();

            container.DockMode = PanelDockMode.Fill;
            container.Margins  = new NMarginsL(5, 5, 5, 5);
            container.PositionChildPanelsInContentBounds = true;
            nChartControl1.Panels.Add(container);

            {
                NLegend markShapesNoStroke = CreateLegend(container, "Mark Shapes, Margins, Background");

                Array         markShapes = Enum.GetValues(typeof(LegendMarkShape));
                NChartPalette palette    = new NChartPalette(ChartPredefinedPalette.Nevron);

                for (int i = 0; i < markShapes.Length; i++)
                {
                    NLegendItemCellData licd      = new NLegendItemCellData();
                    LegendMarkShape     markShape = (LegendMarkShape)markShapes.GetValue(i);

                    licd.Text = markShape.ToString();
                    licd.TextStyle.FillStyle        = new NColorFillStyle(Color.White);
                    licd.TextStyle.FontStyle.EmSize = new NLength(8);
                    licd.MarkShape             = markShape;
                    licd.MarkFillStyle         = new NColorFillStyle(Color.White);
                    licd.MarkBorderStyle.Width = new NLength(0);
                    licd.MarkLineStyle.Width   = new NLength(0);
                    licd.BackgroundFillStyle   = new NColorFillStyle(palette.SeriesColors[i % palette.SeriesColors.Count]);

                    markShapesNoStroke.Data.Items.Add(licd);
                }

                // increase teh margins around each cell
                markShapesNoStroke.Data.CellMargins = new NMarginsL(5, 5, 5, 5);
            }

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

            styleSheet.Apply(nChartControl1.Document);
        }
        private void CreateCustomLegend1(NDockPanel container)
        {
            NLegend markShapesLegend = CreateLegend(container, "Mark Shapes");

            Array         markShapes = Enum.GetValues(typeof(LegendMarkShape));
            NChartPalette palette    = new NChartPalette(ChartPredefinedPalette.Fresh);

            for (int i = 0; i < markShapes.Length; i++)
            {
                NLegendItemCellData licd      = new NLegendItemCellData();
                LegendMarkShape     markShape = (LegendMarkShape)markShapes.GetValue(i);

                licd.Text          = markShape.ToString();
                licd.MarkShape     = markShape;
                licd.MarkFillStyle = new NColorFillStyle(palette.SeriesColors[i % palette.SeriesColors.Count]);

                markShapesLegend.Data.Items.Add(licd);
            }
        }