public override void Initialize()
        {
            base.Initialize();

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

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

            m_Chart = new NPieChart();
            nChartControl1.Charts.Clear();
            nChartControl1.Charts.Add(m_Chart);
            m_Chart.Depth           = 18;
            m_Chart.DisplayOnLegend = nChartControl1.Legends[0];

            m_Pie = (NPieSeries)m_Chart.Series.Add(SeriesType.Pie);
            m_Pie.BorderStyle.Color = Color.LemonChiffon;

            m_Pie.AddDataPoint(new NDataPoint(24, "Cars", new NColorFillStyle(Color.FromArgb(169, 121, 11))));
            m_Pie.AddDataPoint(new NDataPoint(18, "Airplanes", new NColorFillStyle(Color.FromArgb(157, 157, 92))));
            m_Pie.AddDataPoint(new NDataPoint(32, "Trains", new NColorFillStyle(Color.FromArgb(98, 152, 92))));
            m_Pie.AddDataPoint(new NDataPoint(23, "Ships", new NColorFillStyle(Color.FromArgb(111, 134, 181))));
            m_Pie.AddDataPoint(new NDataPoint(19, "Buses", new NColorFillStyle(Color.FromArgb(179, 63, 92))));

            m_Pie.Legend.Mode   = SeriesLegendMode.DataPoints;
            m_Pie.Legend.Format = "<label> <percent>";
        }
Ejemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            m_Manager = ((NMainForm)base.m_MainForm).chartCommandBarsManager;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Customizing the Command Bar");

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

            NPieChart chart = new NPieChart();

            chart.Enable3D = true;
            nChartControl1.Charts.Clear();
            nChartControl1.Charts.Add(chart);

            chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalElevated);
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights);

            chart.DisplayOnLegend = nChartControl1.Legends[0];
            chart.Location        = new NPointL(new NLength(15, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage));
            chart.Size            = new NSizeL(new NLength(70, NRelativeUnit.ParentPercentage), new NLength(70, NRelativeUnit.ParentPercentage));

            NPieSeries pieSeries = (NPieSeries)chart.Series.Add(SeriesType.Pie);

            pieSeries.PieEdgePercent = 30;
            pieSeries.PieStyle       = PieStyle.SmoothEdgePie;
            pieSeries.Legend.Mode    = SeriesLegendMode.DataPoints;
            pieSeries.Legend.Format  = "<label> <percent>";

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

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

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

            styleSheet.Apply(nChartControl1.Document);

            ShowStandardToolbarCheckBox_CheckedChanged(null, null);
        }
Ejemplo n.º 3
0
        public override void Initialize()
        {
            base.Initialize();

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Sorted 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.Charts.Clear();
            nChartControl1.Charts.Add(chart);

            // configure the chart
            chart.Enable3D = true;
            chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalElevated);
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.VividCameraLight);
            chart.DisplayOnLegend = nChartControl1.Legends[0];
            chart.Location        = new NPointL(new NLength(20, NRelativeUnit.ParentPercentage), new NLength(20, NRelativeUnit.ParentPercentage));
            chart.Size            = new NSizeL(new NLength(60, NRelativeUnit.ParentPercentage), new NLength(60, NRelativeUnit.ParentPercentage));

            // configure the legend
            NLegend legend = nChartControl1.Legends[0];

            legend.FillStyle = new NColorFillStyle(Color.FromArgb(100, Color.White));

            // configure the pie series
            m_Pie               = (NPieSeries)chart.Series.Add(SeriesType.Pie);
            m_Pie.Legend.Mode   = SeriesLegendMode.DataPoints;
            m_Pie.Legend.Format = "<label> <percent>";

            // add data
            m_Pie.BorderStyle.Color = Color.LightGray;
            m_Pie.AddDataPoint(new NDataPoint(0, "Cars"));
            m_Pie.AddDataPoint(new NDataPoint(0, "Trains"));
            m_Pie.AddDataPoint(new NDataPoint(0, "Airplanes"));
            m_Pie.AddDataPoint(new NDataPoint(0, "Buses"));
            m_Pie.AddDataPoint(new NDataPoint(0, "Ships"));

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

            styleSheet.Apply(nChartControl1.Document);

            ChangeDataButton_Click(null, null);
        }
Ejemplo n.º 4
0
        private void GroupValues_Click(object sender, System.EventArgs e)
        {
            if (m_bGroupedData)
            {
                MessageBox.Show("Click the ungroup button first");
                return;
            }

            // get a subset containing the pies which are smaller than the specified value
            NDataSeriesSubset smallerThanValue = m_Pie.Values.Filter(Nevron.Chart.CompareMethod.Less, m_dGroupValue);

            // determine the sum of the filtered pies
            double dOtherSliceValue = m_Pie.Values.Evaluate("SUM", smallerThanValue);

            // remove the data points contained in the
            for (int i = m_Pie.GetDataPointCount(); i >= 0; i--)
            {
                if (smallerThanValue.Contains(i))
                {
                    m_Pie.RemoveDataPointAt(i);
                }
            }

            // add a detached pie with the specified group label and color
            NDataPoint dp = new NDataPoint(dOtherSliceValue, m_sGroupLabel);

            dp[DataPointValue.PieDetachment] = 2;
            dp[DataPointValue.FillStyle]     = new NColorFillStyle(m_GroupColor);
            dp[DataPointValue.StrokeStyle]   = new NStrokeStyle(1, m_GroupColor);
            m_Pie.AddDataPoint(dp);

            m_bGroupedData = true;
            nChartControl1.Refresh();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Called to initialize the example
        /// </summary>
        /// <param name="chartControl"></param>
        public override void Create()
        {
            nChartControl1.Controller.Tools.Add(new NPanelSelectorTool());
            nChartControl1.Controller.Tools.Add(new NTrackballTool());

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

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

            m_Chart          = new NPieChart();
            m_Chart.Enable3D = true;
            nChartControl1.Charts.Clear();
            nChartControl1.Charts.Add(m_Chart);

            m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalElevated);
            m_Chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights);

            m_Chart.DisplayOnLegend = nChartControl1.Legends[0];
            m_Chart.Location        = new NPointL(new NLength(15, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage));
            m_Chart.Size            = new NSizeL(new NLength(70, NRelativeUnit.ParentPercentage), new NLength(70, NRelativeUnit.ParentPercentage));

            m_Pie = (NPieSeries)m_Chart.Series.Add(SeriesType.Pie);
            m_Pie.PieEdgePercent = 30;
            m_Pie.PieStyle       = PieStyle.SmoothEdgePie;
            m_Pie.Legend.Mode    = SeriesLegendMode.DataPoints;
            m_Pie.Legend.Format  = "<label> <percent>";

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

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

            styleSheet.Apply(nChartControl1.Document);

            FillDetachments();
        }
Ejemplo n.º 6
0
        private void AddPieButton_Click(object sender, EventArgs e)
        {
            NChart     chart     = nChartControl1.Charts[0];
            NPieSeries pieSeries = (NPieSeries)chart.Series[0];

            double     value = Convert.ToDouble(PieValueTextBox.Text);
            String     text  = "Pie " + Convert.ToString(pieSeries.Values.Count + 1);
            NFillStyle fill  = new NColorFillStyle(WebExamplesUtilities.RandomColor());

            pieSeries.AddDataPoint(new NDataPoint(value, text, fill));
        }
        private void RenderQuestionPieChart(int total, int totalseen, int errors)
        {
            chart.Charts.Clear();
            NChart     piechart = new NPieChart();
            NPieSeries pie      = (NPieSeries)piechart.Series.Add(SeriesType.Pie);


            pie.AddDataPoint(new NDataPoint(totalseen - errors, "Positive", new NColorFillStyle(Color.LightGreen)));
            pie.AddDataPoint(new NDataPoint(errors, "Negative", new NColorFillStyle(Color.Red)));

            pie.Legend.Mode   = SeriesLegendMode.DataPoints;
            pie.Legend.Format = "<label> <percent>";
            pie.PieStyle      = PieStyle.SmoothEdgePie;
            pie.LabelMode     = PieLabelMode.Spider;

            chart.Charts.Add(piechart);
            chart.Refresh();

            this.RenderHistoryChart();
        }
