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

            palette.SetPredefinedPalette(ChartPredefinedPalette.Dark);

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

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

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

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

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

            NLegend legend = nChartControl1.Legends[0];

            legend.SetPredefinedLegendStyle(PredefinedLegendStyle.BottomRight);

            NFunnelChart chart = new NFunnelChart();

            nChartControl1.Charts.Clear();
            nChartControl1.Charts.Add(chart);

            NFunnelSeries funnel = (NFunnelSeries)chart.Series.Add(SeriesType.Funnel);

            funnel.BorderStyle.Color      = Color.LemonChiffon;
            funnel.Legend.DisplayOnLegend = legend;
            funnel.Legend.Mode            = SeriesLegendMode.DataPoints;
            funnel.DataLabelStyle.Format  = "<percent>";
            funnel.ShadowStyle.Type       = ShadowType.GaussianBlur;
            funnel.ShadowStyle.Color      = Color.FromArgb(50, 0, 0, 0);
            funnel.ShadowStyle.Offset     = new NPointL(5, 5);
            funnel.ShadowStyle.FadeLength = new NLength(6);

            funnel.Values.Add(20.0);
            funnel.Values.Add(10.0);
            funnel.Values.Add(15.0);
            funnel.Values.Add(7.0);
            funnel.Values.Add(28.0);

            funnel.Labels.Add("Awareness");
            funnel.Labels.Add("First Hear");
            funnel.Labels.Add("Further Learn");
            funnel.Labels.Add("Liking");
            funnel.Labels.Add("Decision");

            // apply palette to funnel segments
            NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Fresh);

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

            // init form controls
            LabelModeCombo.FillFromEnum(typeof(FunnelLabelMode));
            LabelModeCombo.SelectedIndex = 0;

            FunnelGapScroll.Value   = (int)funnel.FunnelPointGap;
            NeckWidthScroll.Value   = (int)funnel.NeckWidthPercent;
            NeckHeightScroll.Value  = (int)funnel.NeckHeightPercent;
            ArrowLengthScroll.Value = (int)funnel.DataLabelStyle.ArrowLength.Value;
        }
        protected void nChartControl1_AsyncClick(object sender, EventArgs e)
        {
            NHitTestResult result = nChartControl1.HitTest(e as NCallbackMouseEventArgs);

            if (result.ChartElement == ChartElement.DataPoint)
            {
                NBarSeries barSeries = result.Series as NBarSeries;
                barSeries.FillStyles.Clear();
                NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Nevron);
                barSeries.FillStyles[result.DataPointIndex] = new NColorFillStyle(palette.SeriesColors[1]);

                SelectedDataPointIndex = result.DataPointIndex;

                DateTime date = startDate;
                barSeries.InteractivityStyles.Clear();
                int lengthDays = hitsPerDayPerRegion.Length;
                for (int i = 0; i < lengthDays; i++)
                {
                    int totalHits     = 0;
                    int lengthRegions = hitsPerDayPerRegion[i].Length;
                    for (int j = 0; j < lengthRegions; j++)
                    {
                        totalHits += hitsPerDayPerRegion[i][j];
                    }

                    if (SelectedDataPointIndex != i)
                    {
                        barSeries.InteractivityStyles.Add(i, new NInteractivityStyle(true, i.ToString(), string.Format("{0}: {1}", date.ToString("dd/MMM/yyyy"), totalHits), CursorType.Hand));
                    }

                    date = date.AddDays(1);
                }
            }
        }
Exemple #6
0
        private void ProcessMouseEvent(object sender, EventArgs e, Color c)
        {
            NHitTestResult result = nChartControl1.HitTest(e as NCallbackMouseEventArgs);

            if (result.ChartElement == ChartElement.DataPoint)
            {
                switch (result.Chart.Tag.ToString())
                {
                case "BarChart":
                    NChartPalette palette        = new NChartPalette(ChartPredefinedPalette.Nevron);
                    Color         highlightColor = palette.SeriesColors[5];

                    NBarSeries barSeries = result.Series as NBarSeries;
                    foreach (NBarSeries series in nChartControl1.Charts[0].Series)
                    {
                        series.FillStyles.Clear();
                        series.BorderStyles.Clear();
                    }
                    barSeries.FillStyles[result.DataPointIndex]   = new NColorFillStyle(c);
                    barSeries.BorderStyles[result.DataPointIndex] = new NStrokeStyle(1, c);

                    int nCount = nChartControl1.Panels.Count;
                    for (int i = 0; i < nCount; i++)
                    {
                        if (nChartControl1.Panels[i] is NRoundedRectangularCallout)
                        {
                            nChartControl1.Panels.RemoveAt(i);
                        }
                    }

                    NRoundedRectangularCallout m_RoundedRectangularCallout = new NRoundedRectangularCallout();
                    m_RoundedRectangularCallout.ArrowLength      = new NLength(10, NRelativeUnit.ParentPercentage);
                    m_RoundedRectangularCallout.FillStyle        = new NGradientFillStyle(Color.FromArgb(255, Color.White), Color.FromArgb(125, highlightColor));
                    m_RoundedRectangularCallout.UseAutomaticSize = true;
                    m_RoundedRectangularCallout.Orientation      = 45;
                    m_RoundedRectangularCallout.Anchor           = new NDataPointAnchor(barSeries, result.DataPointIndex, ContentAlignment.TopRight, StringAlignment.Center);
                    m_RoundedRectangularCallout.Text             = ((NDataPoint)result.Object)[DataPointValue.Y].ToString();
                    nChartControl1.Panels.Add(m_RoundedRectangularCallout);


                    break;

                case "PieChart":
                    NPieSeries pieSeries = result.Series as NPieSeries;
                    pieSeries.Detachments.Clear();
                    for (int i = 0; i < pieSeries.Values.Count; i++)
                    {
                        if (i == result.DataPointIndex)
                        {
                            pieSeries.Detachments.Add(15);
                        }
                        else
                        {
                            pieSeries.Detachments.Add(0);
                        }
                    }
                    break;
                }
            }
        }
        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);
            }
        }
