コード例 #1
0
        private void UpdateSheet()
        {
            NFillStyleSheetConfigurator fillStyleSheet = new NFillStyleSheetConfigurator();

            fillStyleSheet.Palette.SetPredefinedPalette((ChartPredefinedPalette)PaletteComboBox.SelectedIndex);

            fillStyleSheet.ControlBackgroundFillTemplate = CreateFillTemplateFromCombo(BackgroundFillTemplateComboBox);
            fillStyleSheet.LabelFillTemplate             = CreateFillTemplateFromCombo(LabelsFillTemplateComboBox);
            fillStyleSheet.WallFillTemplate      = CreateFillTemplateFromCombo(WallsFillTemplateComboBox);
            fillStyleSheet.SeriesFillTemplate    = CreateFillTemplateFromCombo(SeriesFillTemplateComboBox);
            fillStyleSheet.IndicatorFillTemplate = CreateFillTemplateFromCombo(IndicatorsFillTemplateComboBox);
            fillStyleSheet.MultiColorSeries      = MultiColorSeriesCheckBox.Checked;

            NStrokeStyleSheetConfigurator strokeStyleSheet = new NStrokeStyleSheetConfigurator();

            strokeStyleSheet.Palette.SetPredefinedPalette((ChartPredefinedPalette)PaletteComboBox.SelectedIndex);

            strokeStyleSheet.LabelStrokeTemplate     = CreateStrokeTemplateFromCombo(LabelsStrokeTemplateComboBox);
            strokeStyleSheet.IndicatorStrokeTemplate = CreateStrokeTemplateFromCombo(IndicatorsStrokeTemplateComboBox);
            strokeStyleSheet.MultiColorSeries        = MultiColorSeriesStrokeCheckBox.Checked;
            strokeStyleSheet.RulerStrokeTemplate     = CreateStrokeTemplateFromCombo(RulerStrokeTemplateComboBox);
            strokeStyleSheet.SeriesStrokeTemplate    = CreateStrokeTemplateFromCombo(SeriesStrokeTemplateComboBox);
            strokeStyleSheet.ApplyToDataLabels       = ApplyToDataLabelsCheckBox.Checked;

            NStyleSheet sheet = new NStyleSheet();

            fillStyleSheet.ConfigureSheet(sheet);
            strokeStyleSheet.ConfigureSheet(sheet);

            sheet.Apply(nChartControl1.Document);

            nChartControl1.Refresh();
        }