Ejemplo n.º 8
0
        private NPanel ConfigurePieChart()
        {
            // configure the chart bounds, contentalign, docking, light model and projection.
            NChart chart = new NPieChart();

            chart.Enable3D         = true;
            chart.BoundsMode       = BoundsMode.Fit;
            chart.ContentAlignment = ContentAlignment.MiddleCenter;
            chart.DockMode         = PanelDockMode.Fill;
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre);
            chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalElevated);

            // create the pie series
            NPieSeries pie = new NPieSeries();

            chart.Series.Add(pie);
            pie.PieStyle = PieStyle.SmoothEdgePie;
            pie.DataLabelStyle.Format = "<percent>";
            pie.LabelMode             = PieLabelMode.Center;
            pie.DataLabelStyle.TextStyle.BackplaneStyle.Visible = false;
            pie.DataLabelStyle.TextStyle.FontStyle.Style       |= FontStyle.Bold;
            pie.DataLabelStyle.TextStyle.FontStyle.EmSize       = new NLength(12, NGraphicsUnit.Point);

            for (int i = 0; i < colors.Length; i++)
            {
                pie.AddDataPoint(new NDataPoint(Random.Next(10) + 5, new NColorFillStyle(colors[i])));
            }

            // create a watermark and nest the chart inside
            NWatermark chartHostPanel = new NWatermark();

            chartHostPanel.DockMode = PanelDockMode.Fill;
            chartHostPanel.ChildPanels.Add(chart);

            return(chartHostPanel);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            NChartControl nChartControl1 = new NChartControl();

            nChartControl1.Width  = 420;
            nChartControl1.Height = 320;
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("HTML Image Map and Binary Streaming");

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

            // setup the legend
            NLegend legend = nChartControl1.Legends[0];

            legend.Mode = LegendMode.Disabled;
            legend.SetPredefinedLegendStyle(PredefinedLegendStyle.Bottom);

            // setup a pie chart
            NPieChart chart = new NPieChart();

            nChartControl1.Charts.Clear();
            nChartControl1.Charts.Add(chart);
            chart.DisplayOnLegend = legend;
            chart.Location        = new NPointL(
                new NLength(10, NRelativeUnit.ParentPercentage),
                new NLength(17, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(
                new NLength(80, NRelativeUnit.ParentPercentage),
                new NLength(66, NRelativeUnit.ParentPercentage));
            chart.InnerRadius = new NLength(20, NRelativeUnit.ParentPercentage);

            // add a pie series
            NPieSeries pieSeries = (NPieSeries)chart.Series.Add(SeriesType.Pie);

            pieSeries.PieStyle              = PieStyle.Torus;
            pieSeries.LabelMode             = PieLabelMode.Rim;
            pieSeries.DataLabelStyle.Format = "<label> <percent>";
            pieSeries.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point);
            pieSeries.Legend.Mode   = SeriesLegendMode.DataPoints;
            pieSeries.Legend.Format = "<label> <value>";
            pieSeries.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point);

            pieSeries.AddDataPoint(new NDataPoint(12, "Metals"));
            pieSeries.AddDataPoint(new NDataPoint(42, "Glass"));
            pieSeries.AddDataPoint(new NDataPoint(23, "Plastics"));
            pieSeries.AddDataPoint(new NDataPoint(56, "Paper"));
            pieSeries.AddDataPoint(new NDataPoint(23, "Other"));

            // add urls to redirect to
            pieSeries.InteractivityStyles.Add(0, new NInteractivityStyle("Metals"));
            pieSeries.InteractivityStyles.Add(1, new NInteractivityStyle("Glass"));
            pieSeries.InteractivityStyles.Add(2, new NInteractivityStyle("Plastics"));
            pieSeries.InteractivityStyles.Add(3, new NInteractivityStyle("Paper"));
            pieSeries.InteractivityStyles.Add(4, new NInteractivityStyle("Other"));

            pieSeries.PieStyle  = PieStyle.Torus;
            pieSeries.LabelMode = PieLabelMode.Spider;

            NHtmlImageMapResponse imageMapResponse = new NHtmlImageMapResponse();

            imageMapResponse.CreateImageFile = false;
            imageMapResponse.ImageFileName   = "NChartImageMap";
            imageMapResponse.ImageMapName    = "MAP_NChartImageMap";
            nChartControl1.ServerSettings.BrowserResponseSettings.DefaultResponse = imageMapResponse;

            this.Controls.Add(nChartControl1);
        }
Ejemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ExplodeModeDropDownList.Items.Add("No exploded pies");
                ExplodeModeDropDownList.Items.Add("Explode biggest");
                ExplodeModeDropDownList.Items.Add("Explode smallest");

                ExplodeModeDropDownList.SelectedIndex = 2;
            }

            nChartControl1.Settings.JitterMode = JitterMode.Enabled;
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Exploded Pie 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));

            // setup legend
            NLegend legend = nChartControl1.Legends[0];

            legend.FillStyle.SetTransparencyPercent(50);
            legend.Data.ExpandMode  = LegendExpandMode.RowsFixed;
            legend.Data.RowCount    = 2;
            legend.ContentAlignment = ContentAlignment.TopLeft;
            legend.Location         = new NPointL(
                new NLength(99, NRelativeUnit.ParentPercentage),
                new NLength(99, NRelativeUnit.ParentPercentage));

            // by default the control contains a Cartesian chart -> remove it and create a Pie chart
            NChart chart = new NPieChart();

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

            // configure the chart
            chart.Enable3D        = true;
            chart.DisplayOnLegend = nChartControl1.Legends[0];
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre);
            chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalElevated);
            chart.BoundsMode = BoundsMode.Fit;
            chart.Location   = new NPointL(
                new NLength(12, NRelativeUnit.ParentPercentage),
                new NLength(12, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(
                new NLength(76, NRelativeUnit.ParentPercentage),
                new NLength(68, NRelativeUnit.ParentPercentage));

            // add a pie serires
            NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie);

            pie.PieStyle                   = PieStyle.SmoothEdgePie;
            pie.PieEdgePercent             = 50;
            pie.DataLabelStyle.Visible     = false;
            pie.Legend.Mode                = SeriesLegendMode.DataPoints;
            pie.Legend.Format              = "<label> <percent>";
            pie.Legend.TextStyle.FontStyle = new NFontStyle("Arial", 8);

            pie.AddDataPoint(new NDataPoint(0, "Ships"));
            pie.AddDataPoint(new NDataPoint(0, "Trains"));
            pie.AddDataPoint(new NDataPoint(0, "Cars"));
            pie.AddDataPoint(new NDataPoint(0, "Buses"));
            pie.AddDataPoint(new NDataPoint(0, "Airplanes"));

            pie.Values.FillRandomRange(Random, pie.Values.Count, 1, 20);

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

            styleSheet.Apply(nChartControl1.Document);

            switch (ExplodeModeDropDownList.SelectedIndex)
            {
            case 0:
                break;

            case 1:
                SetDetachments(pie.Values.FindMaxValue(), pie);
                break;

            case 2:
                SetDetachments(pie.Values.FindMinValue(), pie);
                break;
            }
        }
Ejemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SortDropDownList.Items.Add("Ascending");
                SortDropDownList.Items.Add("Descending");
                SortDropDownList.SelectedIndex = 0;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Sorted Pie 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));

            // setup legend
            NLegend legend = nChartControl1.Legends[0];

            legend.Visible = false;
            legend.HorizontalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel);
            legend.VerticalBorderStyle.Width   = new NLength(0, NGraphicsUnit.Pixel);
            legend.Location = new NPointL(
                new NLength(100, NRelativeUnit.ParentPercentage),
                new NLength(0, NRelativeUnit.ParentPercentage));

            // by default the control contains a Cartesian chart -> remove it and create a Pie chart
            NChart chart = new NPieChart();

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

            chart.Enable3D        = false;
            chart.DisplayOnLegend = nChartControl1.Legends[0];
            chart.BoundsMode      = BoundsMode.Fit;
            chart.Location        = new NPointL(
                new NLength(15, NRelativeUnit.ParentPercentage),
                new NLength(16, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(
                new NLength(70, NRelativeUnit.ParentPercentage),
                new NLength(70, NRelativeUnit.ParentPercentage));


            NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie);

            pie.PieStyle      = PieStyle.SmoothEdgePie;
            pie.Legend.Mode   = SeriesLegendMode.DataPoints;
            pie.Legend.Format = "<label> <percent>";

            pie.AddDataPoint(new NDataPoint(0, "Cars"));
            pie.AddDataPoint(new NDataPoint(0, "Trains"));
            pie.AddDataPoint(new NDataPoint(0, "Buses"));
            pie.AddDataPoint(new NDataPoint(0, "Airplanes"));
            pie.AddDataPoint(new NDataPoint(0, "Ships"));
            pie.Values.FillRandomRange(Random, 5, 1, 40);

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

            styleSheet.Apply(nChartControl1.Document);

            DataSeriesMask        included = DataSeriesMask.RandomAccess;
            DataSeriesMask        excluded = DataSeriesMask.PieDetachments;
            NDataSeriesCollection arr      = pie.GetDataSeries(included, excluded, false);

            int masterDataSeries = arr.FindByMask(DataSeriesMask.Values);

            if (SortDropDownList.SelectedIndex == 0)
            {
                arr.Sort(masterDataSeries, DataSeriesSortOrder.Ascending);
            }
            else
            {
                arr.Sort(masterDataSeries, DataSeriesSortOrder.Descending);
            }
        }
Ejemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                CountryDropDownList.Items.Add("USA");
                CountryDropDownList.Items.Add("CHINA");
                CountryDropDownList.Items.Add("JAPAN");
                CountryDropDownList.Items.Add("GERMANY");
                CountryDropDownList.Items.Add("FRANCE");
                CountryDropDownList.Items.Add("UK");

                CountryDropDownList.SelectedIndex = 0;

                WebExamplesUtilities.FillComboWithPercents(XPositionDropDownList, 10);
                XPositionDropDownList.SelectedIndex = 0;
                WebExamplesUtilities.FillComboWithPercents(YPositionDropDownList, 10);
                YPositionDropDownList.SelectedIndex = 0;

                WebExamplesUtilities.FillComboWithPercents(FlagTransparencyDropDownList, 10);
                FlagTransparencyDropDownList.SelectedIndex = 5;

                ContentAlignmentDropDownList.Items.Add("BottomCenter");
                ContentAlignmentDropDownList.Items.Add("BottomLeft");
                ContentAlignmentDropDownList.Items.Add("BottomRight");
                ContentAlignmentDropDownList.Items.Add("MiddleCenter");
                ContentAlignmentDropDownList.Items.Add("MiddleLeft");
                ContentAlignmentDropDownList.Items.Add("MiddleRight");
                ContentAlignmentDropDownList.Items.Add("TopCenter");
                ContentAlignmentDropDownList.Items.Add("TopLeft");
                ContentAlignmentDropDownList.Items.Add("TopRight");
                ContentAlignmentDropDownList.SelectedIndex = 2;
            }

            // enable the antialiasing of the whole scene
            nChartControl1.Settings.JitterMode = JitterMode.Enabled;
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // by default the chart contains a cartesian chart which cannot display a pie series
            nChartControl1.Charts.Clear();

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

            legend.HorizontalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel);
            legend.VerticalBorderStyle.Width   = new NLength(0, NGraphicsUnit.Pixel);
            legend.FillStyle.SetTransparencyPercent(50);
            legend.OuterBottomBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel);
            legend.OuterLeftBorderStyle.Width   = new NLength(0, NGraphicsUnit.Pixel);
            legend.OuterRightBorderStyle.Width  = new NLength(0, NGraphicsUnit.Pixel);
            legend.OuterTopBorderStyle.Width    = new NLength(0, NGraphicsUnit.Pixel);
            legend.SetPredefinedLegendStyle(PredefinedLegendStyle.TopRight);

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Car sales for " + CountryDropDownList.SelectedItem.Text);

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

            // create the watermark
            NWatermark watermark = new NWatermark();

            watermark.FillStyle        = new NImageFillStyle(this.MapPathSecure(this.TemplateSourceDirectory + "\\" + CountryDropDownList.SelectedItem.Text + ".GIF"));
            watermark.Location         = new NPointL(new NLength(XPositionDropDownList.SelectedIndex * 10, NRelativeUnit.ParentPercentage), new NLength(YPositionDropDownList.SelectedIndex * 10, NRelativeUnit.ParentPercentage));
            watermark.UseAutomaticSize = false;
            watermark.Size             = new NSizeL(150, 100);
            watermark.ContentAlignment = (ContentAlignment)ContentAlignment.Parse(typeof(ContentAlignment), ContentAlignmentDropDownList.SelectedItem.Text);
            watermark.FillStyle.SetTransparencyPercent(FlagTransparencyDropDownList.SelectedIndex * 10.0f);
            watermark.StandardFrameStyle.Visible = false;

            // create the chart
            NPieChart chart = new NPieChart();

            chart.Enable3D = true;
            chart.Depth    = 5;

            if (ShowFlagAboveChartBox.Checked)
            {
                nChartControl1.Panels.Add(chart);
                nChartControl1.Panels.Add(legend);
                nChartControl1.Panels.Add(watermark);
            }
            else
            {
                nChartControl1.Panels.Add(watermark);
                nChartControl1.Panels.Add(chart);
                nChartControl1.Panels.Add(legend);
            }

            chart.DisplayOnLegend = legend;
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre);
            chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated);

            NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie);

            pie.PieStyle               = PieStyle.SmoothEdgePie;
            pie.LabelMode              = PieLabelMode.Center;
            pie.Legend.Mode            = SeriesLegendMode.DataPoints;
            pie.DataLabelStyle.Visible = false;

            pie.AddDataPoint(new NDataPoint(0, "Toyota"));
            pie.AddDataPoint(new NDataPoint(0, "Honda"));
            pie.AddDataPoint(new NDataPoint(0, "Volkswagen"));
            pie.AddDataPoint(new NDataPoint(0, "Chrysler"));
            pie.AddDataPoint(new NDataPoint(0, "Ford"));
            pie.Values.FillRandom(Random, 5);

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

            styleSheet.Apply(pie);
        }
Ejemplo n.º 13
0
        public override void Initialize()
        {
            base.Initialize();

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

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

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

            // setup the legend
            NLegend legend = nChartControl1.Legends[0];

            legend.SetPredefinedLegendStyle(PredefinedLegendStyle.BottomRight);

            NPieChart pieChart = new NPieChart();

            pieChart.Enable3D = true;

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

            NPointLightSource ls = new NPointLightSource();

            ls.CoordinateMode = LightSourceCoordinateMode.Camera;
            ls.Position       = new NVector3DF(0, 0, 50);
            ls.Ambient        = Color.FromArgb(30, 30, 30);
            ls.Diffuse        = Color.FromArgb(180, 180, 180);
            ls.Specular       = Color.FromArgb(100, 100, 100);

            pieChart.LightModel.LightSources.Clear();
            pieChart.LightModel.LightSources.Add(ls);

            pieChart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated);
            pieChart.Depth           = 10;
            pieChart.DisplayOnLegend = nChartControl1.Legends[0];
            pieChart.Location        = new NPointL(new NLength(20, NRelativeUnit.ParentPercentage), new NLength(20, NRelativeUnit.ParentPercentage));
            pieChart.Size            = new NSizeL(new NLength(60, NRelativeUnit.ParentPercentage), new NLength(60, NRelativeUnit.ParentPercentage));
            pieChart.InnerRadius     = new NLength(20, NRelativeUnit.ParentPercentage);

            NPieSeries pieSeries = (NPieSeries)pieChart.Series.Add(SeriesType.Pie);

            pieSeries.BorderStyle.Color = Color.LemonChiffon;

            pieSeries.DataLabelStyle.ArrowLength        = new NLength(10, NGraphicsUnit.Point);
            pieSeries.DataLabelStyle.ArrowPointerLength = new NLength(0, NGraphicsUnit.Point);

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

            pieSeries.AddDataPoint(new NDataPoint(24, "Cars", new NColorFillStyle(Color.FromArgb(169, 121, 11))));
            pieSeries.AddDataPoint(new NDataPoint(18, "Airplanes", new NColorFillStyle(Color.FromArgb(157, 157, 92))));
            pieSeries.AddDataPoint(new NDataPoint(32, "Trains", new NColorFillStyle(Color.FromArgb(98, 152, 92))));
            pieSeries.AddDataPoint(new NDataPoint(23, "Ships", new NColorFillStyle(Color.FromArgb(111, 134, 181))));
            pieSeries.AddDataPoint(new NDataPoint(19, "Buses", new NColorFillStyle(Color.FromArgb(179, 63, 92))));

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

            styleSheet.Apply(nChartControl1.Document);

            // init form controls
            PieShapeCombo.FillFromEnum(typeof(PieStyle));
            PieShapeCombo.SelectedIndex = (int)PieStyle.Ring;

            PieLabelModeCombo.FillFromEnum(typeof(PieLabelMode));
            PieLabelModeCombo.SelectedIndex = 0;

            EdgePercentScroll.Value = (int)pieSeries.PieEdgePercent;
            OuterRadiusScroll.Value = (int)pieChart.Radius.Value;
            InnerRadiusScroll.Value = (int)pieChart.InnerRadius.Value;

            ArrowLengthScroll.Value        = (int)pieSeries.DataLabelStyle.ArrowLength.Value;
            ArrowPointerLengthScroll.Value = (int)pieSeries.DataLabelStyle.ArrowPointerLength.Value;
            ConnectorLengthScroll.Value    = (int)pieSeries.ConnectorLength.Value;
            LeadOffLengthScroll.Value      = (int)pieSeries.LeadOffArrowLength.Value;

            BeginAngleScroll.Value = (int)pieChart.BeginAngle;
            TotalAngleScroll.Value = (int)pieChart.TotalAngle;
        }