Exemple #8
0
        private void ColorFillModeComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            switch (ColorFillModeComboBox.SelectedIndex)
            {
            case 0:
            {
                // custom color filling -> assign colors to each group (child nodes will inherit that fill)
                NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Bright);

                int industryIndex = 0;
                foreach (NGroupTreeMapNode industryTreeMapNode in m_TreeMap.RootTreeMapNode.ChildNodes)
                {
                    foreach (NTreeMapNode companyTreeMapNode in industryTreeMapNode.ChildNodes)
                    {
                        companyTreeMapNode.FillStyle = new NColorFillStyle(palette.SeriesColors[(industryIndex) % palette.SeriesColors.Count]);
                    }

                    industryIndex++;
                }
            }
            break;

            case 1:
            {
                // palette filling -> remove all fill styles assigned to nodes
                foreach (NGroupTreeMapNode industryTreeMapNode in m_TreeMap.RootTreeMapNode.ChildNodes)
                {
                    industryTreeMapNode.Palette = null;

                    foreach (NTreeMapNode companyTreeMapNode in industryTreeMapNode.ChildNodes)
                    {
                        companyTreeMapNode.FillStyle = null;
                    }
                }
            }
            break;

            case 2:
            {
                // palette filling -> remove all fill styles assigned to nodes
                foreach (NGroupTreeMapNode industryTreeMapNode in m_TreeMap.RootTreeMapNode.ChildNodes)
                {
                    NPalette palette = new NPalette();
                    palette.Mode = PaletteMode.AutoMinMaxColor;
                    industryTreeMapNode.Palette = palette;

                    foreach (NTreeMapNode companyTreeMapNode in industryTreeMapNode.ChildNodes)
                    {
                        companyTreeMapNode.FillStyle = null;
                    }
                }
            }
            break;
            }

            nChartControl1.Refresh();
        }
Exemple #9
0
        void SetDataPointColors(NSeries series)
        {
            NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Fresh);

            for (int i = 0; i < 5; i++)
            {
                series.FillStyles[i] = new NColorFillStyle(palette.SeriesColors[i]);
            }
        }
        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);
        }
Exemple #11
0
        private void FillData()
        {
            int dataPointCount = 10000;
            int lineCount      = 5;

            NChart chart = nChartControl1.Charts[0];

            chart.Series.Clear();
            Random random = new Random();

            NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Fresh);

            for (int lineIndex = 0; lineIndex < lineCount; lineIndex++)
            {
                // setup surface series
                NVertexSurfaceSeries surface = new NVertexSurfaceSeries();
                chart.Series.Add(surface);

                surface.Name = "Surface";
                surface.SyncPaletteWithAxisScale       = false;
                surface.PaletteSteps                   = 8;
                surface.ValueFormatter.FormatSpecifier = "0.00";
                surface.FillMode        = SurfaceFillMode.CustomColors;
                surface.FrameMode       = SurfaceFrameMode.Dots;
                surface.FrameColorMode  = SurfaceFrameColorMode.CustomColors;
                surface.VertexPrimitive = VertexPrimitive.LineStrip;
                surface.Data.UseColors  = true;
                surface.Data.SetCapacity(dataPointCount);

                double x = 0.1;
                double y = 0;
                double z = 0;
                double a = 10.0;
                double b = 18 + lineIndex;                 // 28.0 - ;
                double c = (lineIndex + 3) / 3.0;          //8.0
                double t = lineIndex * (0.01 / lineCount) + 0.01;

                Color color1 = palette.SeriesColors[lineIndex % palette.SeriesColors.Count];
                Color color2 = palette.SeriesColors[(lineIndex + 1) % palette.SeriesColors.Count];

                for (int dataPointIndex = 0; dataPointIndex < dataPointCount; dataPointIndex++)
                {
                    float xt = (float)(x + t * a * (y - x));
                    float yt = (float)(y + t * (x * (b - z) - y));
                    float zt = (float)(z + t * (x * y - c * z));

                    surface.Data.AddValueColor(xt, yt, zt, InterpolateColors(color1, color2, (float)((yt + 40.0) / 80.0)));

                    x = xt;
                    y = yt;
                    z = zt;
                }
            }
        }
        private void ResetButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            int gridSizeX = GetGridSizeX();
            int gridSizeY = GetGridSizeY();

            NChart chart = nChartControl1.Charts[0];

            chart.Width = gridSizeX;
            chart.Depth = gridSizeY;

            chart.Series.Clear();

            m_Matrix = new double[gridSizeY][];

            for (int i = 0; i < gridSizeY; i++)
            {
                m_Matrix[i] = new double[gridSizeX];
            }

            NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Fresh);

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

            nChartControl1.Refresh();
        }
        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);
            }
        }
Exemple #14
0
        private void GenerateData(NFunnelSeries funnel)
        {
            funnel.ClearDataPoints();

            double        dSizeX  = 100;
            NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Fresh);

            for (int i = 0; i < 10; i++)
            {
                funnel.Values.Add(Random.NextDouble() + 1);
                funnel.XSizes.Add(dSizeX);
                funnel.FillStyles[i] = new NColorFillStyle(palette.SeriesColors[i % palette.SeriesColors.Count]);

                dSizeX -= Random.NextDouble() * 9;
            }

            funnel.Values.Add(0.0);
            funnel.XSizes.Add(dSizeX);
        }