コード例 #2
0
        public override void Initialize()
        {
            base.Initialize();

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

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

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

            chart.Enable3D = true;
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft);
            chart.Axis(StandardAxis.Depth).Visible = false;

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

            stripStyle.SetShowAtWall(ChartWallType.Back, true);
            stripStyle.SetShowAtWall(ChartWallType.Left, true);
            stripStyle.Interlaced = true;
            ((NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator).StripStyles.Add(stripStyle);

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

            bar.FillStyle              = new NGradientFillStyle(Color.LightGray, Color.SlateBlue);
            bar.ShadowStyle.Type       = ShadowType.LinearBlur;
            bar.ShadowStyle.Offset     = new NPointL(3, 3);
            bar.ShadowStyle.Color      = Color.FromArgb(40, 0, 0, 0);
            bar.ShadowStyle.FadeLength = new NLength(2);

            bar.AddDataPoint(new NDataPoint(10, "Item 0"));
            bar.AddDataPoint(new NDataPoint(20, "Item 1"));
            bar.AddDataPoint(new NDataPoint(30, "Item 2"));
            bar.AddDataPoint(new NDataPoint(25, "Item 3"));
            bar.AddDataPoint(new NDataPoint(29, "Item 4"));
            bar.AddDataPoint(new NDataPoint(27, "Item 5"));

            // apply style sheet
            NFillStyleSheetConfigurator fillStyleSheet = new NFillStyleSheetConfigurator();

            fillStyleSheet.SeriesFillTemplate = new NGradientFillStyleTemplate(GradientStyle.Horizontal, GradientVariant.Variant1);
            fillStyleSheet.MultiColorSeries   = true;
            fillStyleSheet.Palette.SetPredefinedPalette(ChartPredefinedPalette.Nature);
            NStrokeStyleSheetConfigurator strokeStyleSheet = new NStrokeStyleSheetConfigurator();

            strokeStyleSheet.MultiColorSeries  = true;
            strokeStyleSheet.ApplyToDataLabels = false;
            strokeStyleSheet.Palette.SetPredefinedPalette(ChartPredefinedPalette.Nature);

            NStyleSheet styleSheet = new NStyleSheet();

            fillStyleSheet.ConfigureSheet(styleSheet);
            strokeStyleSheet.ConfigureSheet(styleSheet);
            styleSheet.Apply(bar);

            // add a different data label for data point 3
            NDataLabelStyle label = new NDataLabelStyle();

            label.Format = "Individual";
            label.TextStyle.FontStyle.Style          = FontStyle.Bold;
            label.TextStyle.FillStyle                = new NColorFillStyle(Color.Crimson);
            label.TextStyle.BackplaneStyle.Inflate   = new NSizeL(3, 3);
            label.TextStyle.BackplaneStyle.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant2, Color.White, Color.Lavender);
            bar.DataLabelStyles[3] = label;

            // init form controls
            FormatCombo.Items.Add("<value> <label>");
            FormatCombo.Items.Add("<index> <cumulative>");
            FormatCombo.Items.Add("<percent> <total>");

            VertAlignCombo.Items.Add("Center");
            VertAlignCombo.Items.Add("Top");
            VertAlignCombo.Items.Add("Bottom");

            DataLabelModeCombo.Items.Add("Edit Default Label");
            DataLabelModeCombo.Items.Add("Edit Data Label #3");
            DataLabelModeCombo.SelectedIndex = 0;

            // apply layout
            ConfigureStandardLayout(chart, title, null);
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DefaultFormatDropDown.Items.Add("[value] [label]");
                DefaultFormatDropDown.Items.Add("[index] [cumulative]");
                DefaultFormatDropDown.Items.Add("[percent] [total]");
                DefaultFormatDropDown.SelectedIndex = 0;

                DefaultVerticalAlignDropDown.Items.Add("Center");
                DefaultVerticalAlignDropDown.Items.Add("Top");
                DefaultVerticalAlignDropDown.Items.Add("Bottom");
                DefaultVerticalAlignDropDown.SelectedIndex = 1;

                DefaultLabelVisibleCheck.Checked     = true;
                DefaultBackplaneVisibleCheck.Checked = true;

                Label3FormatDropDown.Items.Add("Individual");
                Label3FormatDropDown.Items.Add("[value] [label]");
                Label3FormatDropDown.Items.Add("[index] [cumulative]");
                Label3FormatDropDown.Items.Add("[percent] [total]");
                Label3FormatDropDown.SelectedIndex = 0;

                Label3VerticalAlignDropDown.Items.Add("Center");
                Label3VerticalAlignDropDown.Items.Add("Top");
                Label3VerticalAlignDropDown.Items.Add("Bottom");
                Label3VerticalAlignDropDown.SelectedIndex = 1;

                Label3VisibleCheck.Checked     = true;
                Backplane3VisibleCheck.Checked = true;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Legends[0].Visible = false;

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

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

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

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

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

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

            bar.AddDataPoint(new NDataPoint(10, "Item A"));
            bar.AddDataPoint(new NDataPoint(20, "Item B"));
            bar.AddDataPoint(new NDataPoint(30, "Item C"));
            bar.AddDataPoint(new NDataPoint(25, "Item D"));
            bar.AddDataPoint(new NDataPoint(29, "Item E"));

            // add interlaced stripe
            NLinearScaleConfigurator linearScaleConfigurator = (NLinearScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
            NScaleStripStyle         stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.Beige), null, true, 0, 0, 1, 1);

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

            // apply style sheet
            NFillStyleSheetConfigurator fillStyleSheet = new NFillStyleSheetConfigurator();

            fillStyleSheet.SeriesFillTemplate = new NGradientFillStyleTemplate(GradientStyle.Horizontal, GradientVariant.Variant1);
            fillStyleSheet.MultiColorSeries   = true;
            fillStyleSheet.Palette.SetPredefinedPalette(ChartPredefinedPalette.Nature);
            NStrokeStyleSheetConfigurator strokeStyleSheet = new NStrokeStyleSheetConfigurator();

            strokeStyleSheet.MultiColorSeries  = true;
            strokeStyleSheet.ApplyToDataLabels = false;
            strokeStyleSheet.Palette.SetPredefinedPalette(ChartPredefinedPalette.Nature);

            NStyleSheet styleSheet = new NStyleSheet();

            fillStyleSheet.ConfigureSheet(styleSheet);
            strokeStyleSheet.ConfigureSheet(styleSheet);
            styleSheet.Apply(bar);

            // add a different data label for data point 3
            NDataLabelStyle label = new NDataLabelStyle();

            label.TextStyle.FontStyle.Style          = FontStyle.Bold;
            label.TextStyle.FillStyle                = new NColorFillStyle(Color.Crimson);
            label.TextStyle.BackplaneStyle.Inflate   = new NSizeL(3, 3);
            label.TextStyle.BackplaneStyle.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant2, Color.White, Color.Lavender);
            bar.DataLabelStyles[3] = label;

            label.Format    = WebExamplesUtilities.GetXmlFormatString(Label3FormatDropDown.SelectedItem.Text);
            label.VertAlign = (VertAlign)Label3VerticalAlignDropDown.SelectedIndex;
            label.Visible   = Label3VisibleCheck.Checked;
            label.TextStyle.BackplaneStyle.Visible = Backplane3VisibleCheck.Checked;

            bar.DataLabelStyle.Format    = WebExamplesUtilities.GetXmlFormatString(DefaultFormatDropDown.SelectedItem.Text);
            bar.DataLabelStyle.VertAlign = (VertAlign)DefaultVerticalAlignDropDown.SelectedIndex;
            bar.DataLabelStyle.Visible   = DefaultLabelVisibleCheck.Checked;
            bar.DataLabelStyle.TextStyle.BackplaneStyle.Visible = DefaultBackplaneVisibleCheck.Checked;

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