Ejemplo n.º 14
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (nChartControl1.RequiresInitialization)
            {
                nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
                nChartControl1.Settings.JitterMode = JitterMode.Enabled;

                // configure legend
                NLegend legend = nChartControl1.Legends[0];
                legend.ShadowStyle.Type = ShadowType.GaussianBlur;
                legend.SetPredefinedLegendStyle(PredefinedLegendStyle.Left);
                legend.DockMode        = PanelDockMode.Bottom;
                legend.Margins         = new NMarginsL(0, 0, 0, 10);
                legend.Data.ExpandMode = LegendExpandMode.ColsFixed;
                legend.Data.ColCount   = 2;

                // set a chart title
                NLabel header = nChartControl1.Labels.AddHeader("Product Analysis");
                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));

                // by default the chart contains a cartesian chart which cannot display pie series
                NPieChart chart = new NPieChart();
                chart.Enable3D = true;

                nChartControl1.Charts.Clear();
                nChartControl1.Charts.Add(chart);
                chart.DisplayOnLegend = nChartControl1.Legends[0];

                NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie);

                pie.AddDataPoint(new NDataPoint(23, ".NET Vision"));
                pie.AddDataPoint(new NDataPoint(56, "Chart"));
                pie.AddDataPoint(new NDataPoint(42, "Diagram"));
                pie.AddDataPoint(new NDataPoint(12, "User Interface"));

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

                pie.PieStyle  = PieStyle.SmoothEdgePie;
                pie.LabelMode = PieLabelMode.Spider;

                pie.LabelMode = PieLabelMode.Center;
                pie.DataLabelStyle.ArrowLength        = new NLength(0f, NRelativeUnit.ParentPercentage);
                pie.DataLabelStyle.ArrowPointerLength = new NLength(0f, NRelativeUnit.ParentPercentage);

                chart.LightModel.EnableLighting = true;
                chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre);
                chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated);
                chart.BoundsMode = BoundsMode.Fit;
                chart.Location   = new NPointL(
                    new NLength(10, NRelativeUnit.ParentPercentage),
                    new NLength(10, NRelativeUnit.ParentPercentage));
                chart.Size = new NSizeL(
                    new NLength(80, NRelativeUnit.ParentPercentage),
                    new NLength(70, NRelativeUnit.ParentPercentage));

                //	set up client side tooltips
                pie.InteractivityStyles.Add(0, new NInteractivityStyle(true, null, ".NET Vision"));
                pie.InteractivityStyles.Add(1, new NInteractivityStyle(true, null, "Chart"));
                pie.InteractivityStyles.Add(2, new NInteractivityStyle(true, null, "Diagram"));
                pie.InteractivityStyles.Add(3, new NInteractivityStyle(true, null, "User Interface"));

                // apply style sheet
                NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor);
                styleSheet.Apply(nChartControl1.Document);
            }
        }
Ejemplo n.º 15
0
        public override void Initialize(NThinChartControl control)
        {
            NServerMouseEventTool serverMouseEventTool;

            // enable jittering (full scene antialiasing)
            control.Settings.JitterMode = JitterMode.Enabled;
            control.BackgroundStyle.FrameStyle.Visible = false;

            // set a chart title
            NLabel title = control.Labels.AddHeader("Exploded Pie 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));

            // setup legend
            NLegend legend = control.Legends[0];

            legend.FillStyle.SetTransparencyPercent(50);
            legend.Data.ExpandMode  = LegendExpandMode.RowsFixed;
            legend.Data.RowCount    = 2;
            legend.ContentAlignment = ContentAlignment.TopLeft;
            legend.Location         = new NPointL(
                new NLength(99, NRelativeUnit.ParentPercentage),
                new NLength(99, NRelativeUnit.ParentPercentage));

            // by default the control contains a Cartesian chart -> remove it and create a Pie chart
            NChart chart = new NPieChart();

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

            // configure the chart
            chart.Enable3D        = true;
            chart.DisplayOnLegend = control.Legends[0];
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre);
            chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalElevated);
            chart.BoundsMode = BoundsMode.Fit;
            chart.Location   = new NPointL(
                new NLength(12, NRelativeUnit.ParentPercentage),
                new NLength(12, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(
                new NLength(76, NRelativeUnit.ParentPercentage),
                new NLength(68, NRelativeUnit.ParentPercentage));

            // add a pie serires
            NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie);

            pie.PieStyle                   = PieStyle.SmoothEdgePie;
            pie.PieEdgePercent             = 50;
            pie.DataLabelStyle.Visible     = false;
            pie.Legend.Mode                = SeriesLegendMode.DataPoints;
            pie.Legend.Format              = "<label> <percent>";
            pie.Legend.TextStyle.FontStyle = new NFontStyle("Arial", 8);

            pie.AddDataPoint(new NDataPoint(0, "Ships"));
            pie.AddDataPoint(new NDataPoint(0, "Trains"));
            pie.AddDataPoint(new NDataPoint(0, "Cars"));
            pie.AddDataPoint(new NDataPoint(0, "Buses"));
            pie.AddDataPoint(new NDataPoint(0, "Airplanes"));

            pie.Values.FillRandomRange(new Random(), pie.Values.Count, 1, 20);
            for (int i = 0; i < pie.Values.Count; i++)
            {
                pie.Detachments.Add(0);
            }

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

            styleSheet.Apply(control.Document);

            // configure the controller
            serverMouseEventTool = new NServerMouseEventTool();
            control.Controller.Tools.Add(serverMouseEventTool);

            serverMouseEventTool.MouseDown = new NDetachPieSliceMouseEventCallback();
        }