Exemple #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                WebExamplesUtilities.FillComboWithEnumNames(VerticalFillModeDropDownList, typeof(TreeMapVerticalFillMode));
                VerticalFillModeDropDownList.SelectedIndex = (int)TreeMapVerticalFillMode.Default;

                WebExamplesUtilities.FillComboWithEnumNames(HorizontalFillModeDropDownList, typeof(TreeMapHorizontalFillMode));
                HorizontalFillModeDropDownList.SelectedIndex = (int)TreeMapVerticalFillMode.Default;

                ColorModeDropDownList.Items.Add("Custom");
                ColorModeDropDownList.Items.Add("Common Palette");
                ColorModeDropDownList.Items.Add("Group Palette");
                ColorModeDropDownList.SelectedIndex = 1;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;


            // set a chart title
            NLabel title = new NLabel("Tree Map");

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

            NTreeMapChart treeMap = new NTreeMapChart();

            nChartControl1.Panels.Add(treeMap);
            treeMap.DockMode = PanelDockMode.Fill;

            XmlDocument document = LoadData();

            foreach (XmlElement industry in document.DocumentElement)
            {
                NGroupTreeMapNode treeMapSeries = new NGroupTreeMapNode();

                treeMapSeries.StrokeStyle = new NStrokeStyle(4, Color.Black);
                treeMapSeries.Padding     = new NMarginsL(2.0f);

                treeMap.RootTreeMapNode.ChildNodes.Add(treeMapSeries);

                treeMapSeries.Label = industry.Attributes["Name"].Value;
                treeMapSeries.InteractivityStyle = new NInteractivityStyle(treeMapSeries.Label);

                foreach (XmlElement company in industry.ChildNodes)
                {
                    double value  = double.Parse(company.Attributes["Size"].Value);
                    double change = double.Parse(company.Attributes["Change"].Value);
                    string label  = company.Attributes["Name"].Value;

                    NValueTreeMapNode node = new NValueTreeMapNode(value, change, label);
                    node.InteractivityStyle = new NInteractivityStyle(label);
                    //						node.FillStyle = new NColorFillStyle(Color.Green);
                    treeMapSeries.ChildNodes.Add(node);
                }
            }

            nChartControl1.Controller.Tools.Add(new NTooltipTool());

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

            // update from from controls
            treeMap.RootTreeMapNode.HorizontalFillMode = (TreeMapHorizontalFillMode)HorizontalFillModeDropDownList.SelectedIndex;
            treeMap.RootTreeMapNode.VerticalFillMode   = (TreeMapVerticalFillMode)VerticalFillModeDropDownList.SelectedIndex;

            switch (ColorModeDropDownList.SelectedIndex)
            {
            case 0:
            {
                // custom color filling -> assign colors to each group (child nodes will inherit that fill)
                NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Bright);

                int industryIndex = 0;
                foreach (NGroupTreeMapNode industryTreeMapNode in treeMap.RootTreeMapNode.ChildNodes)
                {
                    foreach (NTreeMapNode companyTreeMapNode in industryTreeMapNode.ChildNodes)
                    {
                        companyTreeMapNode.FillStyle = new NColorFillStyle(palette.SeriesColors[(industryIndex) % palette.SeriesColors.Count]);
                    }

                    industryIndex++;
                }
            }
            break;

            case 1:
            {
                // palette filling -> remove all fill styles assigned to nodes
                foreach (NGroupTreeMapNode industryTreeMapNode in treeMap.RootTreeMapNode.ChildNodes)
                {
                    industryTreeMapNode.Palette = null;

                    foreach (NTreeMapNode companyTreeMapNode in industryTreeMapNode.ChildNodes)
                    {
                        companyTreeMapNode.FillStyle = null;
                    }
                }
            }
            break;

            case 2:
            {
                // palette filling -> remove all fill styles assigned to nodes
                foreach (NGroupTreeMapNode industryTreeMapNode in treeMap.RootTreeMapNode.ChildNodes)
                {
                    NPalette palette = new NPalette();
                    palette.Mode = PaletteMode.AutoMinMaxColor;
                    industryTreeMapNode.Palette = palette;

                    foreach (NTreeMapNode companyTreeMapNode in industryTreeMapNode.ChildNodes)
                    {
                        companyTreeMapNode.FillStyle = null;
                    }
                }
            }
            break;
            }
        }
        public override void Initialize()
        {
            base.Initialize();

            nChartControl1.Panels.Clear();

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

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

            NChart chart = new NPieChart();

            nChartControl1.Panels.Add(chart);

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

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

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

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

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

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

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

            palette.SetPredefinedPalette(ChartPredefinedPalette.Winter);

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

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

            SetPieDefaultFillStyles();

            m_Pie.PieStyle = PieStyle.SmoothEdgePie;

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

            // subscribe for control events
            nChartControl1.MouseDown += new MouseEventHandler(ChartControl_MouseDown);
            nChartControl1.MouseMove += new MouseEventHandler(ChartControl_MouseMove);
        }
        void CreatePreviewChart()
        {
            nChartControl1.HttpHandlerCallback = new PreviewHttpHandlerCallback();

            if (nChartControl1.RequiresInitialization)
            {
                nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
                nChartControl1.Legends.Clear();

                // set a chart title
                NLabel header = nChartControl1.Labels.AddHeader("Wave Preview");
                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(3, NRelativeUnit.ParentPercentage),
                    new NLength(3, NRelativeUnit.ParentPercentage));

                // setup a Smooth Line chart
                NCartesianChart chart = nChartControl1.Charts[0] as NCartesianChart;
                chart.BoundsMode = BoundsMode.Stretch;
                chart.Location   = new NPointL(
                    new NLength(4, NRelativeUnit.ParentPercentage),
                    new NLength(25, NRelativeUnit.ParentPercentage));
                chart.Size = new NSizeL(
                    new NLength(88, NRelativeUnit.ParentPercentage),
                    new NLength(75, NRelativeUnit.ParentPercentage));

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

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

                // add interlace stripe to the Y axis
                NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.FromArgb(0xfe, 0xed, 0xe2)), null, true, 0, 0, 1, 1);
                stripStyle.Interlaced = true;
                stripStyle.SetShowAtWall(ChartWallType.Back, true);
                stripStyle.SetShowAtWall(ChartWallType.Left, true);
                scaleY.StripStyles.Add(stripStyle);

                // add the line
                NSmoothLineSeries line = (NSmoothLineSeries)chart.Series.Add(SeriesType.SmoothLine);
                line.Name                   = "Wave";
                line.Legend.Mode            = SeriesLegendMode.None;
                line.UseXValues             = false;
                line.UseZValues             = false;
                line.InflateMargins         = true;
                line.DataLabelStyle.Visible = false;
                line.MarkerStyle.Visible    = false;
                line.BorderStyle.Width      = new NLength(1, NGraphicsUnit.Pixel);

                // initialize data points
                for (int i = 0; i < waveDataLenth; i++)
                {
                    line.Values.Add(waveData[i]);
                }

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

                // select a default window
                NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Nevron);
                Color         selectionBorderColor = palette.SeriesColors[2];
                Color         selectionFillColor   = Color.FromArgb(64, palette.SeriesColors[1]);

                NRangeSelection selection = new NRangeSelection((int)StandardAxis.PrimaryX, (int)StandardAxis.PrimaryY);
                selection.BorderStyle         = new NStrokeStyle(1, selectionBorderColor);
                selection.FillStyle           = new NColorFillStyle(selectionFillColor);
                selection.HorizontalAxisRange = new NRange1DD(0, defaultDataWindowWidth);
                selection.VerticalAxisRange   = new NRange1DD(-waveDataWave1Factor, waveDataWave1Factor);
                selection.Visible             = true;
                chart.RangeSelections.Add(selection);
            }
        }
        public override void Initialize()
        {
            base.Initialize();

            nChartControl1.Panels.Clear();

            // set a chart title
            NLabel title = new NLabel("Bank Product and Service Volume Change vs. Last Year<br/> <font size = '9pt'>Demonstrates how to use the view range inflate mode property</font>");

            title.TextStyle.TextFormat = TextFormat.XML;
            title.DockMode             = PanelDockMode.Top;
            title.TextStyle.FontStyle  = new NFontStyle("Times New Roman", 18, FontStyle.Italic);
            title.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Center;
            title.ContentAlignment = ContentAlignment.BottomCenter;
            title.Location         = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));
            title.Margins          = new NMarginsL(10, 10, 10, 10);

            nChartControl1.Panels.Add(title);

            // add some data to the control
            NCartesianChart chart = new NCartesianChart();

            chart.DockMode   = PanelDockMode.Fill;
            chart.BoundsMode = BoundsMode.Stretch;

            NBarSeries bar = new NBarSeries();

            bar.DataLabelStyle.Visible = false;

            NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Fresh);

            bar.Values.Add(100);
            bar.FillStyles[0] = new NColorFillStyle(palette.SeriesColors[0]);

            bar.Values.Add(200);
            bar.FillStyles[1] = new NColorFillStyle(palette.SeriesColors[0]);

            bar.Values.Add(1100);
            bar.FillStyles[2] = new NColorFillStyle(palette.SeriesColors[0]);

            bar.Values.Add(-200);
            bar.FillStyles[3] = new NColorFillStyle(palette.SeriesColors[1]);

            bar.Values.Add(200);
            bar.FillStyles[4] = new NColorFillStyle(palette.SeriesColors[1]);

            bar.Values.Add(1800);
            bar.FillStyles[5] = new NColorFillStyle(palette.SeriesColors[1]);

            bar.Values.Add(1000);
            bar.FillStyles[6] = new NColorFillStyle(palette.SeriesColors[1]);

            bar.Values.Add(-320);
            bar.FillStyles[7] = new NColorFillStyle(palette.SeriesColors[1]);

            chart.Series.Add(bar);

            chart.Margins = new NMarginsL(10, 0, 10, 10);

            // configure y axis
            NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).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);

            // configure the x axis
            NHierarchicalScaleConfigurator hierarchicalScale = new NHierarchicalScaleConfigurator();

            hierarchicalScale.CreateSeparatorForEachLevel = false;

            // create utilization group
            NHierarchicalScaleNode utilization = new NHierarchicalScaleNode(0, "Cash Utilisation");

            utilization.LabelStyle.TickMode = RangeLabelTickMode.Separators;
            utilization.LabelStyle.TextStyle.FontStyle.EmSize = new NLength(13);
            utilization.LabelStyle.TextStyle.FontStyle.Style  = FontStyle.Bold;

            utilization.ChildNodes.Add(CreateSubScaleNode("Cash at ATM", true, false));
            utilization.ChildNodes.Add(CreateSubScaleNode("Cash at desk", true, false));
            utilization.ChildNodes.Add(CreateSubScaleNode("Cash at other banks' ATM networks", true, false));
            hierarchicalScale.Nodes.Add(utilization);

            // create payments group
            NHierarchicalScaleNode payments = new NHierarchicalScaleNode(0, "Payments");

            payments.LabelStyle.TickMode = RangeLabelTickMode.Separators;
            payments.LabelStyle.TextStyle.FontStyle.EmSize = new NLength(13);
            payments.LabelStyle.TextStyle.FontStyle.Style  = FontStyle.Bold;

            payments.ChildNodes.Add(CreateSubScaleNode("Cheque", true, false));
            payments.ChildNodes.Add(CreateSubScaleNode("Direct debit", true, false));
            payments.ChildNodes.Add(CreateSubScaleNode("External wire transfer", true, false));
            payments.ChildNodes.Add(CreateSubScaleNode("Internal wire transfer", true, false));
            payments.ChildNodes.Add(CreateSubScaleNode("Standing order ", true, true));
            hierarchicalScale.Nodes.Add(payments);

            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = hierarchicalScale;
            nChartControl1.Panels.Add(chart);

            // update form controls
            NAxis yAxis = nChartControl1.Charts[0].Axis(StandardAxis.PrimaryY);
            NNumericScaleConfigurator scale = (NNumericScaleConfigurator)yAxis.ScaleConfigurator;

            scale.Title.Text = "Volume in Thousands USD";

            m_Updating = true;

            InflateViewRangeMinCheckBox.Checked = scale.InflateViewRangeBegin;
            InflateViewRangeMaxCheckBox.Checked = scale.InflateViewRangeEnd;

            ViewRangeInflateModeComboBox.FillFromEnum(typeof(ScaleViewRangeInflateMode));
            ViewRangeInflateModeComboBox.SelectedIndex = (int)scale.ViewRangeInflateMode;

            LogicalInflateMinNumericUpDown.Value = (decimal)scale.LogicalInflate.Begin;
            LogicalInflateMaxNumericUpDown.Value = (decimal)scale.LogicalInflate.End;

            AbsoluteInflateMinNumericUpDown.Value = (decimal)scale.AbsoluteInflate.Begin.Value;
            AbsoluteInflateMaxNumericUpDown.Value = (decimal)scale.AbsoluteInflate.End.Value;

            m_Updating = false;

            UpdateScale();
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            nChartControl1.Settings.JitterMode = JitterMode.Enabled;
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

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

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

            NLegend legend = nChartControl1.Legends[0];

            legend.SetPredefinedLegendStyle(PredefinedLegendStyle.BottomRight);

            NFunnelChart chart = new NFunnelChart();

            chart.BoundsMode = BoundsMode.Fit;
            chart.Location   = new NPointL(new NLength(5, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage));
            chart.Size       = new NSizeL(new NLength(85, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage));
            chart.Enable3D   = true;
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights);
            chart.Projection.SetPredefinedProjection(PredefinedProjection.Perspective);
            chart.Projection.Elevation = 18;

            nChartControl1.Charts.Clear();
            nChartControl1.Charts.Add(chart);

            NFunnelSeries funnel = (NFunnelSeries)chart.Series.Add(SeriesType.Funnel);

            funnel.BorderStyle.Color      = Color.LemonChiffon;
            funnel.Legend.DisplayOnLegend = legend;
            funnel.Legend.Mode            = SeriesLegendMode.DataPoints;
            funnel.DataLabelStyle.Format  = "<percent>";

            funnel.Values.Add(20.0);
            funnel.Values.Add(10.0);
            funnel.Values.Add(15.0);
            funnel.Values.Add(7.0);
            funnel.Values.Add(28.0);

            funnel.Labels.Add("Awareness");
            funnel.Labels.Add("First Hear");
            funnel.Labels.Add("Further Learn");
            funnel.Labels.Add("Liking");
            funnel.Labels.Add("Decision");

            NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Bright);

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

            if (!IsPostBack)
            {
                // init form controls
                WebExamplesUtilities.FillComboWithEnumValues(FunnelLabelModeDropDownList, typeof(FunnelLabelMode));
                FunnelLabelModeDropDownList.SelectedIndex = 0;

                WebExamplesUtilities.FillComboWithValues(FunnelRadiusDropDownList, 0, 100, 10);
                FunnelRadiusDropDownList.SelectedIndex = (int)(chart.Width / 10);

                WebExamplesUtilities.FillComboWithValues(FunnelPointGapDropDownList, 0, 100, 10);
                FunnelPointGapDropDownList.SelectedIndex = (int)(funnel.FunnelPointGap / 10);

                WebExamplesUtilities.FillComboWithValues(NeckWidthDropDownList, 0, 100, 10);
                NeckWidthDropDownList.SelectedIndex = (int)(funnel.NeckWidthPercent / 10);

                WebExamplesUtilities.FillComboWithValues(NeckHeightDropDownList, 0, 100, 10);
                NeckHeightDropDownList.SelectedIndex = (int)(funnel.NeckHeightPercent / 10);

                WebExamplesUtilities.FillComboWithValues(LabelArrowLengthDropDownList, 0, 10, 1);
                LabelArrowLengthDropDownList.SelectedIndex = (int)(funnel.DataLabelStyle.ArrowLength.Value);
            }

            SetLabelMode(funnel);

            // set funnel arrow length
            funnel.DataLabelStyle.ArrowLength = new NLength((float)(LabelArrowLengthDropDownList.SelectedIndex), NRelativeUnit.ParentPercentage);

            // set funnel radius
            nChartControl1.Charts[0].Width = FunnelRadiusDropDownList.SelectedIndex * 10.0f;

            // set funnel gap
            funnel.FunnelPointGap = FunnelPointGapDropDownList.SelectedIndex;

            // set neck width
            funnel.NeckWidthPercent = NeckWidthDropDownList.SelectedIndex * 10.0f;

            // set neck height
            funnel.NeckHeightPercent = NeckHeightDropDownList.SelectedIndex * 10.0f;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WebExamplesUtilities.FillComboWithEnumValues(ViewRangeInflateModeDropDownList, typeof(ScaleViewRangeInflateMode));
                ViewRangeInflateModeDropDownList.SelectedIndex = (int)ScaleViewRangeInflateMode.MajorTick;

                InflateMinCheckBox.Checked = true;
                InflateMaxCheckBox.Checked = true;

                WebExamplesUtilities.FillComboWithValues(LogicalInflateMinMaxDropDownList, 0, 200, 10);
                WebExamplesUtilities.FillComboWithValues(AbsoluteInflateMinMaxDropDownList, 0, 20, 2);
            }

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

            // set a chart title
            NLabel header = new NLabel("Volume Change vs. Last Year<br/> <font size = '9pt'>Demonstrates different view range modes</font>");

            header.TextStyle.TextFormat       = TextFormat.XML;
            header.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
            header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
            header.DockMode = PanelDockMode.Top;
            header.TextStyle.StringFormatStyle.HorzAlign = HorzAlign.Center;
            header.Margins = new NMarginsL(10, 2, 10, 10);
            nChartControl1.Panels.Add(header);

            // add some data to the control
            NCartesianChart chart = new NCartesianChart();

            chart.DockMode   = PanelDockMode.Fill;
            chart.BoundsMode = BoundsMode.Stretch;

            NBarSeries bar = new NBarSeries();

            bar.DataLabelStyle.Visible = false;

            NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Nevron);

            bar.Values.Add(100);
            bar.FillStyles[0] = new NColorFillStyle(palette.SeriesColors[0]);

            bar.Values.Add(200);
            bar.FillStyles[1] = new NColorFillStyle(palette.SeriesColors[0]);

            bar.Values.Add(-180);
            bar.FillStyles[3] = new NColorFillStyle(palette.SeriesColors[1]);

            bar.Values.Add(200);
            bar.FillStyles[4] = new NColorFillStyle(palette.SeriesColors[1]);

            bar.Values.Add(400);
            bar.FillStyles[5] = new NColorFillStyle(palette.SeriesColors[1]);

            chart.Series.Add(bar);

            chart.Margins = new NMarginsL(10, 0, 10, 10);

            // configure y axis
            NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).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);

            // configure the x axis
            NHierarchicalScaleConfigurator hierarchicalScale = new NHierarchicalScaleConfigurator();

            hierarchicalScale.CreateSeparatorForEachLevel = false;

            // create utilization group
            NHierarchicalScaleNode utilization = new NHierarchicalScaleNode(0, "Cash Utilisation");

            utilization.LabelStyle.TickMode = RangeLabelTickMode.Separators;
            utilization.LabelStyle.TextStyle.FontStyle.EmSize = new NLength(11);
            utilization.LabelStyle.TextStyle.FontStyle.Style  = FontStyle.Bold;

            utilization.ChildNodes.Add(CreateSubScaleNode("Cash at ATM", true, false));
            utilization.ChildNodes.Add(CreateSubScaleNode("Cash at desk", true, false));
            hierarchicalScale.Nodes.Add(utilization);

            // create payments group
            NHierarchicalScaleNode payments = new NHierarchicalScaleNode(0, "Payments");

            payments.LabelStyle.TickMode = RangeLabelTickMode.Separators;
            payments.LabelStyle.TextStyle.FontStyle.EmSize = new NLength(11);
            payments.LabelStyle.TextStyle.FontStyle.Style  = FontStyle.Bold;

            payments.ChildNodes.Add(CreateSubScaleNode("Cheque", true, false));
            payments.ChildNodes.Add(CreateSubScaleNode("Direct debit", true, false));
            payments.ChildNodes.Add(CreateSubScaleNode("Wire transfer", true, true));
            hierarchicalScale.Nodes.Add(payments);

            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = hierarchicalScale;
            nChartControl1.Panels.Add(chart);

            // update form controls
            NAxis yAxis = nChartControl1.Charts[0].Axis(StandardAxis.PrimaryY);
            NNumericScaleConfigurator scale = (NNumericScaleConfigurator)yAxis.ScaleConfigurator;

            scale.Title.Text = "Volume in Thousands USD";

            scale.ViewRangeInflateMode  = (ScaleViewRangeInflateMode)ViewRangeInflateModeDropDownList.SelectedIndex;
            scale.InflateViewRangeBegin = InflateMinCheckBox.Checked;
            scale.InflateViewRangeEnd   = InflateMaxCheckBox.Checked;

            switch (scale.ViewRangeInflateMode)
            {
            case ScaleViewRangeInflateMode.MajorTick:
                break;

            case ScaleViewRangeInflateMode.Logical:
                double logicalInflate = LogicalInflateMinMaxDropDownList.SelectedIndex * 10;
                scale.LogicalInflate = new NRange1DD(logicalInflate, logicalInflate);
                break;

            case ScaleViewRangeInflateMode.Absolute:
                float absoluteInflate = AbsoluteInflateMinMaxDropDownList.SelectedIndex * 2;
                scale.AbsoluteInflate = new NRange1DL(new NLength(absoluteInflate, NGraphicsUnit.Point),
                                                      new NLength(absoluteInflate, NGraphicsUnit.Point));
                break;
            }

            // assign scale configurator to y axis
            yAxis.ScaleConfigurator = scale;

            // update controls state
            LogicalInflateMinMaxDropDownList.Enabled  = scale.ViewRangeInflateMode == ScaleViewRangeInflateMode.Logical;
            AbsoluteInflateMinMaxDropDownList.Enabled = scale.ViewRangeInflateMode == ScaleViewRangeInflateMode.Absolute;
        }
Exemple #21
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)
        {
            if (!IsPostBack)
            {
                WebExamplesUtilities.FillComboWithEnumValues(ShapeStyleDropDownList, typeof(BarShape));
                ShapeStyleDropDownList.SelectedIndex = 0;

                WebExamplesUtilities.FillComboWithColorNames(ShapesColorDropDownList, KnownColor.DarkOrange);

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

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            // apply layout
            ApplyLayoutTemplate(0, nChartControl1, chart, title, null);
        }
Exemple #23
0
        /// <summary>
        /// Called to initialize the example
        /// </summary>
        /// <param name="chartControl"></param>
        public override void Create()
        {
            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("3D Funnel Chart");

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

            NLegend legend = nChartControl1.Legends[0];

            legend.SetPredefinedLegendStyle(PredefinedLegendStyle.BottomRight);

            NFunnelChart chart = new NFunnelChart();

            chart.Enable3D = true;
            chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal);
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights);
            chart.Projection.Elevation = 4;

            nChartControl1.Charts.Clear();
            nChartControl1.Charts.Add(chart);

            NFunnelSeries funnel = (NFunnelSeries)chart.Series.Add(SeriesType.Funnel);

            funnel.BorderStyle.Color      = Color.LemonChiffon;
            funnel.Legend.DisplayOnLegend = legend;
            funnel.Legend.Mode            = SeriesLegendMode.DataPoints;
            funnel.DataLabelStyle.Format  = "<percent>";

            funnel.Values.Add(20.0);
            funnel.Values.Add(10.0);
            funnel.Values.Add(15.0);
            funnel.Values.Add(7.0);
            funnel.Values.Add(28.0);

            funnel.Labels.Add("Awareness");
            funnel.Labels.Add("First Hear");
            funnel.Labels.Add("Further Learn");
            funnel.Labels.Add("Liking");
            funnel.Labels.Add("Decision");

            // apply palette to funnel segments
            NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Fresh);

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

            // init form controls
            NExampleHelpers.FillComboWithEnumValues(FunnelLabelModeComboBox, typeof(FunnelLabelMode));
            FunnelLabelModeComboBox.SelectedIndex = 0;

            FunnelRadiusScrollBar.Value     = chart.Width / 100.0f;
            FunnelPointGapScrollBar.Value   = funnel.FunnelPointGap / 10.0f;
            NeckWidthScrollBar.Value        = funnel.NeckWidthPercent / 100.0f;
            NeckHeightScrollBar.Value       = funnel.NeckHeightPercent / 100.0f;
            LabelArrowLengthScrollBar.Value = funnel.DataLabelStyle.ArrowLength.Value / 100.0f;
        }
        void LoadBarChart()
        {
            if (nChartControl1.RequiresInitialization)
            {
                nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
                nChartControl1.Legends.Clear();

                // set a chart title
                NLabel header = nChartControl1.Labels.AddHeader("Total Web Site Hits per Day");
                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(3, NRelativeUnit.ParentPercentage),
                    new NLength(3, NRelativeUnit.ParentPercentage));

                // setup a Bar chart
                NChart chart = nChartControl1.Charts[0];
                chart.Enable3D   = false;
                chart.BoundsMode = BoundsMode.Stretch;
                chart.Location   = new NPointL(
                    new NLength(4, NRelativeUnit.ParentPercentage),
                    new NLength(25, NRelativeUnit.ParentPercentage));
                chart.Size = new NSizeL(
                    new NLength(88, NRelativeUnit.ParentPercentage),
                    new NLength(75, NRelativeUnit.ParentPercentage));

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

                // add interlace stripe to the Y axis
                NScaleStripStyle stripStyle = new NScaleStripStyle(new NColorFillStyle(Color.FromArgb(0xfe, 0xed, 0xe2)), null, true, 0, 0, 1, 1);
                stripStyle.Interlaced = true;
                stripStyle.SetShowAtWall(ChartWallType.Back, true);
                stripStyle.SetShowAtWall(ChartWallType.Left, true);
                linearScale.StripStyles.Add(stripStyle);

                // setup X axis
                NDateTimeScaleConfigurator timeScale = new NDateTimeScaleConfigurator();
                timeScale.EnableUnitSensitiveFormatting = true;
                timeScale.DateTimeUnitFormatterPairs.Clear();
                timeScale.DateTimeUnitFormatterPairs.Add(new NDateTimeUnitFormatterPair(NDateTimeUnit.Day, new NDateTimeValueFormatter("d/MM/yy")));
                timeScale.LabelFitModes = new LabelFitMode[] { LabelFitMode.AutoScale };
                timeScale.MajorTickMode = MajorTickMode.CustomStep;
                timeScale.CustomStep    = new NDateTimeSpan(1, NDateTimeUnit.Day);
                timeScale.InnerMajorTickStyle.Visible = false;
                timeScale.RoundToTickMin = false;
                timeScale.RoundToTickMax = false;
                chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = timeScale;

                // setup bar series
                NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);
                bar.Name = "Total Web Site Hits per Day";
                bar.DataLabelStyle.Format = "<value>";
                bar.DataLabelStyle.TextStyle.FontStyle = new NFontStyle("Arial", 8);
                bar.BarWidth       = new NLength(10, NRelativeUnit.ParentPercentage);
                bar.InflateMargins = true;
                bar.UseXValues     = true;
                bar.UseZValues     = false;

                // initialize data points
                DateTime date       = startDate;
                int      lengthDays = hitsPerDayPerRegion.Length;
                for (int i = 0; i < lengthDays; i++)
                {
                    int totalHits     = 0;
                    int lengthRegions = hitsPerDayPerRegion[i].Length;
                    for (int j = 0; j < lengthRegions; j++)
                    {
                        totalHits += hitsPerDayPerRegion[i][j];
                    }

                    bar.XValues.Add(date);
                    bar.Values.Add(totalHits);

                    if (i > 0)
                    {
                        bar.InteractivityStyles.Add(i, new NInteractivityStyle(true, i.ToString(), string.Format("{0}: {1}", date.ToString("dd/MMM/yyyy"), totalHits), CursorType.Hand));
                    }

                    date = date.AddDays(1);
                }

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

                // select the first bar
                NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Nevron);
                bar.FillStyles[0] = new NColorFillStyle(palette.SeriesColors[1]);
            }
        }
        private void UpdateData()
        {
            int dataPointCount = 0;

            switch (DataPointCountPerLineComboBox.SelectedIndex)
            {
            case 0:
                dataPointCount = 10000;
                break;

            case 1:
                dataPointCount = 100000;
                break;

            case 2:
                dataPointCount = 500000;
                break;
            }

            int    lineCount = (int)NumberOfLinesUpDown.Value;
            NChart chart     = nChartControl1.Charts[0];

            chart.Series.Clear();
            Random random = new Random();

            NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Fresh);

            for (int lineIndex = 0; lineIndex < lineCount; lineIndex++)
            {
                // setup surface series
                NVertexSurfaceSeries surface = new NVertexSurfaceSeries();
                chart.Series.Add(surface);

                surface.Name = "Surface";
                surface.SyncPaletteWithAxisScale       = false;
                surface.PaletteSteps                   = 8;
                surface.ValueFormatter.FormatSpecifier = "0.00";
                surface.FillMode        = SurfaceFillMode.CustomColors;
                surface.FrameMode       = SurfaceFrameMode.Dots;
                surface.FrameColorMode  = SurfaceFrameColorMode.CustomColors;
                surface.VertexPrimitive = VertexPrimitive.LineStrip;
                surface.Data.UseColors  = true;
                surface.Data.SetCapacity(dataPointCount);

                double x = 0.1;
                double y = 0;
                double z = 0;
                double a = 10.0;
                double b = 18 + lineIndex;        // 28.0 - ;
                double c = (lineIndex + 3) / 3.0; //8.0
                double t = lineIndex * (0.01 / lineCount) + 0.01;

                NArgbColorValue color1 = new NArgbColorValue(palette.SeriesColors[lineIndex % palette.SeriesColors.Count]);
                NArgbColorValue color2 = new NArgbColorValue(palette.SeriesColors[(lineIndex + 1) % palette.SeriesColors.Count]);

                unsafe
                {
                    fixed(byte *pData = &surface.Data.Data[0])
                    {
                        float *pVertex = (float *)pData;
                        uint * pColor  = (uint *)(pData + surface.Data.ColorOffset * 4);

                        for (int dataPointIndex = 0; dataPointIndex < dataPointCount; dataPointIndex++)
                        {
                            float xt = (float)(x + t * a * (y - x));
                            float yt = (float)(y + t * (x * (b - z) - y));
                            float zt = (float)(z + t * (x * y - c * z));

                            pVertex[0] = xt;
                            pVertex[1] = yt;
                            pVertex[2] = zt;
                            *pColor = InterpolateColors(color1, color2, (float)((yt + 40.0) / 80.0)).Value;

                            pVertex += 4;
                            pColor  += 4;

                            x = xt;
                            y = yt;
                            z = zt;
                        }
                    }
                }

                // notify series that data has changed as we've modified it directly using pointers
                surface.Data.SetCount(dataPointCount);
            }

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

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

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

                WebExamplesUtilities.FillComboWithColorNames(ColorDropDownList, KnownColor.DarkOrange);

                DifferentColorsCheckBox.Checked = true;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

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

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

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

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

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

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

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

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

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

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

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

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

            if (ModeDropDownList.SelectedIndex == 2)
            {
                FormatDropDownList.Enabled = true;
                point.Legend.Format        = WebExamplesUtilities.GetXmlFormatString(FormatDropDownList.SelectedItem.Text);
            }
            else
            {
                FormatDropDownList.Enabled = false;
            }
        }