Ejemplo n.º 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WebExamplesUtilities.FillComboWithColorNames(GroupedPieColorDropDownList);
                GroupedPieColorDropDownList.SelectedIndex = 20;

                // init form controls
                ThresholdValueTextBox.Text  = "34";
                GroupedPieLabelTextBox.Text = "Other";
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Settings.JitterMode = JitterMode.Enabled;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Grouped Pie 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));

            // setup legend
            NLegend legend = nChartControl1.Legends[0];

            legend.OuterBottomBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel);
            legend.OuterLeftBorderStyle.Width   = new NLength(0, NGraphicsUnit.Pixel);
            legend.OuterRightBorderStyle.Width  = new NLength(0, NGraphicsUnit.Pixel);
            legend.OuterTopBorderStyle.Width    = new NLength(0, NGraphicsUnit.Pixel);
            legend.FillStyle.SetTransparencyPercent(70);
            legend.HorizontalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel);
            legend.VerticalBorderStyle.Width   = new NLength(0, NGraphicsUnit.Pixel);

            // by default the control contains a Cartesian chart -> remove it and create a Pie chart
            NChart chart = new NPieChart();

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

            chart.Enable3D        = true;
            chart.DisplayOnLegend = nChartControl1.Legends[0];
            chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated);
            chart.BoundsMode = BoundsMode.Fit;
            chart.Location   = new NPointL(
                new NLength(20, NRelativeUnit.ParentPercentage),
                new NLength(20, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(
                new NLength(60, NRelativeUnit.ParentPercentage),
                new NLength(60, NRelativeUnit.ParentPercentage));

            // setup pie series
            NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie);

            pie.Legend.Mode = SeriesLegendMode.None;
            pie.PieStyle    = PieStyle.SmoothEdgePie;

            int count = 10;

            pie.Values.FillRandomRange(Random, count, 1, 100);

            for (int i = 0; i < count; i++)
            {
                pie.Detachments.Add(0);
                pie.Labels.Add(arrLabels[i]);
                pie.FillStyles[i] = arrCustomColors2[i % arrCustomColors2.Length];
            }

            if (GroupPiesCheckBox.Checked == true)
            {
                try
                {
                    Color  groupColor  = WebExamplesUtilities.ColorFromDropDownList(GroupedPieColorDropDownList);
                    double dGroupValue = Int32.Parse(ThresholdValueTextBox.Text);

                    // get a subset containing the pies which are smaller than the specified value
                    NDataSeriesSubset smallerThanValue = pie.Values.Filter(Nevron.Chart.CompareMethod.Less, dGroupValue);

                    // determine the sum of the filtered pies
                    double dOtherSliceValue = pie.Values.Evaluate("SUM", smallerThanValue);

                    // remove the data points contained in the
                    for (int i = pie.GetDataPointCount(); i >= 0; i--)
                    {
                        if (smallerThanValue.Contains(i))
                        {
                            pie.RemoveDataPointAt(i);
                        }
                    }

                    // add a detached pie with the specified group label and color
                    NDataPoint dp = new NDataPoint(dOtherSliceValue, GroupedPieLabelTextBox.Text);
                    dp[DataPointValue.PieDetachment] = 1.0;
                    dp[DataPointValue.FillStyle]     = new NColorFillStyle(groupColor);
                    dp[DataPointValue.StrokeStyle]   = new NStrokeStyle(1, groupColor);
                    pie.AddDataPoint(dp);
                }
                catch
                {
                }
            }
            else
            {
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            NServerMouseEventTool serverMouseEventTool;

            if (!NThinChartControl1.Initialized)
            {
                // enable jittering (full scene antialiasing)
                NThinChartControl1.Settings.JitterMode = JitterMode.Enabled;
                NThinChartControl1.BackgroundStyle.FrameStyle.Visible = false;

                // set a chart title
                NLabel title = NThinChartControl1.Labels.AddHeader("Server Side Events Tool");
                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));

                // setup legend
                NLegend legend = NThinChartControl1.Legends[0];
                legend.FillStyle.SetTransparencyPercent(50);
                legend.Data.ExpandMode  = LegendExpandMode.RowsFixed;
                legend.Data.RowCount    = 2;
                legend.ContentAlignment = ContentAlignment.TopLeft;
                legend.Location         = new NPointL(
                    new NLength(99, NRelativeUnit.ParentPercentage),
                    new NLength(99, NRelativeUnit.ParentPercentage));

                // by default the control contains a Cartesian chart -> remove it and create a Pie chart
                NChart chart = new NPieChart();
                NThinChartControl1.Charts.Clear();
                NThinChartControl1.Charts.Add(chart);

                // configure the chart
                chart.Enable3D        = true;
                chart.DisplayOnLegend = NThinChartControl1.Legends[0];
                chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre);
                chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalElevated);
                chart.BoundsMode = BoundsMode.Fit;
                chart.Location   = new NPointL(
                    new NLength(12, NRelativeUnit.ParentPercentage),
                    new NLength(12, NRelativeUnit.ParentPercentage));
                chart.Size = new NSizeL(
                    new NLength(76, NRelativeUnit.ParentPercentage),
                    new NLength(68, NRelativeUnit.ParentPercentage));

                // add a pie serires
                NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie);
                pie.PieStyle                   = PieStyle.SmoothEdgePie;
                pie.PieEdgePercent             = 50;
                pie.DataLabelStyle.Visible     = false;
                pie.Legend.Mode                = SeriesLegendMode.DataPoints;
                pie.Legend.Format              = "<label> <percent>";
                pie.Legend.TextStyle.FontStyle = new NFontStyle("Arial", 8);

                pie.AddDataPoint(new NDataPoint(0, "Ships"));
                pie.AddDataPoint(new NDataPoint(0, "Trains"));
                pie.AddDataPoint(new NDataPoint(0, "Cars"));
                pie.AddDataPoint(new NDataPoint(0, "Buses"));
                pie.AddDataPoint(new NDataPoint(0, "Airplanes"));

                pie.Values.FillRandomRange(Random, pie.Values.Count, 1, 20);
                for (int i = 0; i < pie.Values.Count; i++)
                {
                    pie.Detachments.Add(0);
                }

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

                // configure the controller
                serverMouseEventTool = new NServerMouseEventTool();
                NThinChartControl1.Controller.Tools.Add(serverMouseEventTool);
            }
            else
            {
                serverMouseEventTool = NThinChartControl1.Controller.Tools[0] as NServerMouseEventTool;
            }

            // subscribe / unsubscribe to mouse down
            if (MouseDownCheckBox.Checked)
            {
                serverMouseEventTool.MouseDown = new NDetachPieSliceMouseEventCallback();
            }
            else
            {
                serverMouseEventTool.MouseDown = null;
            }

            // subscribe / unsubscribe to mouse move
            if (MouseMoveCheckBox.Checked)
            {
                serverMouseEventTool.MouseMove = new NDetachPieSliceMouseEventCallback();
            }
            else
            {
                serverMouseEventTool.MouseMove = null;
            }

            // subscribe / unsubscribe to mouse up
            if (MouseUpCheckBox.Checked)
            {
                serverMouseEventTool.MouseUp = new NDetachPieSliceMouseEventCallback();
            }
            else
            {
                serverMouseEventTool.MouseUp = null;
            }

            /// // subscribe / unsubscribe to mouse hover
            if (MouseOverCheckBox.Checked)
            {
                serverMouseEventTool.MouseOver = new NDetachPieSliceMouseEventCallback();
            }
            else
            {
                serverMouseEventTool.MouseOver = null;
            }

            // subscribe / unsubscribe to mouse leave
            if (MouseLeaveCheckBox.Checked)
            {
                serverMouseEventTool.MouseLeave = new NCollapseAllPieSlicesMouseEventCallback();
            }
            else
            {
                serverMouseEventTool.MouseLeave = null;
            }

            // subscribe / unsubscribe to mouse enter
            if (MouseEnterCheckBox.Checked)
            {
                serverMouseEventTool.MouseEnter = new NDetachAllPieSlicesMouseEventCallback();
            }
            else
            {
                serverMouseEventTool.MouseEnter = null;
            }
        }
Ejemplo n.º 18
0
        public override void Initialize()
        {
            base.Initialize();

            nChartControl1.Panels.Clear();

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

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

            // create a simple pie chart
            NChart chart = new NPieChart();

            chart.Enable3D = true;
            nChartControl1.Charts.Add(chart);
            chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalElevated);
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre);
            chart.BoundsMode      = BoundsMode.None;
            chart.DisplayOnLegend = m_Legend;

            NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie);

            pie.LabelMode     = PieLabelMode.Center;
            pie.Legend.Mode   = SeriesLegendMode.DataPoints;
            pie.Legend.Format = "<label> <percent>";

            pie.AddDataPoint(new NDataPoint(12, "Cars"));
            pie.AddDataPoint(new NDataPoint(42, "Trains"));
            pie.AddDataPoint(new NDataPoint(36, "Airplanes"));
            pie.AddDataPoint(new NDataPoint(23, "Buses"));
            pie.AddDataPoint(new NDataPoint(29, "Ships"));
            pie.AddDataPoint(new NDataPoint(15, "Other"));

            // create a legend
            m_Legend = new NLegend();
            nChartControl1.Panels.Add(m_Legend);

            // tell the chart do display data on it
            chart.DisplayOnLegend = m_Legend;

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

            styleSheet.Apply(nChartControl1.Document);

            // init form controls
            LegendModeComboBox.Items.Add("Disabled");
            LegendModeComboBox.Items.Add("Automatic");
            LegendModeComboBox.Items.Add("Manual");

            PredefinedPositionsComboBox.Items.Add("Top");
            PredefinedPositionsComboBox.Items.Add("Bottom");
            PredefinedPositionsComboBox.Items.Add("Left");
            PredefinedPositionsComboBox.Items.Add("Right");
            PredefinedPositionsComboBox.Items.Add("Top right");
            PredefinedPositionsComboBox.Items.Add("Top left");

            ExpandModeComboBox.Items.Add("Rows only");
            ExpandModeComboBox.Items.Add("Cols only");
            ExpandModeComboBox.Items.Add("Rows fixed");
            ExpandModeComboBox.Items.Add("Cols fixed");

            if (m_Legend.Mode != LegendMode.Manual)
            {
                ManualMarksGroupBox.Enabled = false;
            }

            UpdateControlsFromLegend();
            PredefinedPositionsComboBox.SelectedIndex = 4;
        }
Ejemplo n.º 19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // init form controls
                WebExamplesUtilities.FillComboWithEnumValues(PieStyleDropDownList, typeof(PieStyle));
                PieStyleDropDownList.SelectedIndex = (int)PieStyle.Ring;

                PieLabelModeDropDownList.Items.Add("Center");
                PieLabelModeDropDownList.Items.Add("Rim");
                PieLabelModeDropDownList.Items.Add("Spider");
                PieLabelModeDropDownList.SelectedIndex = 1;

                WebExamplesUtilities.FillComboWithValues(ArrowLengthDropDownList, 0, 10, 1);
                ArrowLengthDropDownList.SelectedIndex = 4;

                WebExamplesUtilities.FillComboWithValues(ArrowPointerLengthDropDownList, 0, 10, 1);
                ArrowPointerLengthDropDownList.SelectedIndex = 4;

                WebExamplesUtilities.FillComboWithValues(DepthDropDownList, 0, 100, 10);
                DepthDropDownList.SelectedIndex = 1;

                WebExamplesUtilities.FillComboWithValues(BeginAngleDropDownList, 0, 360, 10);
                BeginAngleDropDownList.SelectedIndex = 0;

                WebExamplesUtilities.FillComboWithValues(TotalAngleDropDownList, 0, 360, 10);
                TotalAngleDropDownList.SelectedIndex = 36;

                LightsCheckBox.Checked = true;
            }

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;
            nChartControl1.Settings.JitterMode = JitterMode.Enabled;

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Pie 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));

            // setup legend
            NLegend legend = nChartControl1.Legends[0];

            legend.FillStyle = new NColorFillStyle(Color.FromArgb(124, 255, 255, 255));
            legend.HorizontalBorderStyle.Width = new NLength(0);
            legend.VerticalBorderStyle.Width   = new NLength(0);
            legend.SetPredefinedLegendStyle(PredefinedLegendStyle.Bottom);
            legend.Data.ExpandMode  = LegendExpandMode.RowsFixed;
            legend.Data.RowCount    = 2;
            legend.Data.CellMargins = new NMarginsL(
                new NLength(6, NGraphicsUnit.Pixel),
                new NLength(3, NGraphicsUnit.Pixel),
                new NLength(6, NGraphicsUnit.Pixel),
                new NLength(3, NGraphicsUnit.Pixel));
            legend.Data.MarkSize = new NSizeL(
                new NLength(7, NGraphicsUnit.Pixel),
                new NLength(7, NGraphicsUnit.Pixel));


            // by default the control contains a Cartesian chart -> remove it and create a Pie chart
            NPieChart pieChart = new NPieChart();

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

            pieChart.Enable3D        = true;
            pieChart.DisplayOnLegend = nChartControl1.Legends[0];
            pieChart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated);
            pieChart.Depth      = DepthDropDownList.SelectedIndex * 10;
            pieChart.BoundsMode = BoundsMode.Fit;
            pieChart.Location   = new NPointL(
                new NLength(12, NRelativeUnit.ParentPercentage),
                new NLength(12, NRelativeUnit.ParentPercentage));
            pieChart.Size = new NSizeL(
                new NLength(76, NRelativeUnit.ParentPercentage),
                new NLength(68, NRelativeUnit.ParentPercentage));

            pieChart.BeginAngle  = BeginAngleDropDownList.SelectedIndex * 10;
            pieChart.TotalAngle  = TotalAngleDropDownList.SelectedIndex * 10;
            pieChart.InnerRadius = new NLength(40);

            // setup pie series
            NPieSeries pie = (NPieSeries)pieChart.Series.Add(SeriesType.Pie);

            pie.Legend.Mode   = SeriesLegendMode.DataPoints;
            pie.Legend.Format = "<label> <percent>";
            pie.Legend.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point);
            pie.PieStyle  = (PieStyle)PieStyleDropDownList.SelectedIndex;
            pie.LabelMode = (PieLabelMode)PieLabelModeDropDownList.SelectedIndex;
            pie.DataLabelStyle.ArrowLength        = new NLength((float)ArrowLengthDropDownList.SelectedIndex, NRelativeUnit.ParentPercentage);
            pie.DataLabelStyle.ArrowPointerLength = new NLength((float)ArrowPointerLengthDropDownList.SelectedIndex, NRelativeUnit.ParentPercentage);


            pie.AddDataPoint(new NDataPoint(12, "Bikes"));
            pie.AddDataPoint(new NDataPoint(22, "Trains"));
            pie.AddDataPoint(new NDataPoint(19, "Cars"));
            pie.AddDataPoint(new NDataPoint(51, "Planes"));
            pie.AddDataPoint(new NDataPoint(23, "Buses", new NColorFillStyle(Color.Red)));

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

            styleSheet.Apply(nChartControl1.Document);

            switch (pie.LabelMode)
            {
            case PieLabelMode.Center:
                ArrowPointerLengthDropDownList.Enabled = false;
                ArrowLengthDropDownList.Enabled        = false;
                break;

            case PieLabelMode.Rim:
                ArrowPointerLengthDropDownList.Enabled = true;
                ArrowLengthDropDownList.Enabled        = true;
                break;

            case PieLabelMode.Spider:
                ArrowPointerLengthDropDownList.Enabled = true;
                ArrowLengthDropDownList.Enabled        = true;
                break;
            }

            if (LightsCheckBox.Checked)
            {
                pieChart.LightModel.EnableLighting = true;
                pieChart.LightModel.SetPredefinedLightModel(PredefinedLightModel.BrightCameraLight);
            }
            else
            {
                pieChart.LightModel.EnableLighting = false;
            }
        }
        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);
        }
Ejemplo n.º 21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // the control will save its state in the temp directory along with the
            // temporary image files
            nChartControl1.ServerSettings.ControlStateSettings.PersistControlState = true;

            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            nChartControl1.Settings.JitterMode     = JitterMode.Enabled;
            nChartControl1.Settings.JitteringSteps = 4;

            if (!IsPostBack)
            {
                // set a chart title
                NLabel title = nChartControl1.Labels.AddHeader("Persistent server control");
                title.TextStyle.FontStyle        = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
                title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
                title.ContentAlignment           = ContentAlignment.BottomCenter;
                title.Location = new NPointL(
                    new NLength(50, NRelativeUnit.ParentPercentage),
                    new NLength(2, NRelativeUnit.ParentPercentage));

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

                // setup a pie chart
                NPieChart chart = new NPieChart();
                nChartControl1.Charts.Clear();
                nChartControl1.Charts.Add(chart);

                chart.Enable3D = true;
                chart.LightModel.EnableLighting = true;
                chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre);
                chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated);
                chart.Location = new NPointL(
                    new NLength(10, NRelativeUnit.ParentPercentage),
                    new NLength(20, NRelativeUnit.ParentPercentage));
                chart.Size = new NSizeL(
                    new NLength(80, NRelativeUnit.ParentPercentage),
                    new NLength(65, NRelativeUnit.ParentPercentage));

                // add a pie series
                NPieSeries pieSeries = (NPieSeries)chart.Series.Add(SeriesType.Pie);
                pieSeries.PieStyle  = PieStyle.SmoothEdgePie;
                pieSeries.LabelMode = PieLabelMode.SpiderNoOverlap;

                // show a hand when over a pie slice
                pieSeries.InteractivityStyle.Cursor.Type = CursorType.Hand;

                pieSeries.AddDataPoint(new NDataPoint(8, "Pie 1"));
                pieSeries.AddDataPoint(new NDataPoint(4, "Pie 2"));
                pieSeries.AddDataPoint(new NDataPoint(7, "Pie 3"));
                pieSeries.AddDataPoint(new NDataPoint(9, "Pie 4"));

                for (int i = 0; i < pieSeries.Values.Count; i++)
                {
                    pieSeries.FillStyles[i] = new NColorFillStyle(WebExamplesUtilities.RandomColor());
                }
            }

            this.AddPieButton.Click        += new EventHandler(this.AddPieButton_Click);
            this.DeleteLastPieButton.Click += new EventHandler(this.DeleteLastPieButton_Click);
        }