Exemple #27
0
        /// <summary>
        /// Called to initialize the example
        /// </summary>
        /// <param name="chartControl"></param>
        public override void Create()
        {
            // set a chart title
            NLabel title = new NLabel("Graphics Path Series");

            title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, System.Drawing.FontStyle.Italic);
            title.TextStyle.FillStyle = new NColorFillStyle(GreyBlue);

            NChart chart = nChartControl1.Charts[0];

            chart.BoundsMode = BoundsMode.Stretch;

            int           shapeIndex   = 0;
            double        cellSize     = 100;
            double        shapePadding = 10;
            NChartPalette palette      = new NChartPalette(ChartPredefinedPalette.Nevron);

            for (int x = 0; x < 2; x++)
            {
                for (int y = 0; y < 2; y++)
                {
                    NGraphicsPathSeries graphicsPathSeries = new NGraphicsPathSeries();

                    double xmin = x * cellSize + shapePadding;
                    double ymin = y * cellSize + shapePadding;

                    double xmax      = xmin + cellSize - shapePadding;
                    double ymax      = ymin + cellSize - shapePadding;
                    double shapeSize = cellSize - 2 * shapePadding;

                    NGraphicsPath path = new NGraphicsPath();

                    switch (shapeIndex)
                    {
                    case 0:
                        // rectangle
                        graphicsPathSeries.Name = "Rectangle";
                        path.AddRectangle(xmin, ymin, xmax - xmin, ymax - ymin);
                        graphicsPathSeries.InteractivityStyle = new NInteractivityStyle("Rectangle");
                        break;

                    case 1:
                        // ellipse
                        graphicsPathSeries.Name = "Ellipse";
                        path.AddEllipse(xmin, ymin, xmax - xmin, ymax - ymin);
                        graphicsPathSeries.InteractivityStyle = new NInteractivityStyle("Ellipse");
                        break;

                    case 2:
                        // triangle
                        graphicsPathSeries.Name = "Triangle";
                        graphicsPathSeries.InteractivityStyle = new NInteractivityStyle("Triangle");
                        path.StartFigure((xmin + xmax) / 2.0, ymin);
                        path.LineTo(xmin, ymax);
                        path.LineTo(xmax, ymax);
                        path.CloseFigure();

                        break;

                    case 3:
                        // polygon
                        graphicsPathSeries.Name = "Polygon";
                        graphicsPathSeries.InteractivityStyle = new NInteractivityStyle("Polygon");
                        double xcenter = (xmin + xmax) / 2.0;
                        double ycenter = (ymin + ymax) / 2.0;

                        int    count  = 8;
                        double radius = shapeSize / 2;

                        for (int i = 0; i < count; i++)
                        {
                            double angle = Math.PI * 2 * (double)i / (double)count;


                            if (i == 0)
                            {
                                path.StartFigure(xcenter + Math.Cos(angle) * radius,
                                                 ycenter + Math.Sin(angle) * radius);
                            }
                            else
                            {
                                path.LineTo(xcenter + Math.Cos(angle) * radius,
                                            ycenter + Math.Sin(angle) * radius);
                            }
                        }

                        path.CloseFigure();
                        break;
                    }

                    graphicsPathSeries.FillStyle    = new NColorFillStyle(palette.SeriesColors[shapeIndex]);
                    graphicsPathSeries.GraphicsPath = path;

                    chart.Series.Add(graphicsPathSeries);

                    shapeIndex++;
                }
            }

            ConfigureStandardLayout(chart, title, nChartControl1.Legends[0]);

            nChartControl1.Controller.Tools.Add(new NTooltipTool());

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

            styleSheet.Apply(nChartControl1.Document);
        }
            public override void OnAsyncMouseUp(string webControlId, System.Web.HttpContext context, NStateObject state, NCallbackMouseEventArgs args)
            {
                NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Nevron);

                ProcessMouseEvent(state, args, palette.GaugeBackgroundForeColor);
            }
Exemple #29
0
        protected void nChartControl1_AsyncMouseUp(object sender, EventArgs e)
        {
            NChartPalette palette = new NChartPalette(ChartPredefinedPalette.Nevron);

            ProcessMouseEvent(sender, e, palette.GaugeBackgroundForeColor);
        }
Exemple #30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                FillModeDropDownList.Items.Add("Uniform");
                FillModeDropDownList.Items.Add("Individual");
                FillModeDropDownList.SelectedIndex = 1;

                WebExamplesUtilities.FillComboWithColorNames(BarColorDropDownList, KnownColor.DarkOrange);

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

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

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

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

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

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

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

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

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

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

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

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

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

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

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

                bar.FillStyles.Clear();

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

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

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

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

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