Ejemplo n.º 22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.Panels.Clear();

            // add watermarks

            string[] divIds = new string[] { "toyota",
                                             "chevrolet",
                                             "ford",
                                             "volkswagen",
                                             "hyundai",
                                             "nissan",
                                             "mazda" };

            nChartControl1.BackgroundStyle.FillStyle          = new NColorFillStyle(Color.LightGray);
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            // add header
            NLabel header = nChartControl1.Labels.AddHeader("Car Sales by Company");

            header.TextStyle.BackplaneStyle.Visible = false;
            header.TextStyle.TextFormat             = TextFormat.XML;
            header.TextStyle.ShadowStyle.Type       = ShadowType.GaussianBlur;
            header.TextStyle.FillStyle = new NColorFillStyle(Color.Black);
            header.DockMode            = PanelDockMode.Top;
            header.Margins             = new NMarginsL(0, 10, 0, 0);

            // by default the chart contains a cartesian chart which cannot display a pie series
            NDockPanel dockPanel = new NDockPanel();

            dockPanel.DockMode = PanelDockMode.Fill;
            dockPanel.PositionChildPanelsInContentBounds = true;
            dockPanel.Margins = new NMarginsL(10, 10, 10, 10);

            nChartControl1.Panels.Add(dockPanel);

            AddWatermark(dockPanel, "ToyotaLogo.png");
            AddWatermark(dockPanel, "ChevroletLogo.png");
            AddWatermark(dockPanel, "FordLogo.png");
            AddWatermark(dockPanel, "VolkswagenLogo.png");
            AddWatermark(dockPanel, "HyundaiLogo.png");
            AddWatermark(dockPanel, "NissanLogo.png");
            AddWatermark(dockPanel, "MazdaLogo.png");

            NPieChart pieChart = new NPieChart();

            dockPanel.ChildPanels.Add(pieChart);

            NPieSeries pieSeries = new NPieSeries();

            pieChart.Series.Add(pieSeries);

            // add some data
            pieSeries.AddDataPoint(new NDataPoint(11.6, "Toyota Corolla"));
            pieSeries.AddDataPoint(new NDataPoint(9.7, "Chevrolet Cruze"));
            pieSeries.AddDataPoint(new NDataPoint(9.3, "Ford Focus"));
            pieSeries.AddDataPoint(new NDataPoint(7.1, "Volkswagen Jetta"));
            pieSeries.AddDataPoint(new NDataPoint(7.0, "Hyundai Elantra"));
            pieSeries.AddDataPoint(new NDataPoint(6.1, "Nissan Versa"));
            pieSeries.AddDataPoint(new NDataPoint(5.9, "Mazda 3"));
            pieSeries.AddDataPoint(new NDataPoint(43.4, "Other"));

            pieSeries.PieStyle  = PieStyle.Torus;
            pieSeries.LabelMode = PieLabelMode.Center;

            // configure interactivity for data points
            for (int i = 0; i < pieSeries.Values.Count; i++)
            {
                NInteractivityStyle interactivityStyle = new NInteractivityStyle();

                if (i < nChartControl1.Watermarks.Count)
                {
                    string watermarkId = new NElementIdentifier(nChartControl1.Watermarks[i].Id).ToString();
                    interactivityStyle.CustomMapAreaAttribute.JScriptAttribute = "onmouseover = 'ShowWatermark(evt, \"" + watermarkId + "\", \"" + divIds[i] + "\")'";
                }
                else
                {
                    interactivityStyle.CustomMapAreaAttribute.JScriptAttribute = "onmouseover = 'ShowWatermark(evt, null, null)'";
                }

                pieSeries.InteractivityStyles.Add(i, interactivityStyle);
            }

            nChartControl1.InteractivityStyle.CustomMapAreaAttribute.JScriptAttribute = "onmouseover = 'ShowWatermark(evt, null, null)'";

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

            styleSheet.Apply(nChartControl1.Document);

            // configure the control to generate SVG.
            NImageResponse  imageResponse  = new NImageResponse();
            NSvgImageFormat svgImageFormat = new NSvgImageFormat();

            svgImageFormat.EnableInteractivity = true;
            svgImageFormat.CustomScript        = GetScript();
            svgImageFormat.EmbedImagesInSvg    = true;
            svgImageFormat.EmbeddedImageFormat = new NJpegImageFormat();

            Hashtable attributes = new Hashtable();

            attributes["preserveAspectRatio"] = "yMid slice";
//			attributes["onload"] = "Initialize(evt)";
            svgImageFormat.Attributes = attributes;
            imageResponse.ImageFormat = svgImageFormat;

            nChartControl1.ServerSettings.BrowserResponseSettings.DefaultResponse = imageResponse;
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            nChartControl1.HttpHandlerCallback = new CustomHttpHandlerCallback();

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

                // set a chart title
                NLabel header = nChartControl1.Labels.AddHeader("Mouse Events");
                header.TextStyle.FontStyle        = new NFontStyle("Palatino Linotype", 14, FontStyle.Italic);
                header.TextStyle.FillStyle        = new NColorFillStyle(Color.FromArgb(60, 90, 108));
                header.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;
                header.ContentAlignment           = ContentAlignment.BottomRight;
                header.Location = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));

                // clear the legends
                nChartControl1.Legends.Clear();

                // configure stack bar chart
                NChart chart1 = nChartControl1.Charts[0];
                chart1.Tag        = "BarChart";
                chart1.Location   = new NPointL(new NLength(5, NRelativeUnit.ParentPercentage), new NLength(10, NRelativeUnit.ParentPercentage));
                chart1.Size       = new NSizeL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage));
                chart1.BoundsMode = BoundsMode.Fit;
                chart1.Axis(StandardAxis.Depth).Visible = false;

                // add the first bar
                NBarSeries bar1 = (NBarSeries)chart1.Series.Add(SeriesType.Bar);
                bar1.Name                   = "Cars";
                bar1.MultiBarMode           = MultiBarMode.Series;
                bar1.DataLabelStyle.Visible = false;

                // add the second bar
                NBarSeries bar2 = (NBarSeries)chart1.Series.Add(SeriesType.Bar);
                bar2.Name                   = "Airplanes";
                bar2.MultiBarMode           = MultiBarMode.Stacked;
                bar2.DataLabelStyle.Visible = false;

                // add the third bar
                NBarSeries bar3 = (NBarSeries)chart1.Series.Add(SeriesType.Bar);
                bar3.Name                   = "Trains";
                bar3.MultiBarMode           = MultiBarMode.Stacked;
                bar3.DataLabelStyle.Visible = false;

                // add the fourth bar
                NBarSeries bar4 = (NBarSeries)chart1.Series.Add(SeriesType.Bar);
                bar4.Name                   = "Buses";
                bar4.MultiBarMode           = MultiBarMode.Stacked;
                bar4.DataLabelStyle.Visible = false;

                // change the color of the second and third bars
                bar1.Values.FillRandomRange(Random, 5, 20, 100);
                bar2.Values.FillRandomRange(Random, 5, 20, 100);
                bar3.Values.FillRandomRange(Random, 5, 20, 100);
                bar4.Values.FillRandomRange(Random, 5, 20, 100);

                // add a pie chart
                NChart chart2 = new NPieChart();
                nChartControl1.Charts.Add(chart2);

                chart2.Tag             = "PieChart";
                chart2.Location        = new NPointL(new NLength(55, NRelativeUnit.ParentPercentage), new NLength(8, NRelativeUnit.ParentPercentage));
                chart2.Size            = new NSizeL(new NLength(45, NRelativeUnit.ParentPercentage), new NLength(80, NRelativeUnit.ParentPercentage));
                chart2.BoundsMode      = BoundsMode.Fit;
                chart2.Projection.Zoom = 80;

                NPieSeries pie = (NPieSeries)chart2.Series.Add(SeriesType.Pie);
                pie.DataLabelStyle.Visible = false;

                pie.AddDataPoint(new NDataPoint(12));
                pie.AddDataPoint(new NDataPoint(42));
                pie.AddDataPoint(new NDataPoint(56));
                pie.AddDataPoint(new NDataPoint(23));

                // apply style sheet
                NStyleSheet styleSheet1 = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);
                styleSheet1.Apply(chart1);

                NStyleSheet styleSheet2 = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor);
                styleSheet2.Apply(chart2);
            }
        }
        private void RenderCategory(bool bvesselspecific)
        {
            string     vessel_list   = "";
            string     category_list = GetCommalist(this.tbl_negativecategories, "CategoryNewId", true);
            SqlCommand cmd           = new SqlCommand();

            cmd.Connection = MyConnection.GetConnection();

            int vesselid = (int)(this.bindingSource_Vessels.Current as DataRowView)["VesselId"];

            if (bvesselspecific)
            {
                cmd.CommandText =
                    "  Select a.*,b.CategoryDescription,b.categorycode from ( Select  cn.CategoryNewId,count(*) as NegativeTotal from Vetting a join Objects o on a.objectid=o.objectid join VettingInfo v on a.vetid=v.vetid join Category cn on o.CategoryId=cn.CategoryNewID"
                    + " where a.answer=2 and cn.CategoryNewId in " + category_list + " and v.vesselid= " + vesselid.ToString()
                    + " group by cn.CategoryNewId ) a inner join Category b on a.categorynewid=b.categorynewid ";

                /*
                 * //"Objects AS b ON a.objectid = b.objectid INNER JOIN category c  on b.CategoryId=c.categoryNewid " +
                 * //              "WHERE     (a.answer = 2) and (d.vesselid=@pvesselid)order by categorycode";
                 * cmd.CommandText =
                 * "  Select a.*,b.CategoryDescription,b.categorycode from ( Select  cn.CategoryNewId,count(*) as NegativeTotal from Vetting a join VIQPlus b on a.objectid=b.objectid join VettingInfo v on a.vetid=v.vetid join Category cn on b.ParentId=cn.CategoryNewID"
                 + " where a.answer=2 and cn.CategoryNewId in " + category_list + " and v.vesselid= " + vesselid.ToString()
                 + " group by cn.CategoryNewId ) a inner join Category b on a.categorynewid=b.categorynewid ";
                 * */
            }
            else
            {
                cmd.CommandText =
                    "  Select a.*,b.CategoryDescription,b.categorycode from ( Select  cn.CategoryNewId,count(*) as NegativeTotal from Vetting a join Objects o on a.objectid=o.objectid join VettingInfo v on a.vetid=v.vetid join Category cn on o.CategoryId=cn.CategoryNewID"
                    + " where a.answer=2 and cn.CategoryNewId in " + category_list
                    + " group by cn.CategoryNewId ) a inner join Category b on a.categorynewid=b.categorynewid ";
            }



            SqlDataAdapter da = new SqlDataAdapter(cmd);

            DataTable tbl = new DataTable();


            int num = 0;

            try
            {
                num = da.Fill(tbl);
            }
            catch (Exception e1)
            {
                int i = 0;
            }
            finally
            {
                cmd.Connection.Close();
            }


            this.ChartCategory.Charts.Clear();
            NChart     piechart = new NPieChart();
            NPieSeries ss       = (NPieSeries)piechart.Series.Add(SeriesType.Pie);

            tbl.DefaultView.Sort = "NegativeTotal desc";
            int rc = 255;
            int gc = 0;
            int bc = 0;

            foreach (DataRowView dr in tbl.DefaultView)
            {
                ss.AddDataPoint(new NDataPoint(Convert.ToDouble(dr["NegativeTotal"]), "{" + dr["CategoryCode"].ToString() + "}", new NColorFillStyle(Color.FromArgb(rc, gc, bc))));

                /*
                 * if (rc - 5 > 0)
                 *  rc -= 5;
                 * else
                 *  rc = 0;
                 */
                int step = 10;
                if (gc + step < 255)
                {
                    gc += step;
                }
                else
                {
                    gc = 0;
                }
                if (bc + step < 255)
                {
                    bc += step;
                }
                else
                {
                    bc = 0;
                }
            }
            this.ChartCategory.Charts.Add(piechart);
            this.ChartCategory.Refresh();
        }
        private void ConfigureControl(NChartControl control, string sLabel)
        {
            control.BackgroundStyle.FrameStyle.Visible = false;

            // generate image map respones
            NHtmlImageMapResponse imageMapResponse = new NHtmlImageMapResponse();

            control.ServerSettings.BrowserResponseSettings.BrowserResponsePairs.Clear();
            control.ServerSettings.BrowserResponseSettings.DefaultResponse = imageMapResponse;

            // set a chart title
            NLabel title = control.Labels.AddHeader(sLabel);

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

            NLegend legend = control.Legends[0];

            legend.SetPredefinedLegendStyle(PredefinedLegendStyle.Bottom);
            legend.Data.ExpandMode  = LegendExpandMode.ColsFixed;
            legend.Data.ColCount    = 2;
            legend.ShadowStyle.Type = ShadowType.GaussianBlur;

            NPieChart chart = new NPieChart();

            control.Charts.Clear();
            control.Charts.Add(chart);
            chart.DisplayOnLegend = legend;
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights);
            chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated);
            chart.BoundsMode = BoundsMode.Fit;
            chart.Location   = new NPointL(
                new NLength(15, NRelativeUnit.ParentPercentage),
                new NLength(25, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(
                new NLength(70, NRelativeUnit.ParentPercentage),
                new NLength(50, NRelativeUnit.ParentPercentage));

            NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie);

            pie.PieStyle  = PieStyle.SmoothEdgePie;
            pie.LabelMode = PieLabelMode.Rim;
            pie.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(8, NGraphicsUnit.Point);
            pie.Legend.Mode   = SeriesLegendMode.DataPoints;
            pie.Legend.Format = "<label> <percent>";
            pie.DataLabelStyle.ArrowLength        = new NLength(0f, NRelativeUnit.ParentPercentage);
            pie.DataLabelStyle.ArrowPointerLength = new NLength(0f, NRelativeUnit.ParentPercentage);

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

            pie.InteractivityStyles.Add(0, new NInteractivityStyle("Cars", CursorType.Hand));
            pie.InteractivityStyles.Add(1, new NInteractivityStyle("Trains", CursorType.Hand));
            pie.InteractivityStyles.Add(2, new NInteractivityStyle("Airplanes", CursorType.Hand));
            pie.InteractivityStyles.Add(3, new NInteractivityStyle("Buses", CursorType.Hand));

            NPostbackAttribute postbackAttribute = new NPostbackAttribute();

            for (int i = 0; i < pie.InteractivityStyles.Count; i++)
            {
                ((NInteractivityStyle)pie.InteractivityStyles[i]).InteractivityAttributes.Add(postbackAttribute);
                pie.Detachments.Add(0);
            }

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

            styleSheet.Apply(control.Document);
        }
Ejemplo n.º 26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            nChartControl1.BackgroundStyle.FrameStyle.Visible = false;

            NLegend legend = nChartControl1.Legends[0];

            legend.ShadowStyle.Type = ShadowType.GaussianBlur;
            legend.SetPredefinedLegendStyle(PredefinedLegendStyle.Left);
            legend.Location         = new NPointL(legend.Location.X, new NLength(50, NRelativeUnit.ParentPercentage));
            legend.ContentAlignment = ContentAlignment.BottomRight;

            // set a chart title
            NLabel header = nChartControl1.Labels.AddHeader("Transport Sales Analysis");

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

            // by default the chart contains a cartesian chart which cannot display pie series
            nChartControl1.Charts.Clear();

            NPieChart chart = new NPieChart();

            chart.Enable3D = true;
            nChartControl1.Charts.Add(chart);
            chart.DisplayOnLegend = nChartControl1.Legends[0];

            NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie);

            pie.AddDataPoint(new NDataPoint(12, "Cars", new NColorFillStyle(Color.Red)));
            pie.AddDataPoint(new NDataPoint(42, "Trains", new NColorFillStyle(Color.Gold)));
            pie.AddDataPoint(new NDataPoint(56, "Ships", new NColorFillStyle(Color.Chocolate)));
            pie.AddDataPoint(new NDataPoint(23, "Buses", new NColorFillStyle(Color.Cyan)));


            pie.InteractivityStyles.Add(0, new NInteractivityStyle("Cars", CursorType.Hand));
            pie.InteractivityStyles.Add(1, new NInteractivityStyle("Trains", CursorType.Hand));
            pie.InteractivityStyles.Add(2, new NInteractivityStyle("Ships", CursorType.Hand));
            pie.InteractivityStyles.Add(3, new NInteractivityStyle("Buses", CursorType.Hand));

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

            pie.PieStyle  = PieStyle.SmoothEdgePie;
            pie.LabelMode = PieLabelMode.Spider;

            pie.LabelMode = PieLabelMode.Center;
            pie.DataLabelStyle.ArrowLength        = new NLength(0f, NRelativeUnit.ParentPercentage);
            pie.DataLabelStyle.ArrowPointerLength = new NLength(0f, NRelativeUnit.ParentPercentage);

            chart.LightModel.EnableLighting = true;
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights);
            chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated);
            chart.BoundsMode = BoundsMode.Fit;
            chart.Location   = new NPointL(
                new NLength(35, NRelativeUnit.ParentPercentage),
                new NLength(30, NRelativeUnit.ParentPercentage));
            chart.Size = new NSizeL(
                new NLength(60, NRelativeUnit.ParentPercentage),
                new NLength(60, NRelativeUnit.ParentPercentage));


            NHtmlImageMapResponse imageMapResponse = new NHtmlImageMapResponse();

            nChartControl1.ServerSettings.BrowserResponseSettings.DefaultResponse = imageMapResponse;

            nChartControl1.Settings.JitterMode     = JitterMode.Enabled;
            nChartControl1.Settings.JitteringSteps = 4;

            // select the car sales by default
            if (!IsPostBack)
            {
                for (int i = 0; i < pie.Values.Count; i++)
                {
                    pie.Detachments.Add(0);
                }

                SalesOverTimeImg.ImageUrl = "NInteractiveCarSalesPage.aspx";
            }

            ApplyImageMapAttributesToSerie(pie);

            this.nChartControl1.Click += new EventHandler(this.NChartControl1_Click);
        }