コード例 #1
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;
                }
            }
        }
コード例 #2
0
        private void PositiveNegativeData_Click(object sender, System.EventArgs e)
        {
            NBarSeries bar = (NBarSeries)nChartControl1.Charts[0].Series[0];

            bar.Values.FillRandomRange(Random, categoriesCount, -100, 100);
            nChartControl1.Refresh();
        }
コード例 #3
0
        private void BarDepthScroll_Scroll(object sender, Nevron.UI.WinForm.Controls.ScrollBarEventArgs e)
        {
            NBarSeries bar = (NBarSeries)nChartControl1.Charts[0].Series[0];

            bar.DepthPercent = BarDepthScroll.Value;
            nChartControl1.Refresh();
        }
コード例 #4
0
        private void EdgePercentScrollBar_Scroll(object sender, Nevron.UI.WinForm.Controls.ScrollBarEventArgs e)
        {
            NBarSeries bar = (NBarSeries)nChartControl1.Charts[0].Series[0];

            bar.BarEdgePercent = EdgePercentScrollBar.Value;
            nChartControl1.Refresh();
        }
コード例 #5
0
        private void HasBottomEdge_CheckedChanged(object sender, System.EventArgs e)
        {
            NBarSeries bar = (NBarSeries)nChartControl1.Charts[0].Series[0];

            bar.HasBottomEdge = HasBottomEdge.Checked;
            nChartControl1.Refresh();
        }
コード例 #6
0
        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);
                }
            }
        }
コード例 #7
0
        private void DifferentFillStyles_CheckedChanged(object sender, System.EventArgs e)
        {
            NBarSeries bar = (NBarSeries)nChartControl1.Charts[0].Series[0];

            if (DifferentFillStyles.Checked)
            {
                BarFillStyleButton.Enabled = false;

                bar.Legend.Mode = SeriesLegendMode.DataPoints;

                NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor);
                styleSheet.Apply(nChartControl1.Document);
            }
            else
            {
                BarFillStyleButton.Enabled = true;

                bar.Legend.Mode = SeriesLegendMode.Series;

                NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Fresh);
                styleSheet.Apply(nChartControl1.Document);
            }

            nChartControl1.Refresh();
        }
コード例 #8
0
        private void Filter(NBarSeries bar)
        {
            NDataSeriesSubset subsetAll    = new NDataSeriesSubset();
            NDataSeriesSubset subsetFilter = new NDataSeriesSubset();

            subsetAll.AddRange(0, bar.Values.Count - 1);

            try
            {
                double dValue = Double.Parse(ValueTextBox.Text);

                Nevron.Chart.CompareMethod method = (Nevron.Chart.CompareMethod)FilterDropDownList.SelectedIndex;

                subsetFilter = bar.Values.Filter(method, dValue);

                // apply red color only to the bars in the filter subset
                foreach (int index in subsetFilter)
                {
                    bar.FillStyles[index] = new NColorFillStyle(Color.Red);
                }
            }
            catch
            {
            }
        }
コード例 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Scale Breaks Appearance";

            // configure chart
            m_Chart         = (NCartesianChart)chartView.Surface.Charts[0];
            m_Chart.Padding = new NMargins(20);

            // configure axes
            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);

            m_Chart.PlotFill = new NStockGradientFill(NColor.White, NColor.DarkGray);

            // configure scale
            NLinearScale yScale = (NLinearScale)m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale;

            yScale.ViewRangeInflateMode = ENScaleViewRangeInflateMode.MajorTick;

            m_ScaleBreak = new NAutoScaleBreak(0.4f);
            m_ScaleBreak.PositionMode = ENScaleBreakPositionMode.Percent;
            yScale.ScaleBreaks.Add(m_ScaleBreak);

            // add an interlaced strip to the Y axis
            NScaleStrip interlacedStrip = new NScaleStrip();

            interlacedStrip.Interlaced = true;
            interlacedStrip.Fill       = new NColorFill(NColor.Beige);
            yScale.Strips.Add(interlacedStrip);

            // Create some data with a peak in it
            NBarSeries bar = new NBarSeries();

            m_Chart.Series.Add(bar);
            bar.DataLabelStyle = new NDataLabelStyle(false);

            // fill in some data so that it contains several peaks of data
            Random random = new Random();

            for (int i = 0; i < 8; i++)
            {
                bar.DataPoints.Add(new NBarDataPoint(random.Next(30)));
            }

            for (int i = 0; i < 5; i++)
            {
                bar.DataPoints.Add(new NBarDataPoint(300 + random.Next(50)));
            }

            for (int i = 0; i < 8; i++)
            {
                bar.DataPoints.Add(new NBarDataPoint(random.Next(30)));
            }

            chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, false));

            return(chartView);
        }
コード例 #10
0
        public override void Initialize()
        {
            base.Initialize();

            // add a label
            NLabel title = nChartControl1.Labels.AddHeader("Finding Data");

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

            // create a bar chart
            m_Chart = nChartControl1.Charts[0];
            m_Chart.Axis(StandardAxis.Depth).Visible = false;

            // setup bar series
            m_Bar             = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar);
            m_Bar.Legend.Mode = SeriesLegendMode.None;

            // generate random values and labels
            GenerateValues(6);
            m_Bar.Labels.FillRandom(Random, 6);

            // init form controls
            ValueEdit.Text  = m_Bar.Values[3].ToString();
            StringEdit.Text = (string)m_Bar.Labels[4];
        }
コード例 #11
0
        private void ShowConnectorLinesCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            NBarSeries bar = (NBarSeries)nChartControl1.Charts[0].Series[0];

            bar.ShowConnectorLines = ShowConnectorLinesCheckBox.Checked;
            nChartControl1.Refresh();
        }
コード例 #12
0
        public override void Initialize()
        {
            base.Initialize();

            m_Chart = nChartControl1.Charts[0];
            m_Chart.Axis(StandardAxis.Depth).Visible = false;

            m_Bar = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar);
            m_Bar.Values.FillRandom(Random, 10);
            m_Bar.Legend.Mode = SeriesLegendMode.None;

            m_Subset.AddRange(0, 9);
            Subset.Text = m_Subset.ToString();
            FunctionCombo.SelectedIndex = 0;

            ApplyColorToSubset();

            // add a label
            NLabel title = nChartControl1.Labels.AddHeader("Evaluating data");

            title.TextStyle.FontStyle         = new NFontStyle("Times New Roman", 20, FontStyle.Italic);
            title.TextStyle.FillStyle         = new NColorFillStyle(Color.MidnightBlue);
            title.TextStyle.ShadowStyle.Type  = ShadowType.Solid;
            title.TextStyle.ShadowStyle.Color = Color.White;
            title.ContentAlignment            = ContentAlignment.BottomCenter;
            title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));
        }
コード例 #13
0
        public override void Initialize()
        {
            base.Initialize();

            // setup background

            nChartControl1.Legends[0].Visible = false;

            // add a label
            NLabel title = nChartControl1.Labels.AddHeader("Binding to IBindingList");

            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 = nChartControl1.Charts[0];

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

            bar.Name                  = "Bar";
            bar.Legend.Format         = "<label>";
            bar.DataLabelStyle.Format = "<label>";

            comboBox1.SelectedIndex = 0;

            SetChartControl();
        }
コード例 #14
0
            void INAutoUpdateCallback.OnAutoUpdate(NAspNetThinWebControl control)
            {
                NThinChartControl chartControl = (NThinChartControl)control;
                NBarSeries        bar          = (NBarSeries)chartControl.Charts[0].Series[0];

                int index = (int)chartControl.CustomData;

                for (int i = 0; i < bar.FillStyles.Count; i++)
                {
                    NColorFillStyle colorFill = bar.FillStyles[i] as NColorFillStyle;
                    if (i != index)
                    {
                        colorFill.Color = Color.FromArgb(60, colorFill.Color);
                    }
                    else
                    {
                        colorFill.Color = Color.FromArgb(255, colorFill.Color);
                    }
                }

                index++;

                if (index >= bar.FillStyles.Count)
                {
                    index = 0;
                }

                chartControl.CustomData = index;

                chartControl.UpdateView();
            }
コード例 #15
0
        private void BarEdgePercentComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            NBarSeries bar = (NBarSeries)nChartControl1.Charts[0].Series[0];

            bar.BarEdgePercent = BarEdgePercentComboBox.SelectedIndex * 10;
            nChartControl1.Refresh();
        }
コード例 #16
0
ファイル: PatrolSim.UI.cs プロジェクト: cbchoi/PatrolSim
        private static void UpdateChartComponent(NChartControl nChartControl, double[][] matrix)
        {
            NCartesianChart chart = (NCartesianChart)nChartControl.Charts[0];

            for (int i = 0; i < _gridSizeY; i++)
            {
                NBarSeries bar           = chart.Series[i] as NBarSeries;
                double[]   barValues     = matrix[i];
                int        barValueCount = barValues.Length;

                if (bar.Values.Count == 0)
                {
                    bar.Values.AddRange(barValues);
                }
                else
                {
                    bar.Values.SetRange(0, barValues);
                }

                int fillStyleCount = bar.FillStyles.Count;

                for (int j = 0; j < barValueCount; j++)
                {
                    if (j >= fillStyleCount)
                    {
                        bar.FillStyles[j] = new NColorFillStyle(_scenarioManager.ColorList[(int)barValues[j]]);
                    }
                    else
                    {
                        ((NColorFillStyle)bar.FillStyles[j]).Color = _scenarioManager.ColorList[(int)barValues[j]];
                    }
                }
            }
            nChartControl.Refresh();
        }
コード例 #17
0
            void INCustomRequestCallback.OnCustomRequestCallback(NAspNetThinWebControl control, NRequestContext context, string argument)
            {
                NThinChartControl chartControl = (NThinChartControl)control;

                NChart     chart = chartControl.Charts[0];
                NBarSeries bar   = (NBarSeries)chart.Series[0];

                bar.DataLabelStyles.Clear();

                switch (argument)
                {
                case "ShowDataLabels":
                {
                    bar.DataLabelStyle.Visible = true;
                }
                break;

                case "HideDataLabels":
                {
                    bar.DataLabelStyle.Visible = false;
                }
                break;
                }

                // update the control and toolbar
                chartControl.Update();
            }
コード例 #18
0
        /// <summary>
        ///
        /// </summary>
        private void FillRandomData()
        {
            NList <NBarSeries> barSeriesList = new NList <NBarSeries>();

            // collect all bar series in the view
            for (int chartIndex = 0; chartIndex < m_ChartView.Surface.Charts.Length; chartIndex++)
            {
                NCartesianChart chart = (NCartesianChart)m_ChartView.Surface.Charts[chartIndex];

                for (int seriesIndex = 0; seriesIndex < chart.Series.Count; seriesIndex++)
                {
                    NBarSeries barSeries = chart.Series[seriesIndex] as NBarSeries;

                    if (barSeries != null)
                    {
                        barSeriesList.Add(barSeries);
                        barSeries.DataPoints.Clear();
                    }
                }
            }

            // fill all bar series with random data
            Random random = new Random();

            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < barSeriesList.Count; j++)
                {
                    NBarSeries barSeries = barSeriesList[j];
                    barSeries.DataPoints.Add(new NBarDataPoint(random.Next(10, 100)));
                }
            }
        }
コード例 #19
0
        public override void Initialize()
        {
            base.Initialize();

            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Average, Median, Min, Max");

            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 chart
            m_Chart            = nChartControl1.Charts[0];
            m_Chart.BoundsMode = BoundsMode.Stretch;

            m_Chart.Location = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage));
            m_Chart.Size     = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage));

            // add a line series for the function
            m_Line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line);
            m_Line.MarkerStyle.Visible           = true;
            m_Line.MarkerStyle.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel);
            m_Line.MarkerStyle.FillStyle         = new NColorFillStyle(Color.Crimson);
            m_Line.BorderStyle.Color             = Color.Red;
            m_Line.BorderStyle.Width             = new NLength(2, NGraphicsUnit.Pixel);
            m_Line.Legend.Mode           = SeriesLegendMode.None;
            m_Line.Values.ValueFormatter = new NNumericValueFormatter("0.00");
            m_Line.DisplayOnAxis(StandardAxis.PrimaryX, false);
            m_Line.DisplayOnAxis(StandardAxis.SecondaryX, true);

            // add the bar series
            m_Bar                        = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar);
            m_Bar.Name                   = "Bar1";
            m_Bar.Values.Name            = "values";
            m_Bar.Values.ValueFormatter  = new NNumericValueFormatter("0.00");
            m_Bar.MultiBarMode           = MultiBarMode.Series;
            m_Bar.DataLabelStyle.Visible = false;
            m_Bar.Legend.Mode            = SeriesLegendMode.DataPoints;
            m_Bar.BarShape               = BarShape.Cylinder;
            m_Bar.BorderStyle.Width      = new NLength(0, NGraphicsUnit.Pixel);
            m_Bar.FillStyle              = new NGradientFillStyle(GradientStyle.Vertical, GradientVariant.Variant1, Color.LightSteelBlue, Color.MidnightBlue);
            m_Bar.Values.FillRandomRange(Random, 12, 0, 50);

            // form controls
            m_bSkipUpdate = true;
            m_FunctionCombo.Items.Add("Average");
            m_FunctionCombo.Items.Add("Median");
            m_FunctionCombo.Items.Add("Min");
            m_FunctionCombo.Items.Add("Max");
            m_FunctionCombo.SelectedIndex = 0;

            m_GroupingCombo.Items.Add("Do not group");
            m_GroupingCombo.Items.Add("Group by every 2 values");
            m_GroupingCombo.Items.Add("Group by every 3 values");
            m_GroupingCombo.Items.Add("Group by every 4 values");
            m_GroupingCombo.SelectedIndex = 0;
            m_bSkipUpdate = false;

            m_FunctionCombo_SelectedIndexChanged(null, null);
        }
コード例 #20
0
        private void ConfigureChart(NChart chart, Color color)
        {
            chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal);
            chart.Axis(StandardAxis.Depth).Visible          = false;
            chart.Wall(ChartWallType.Floor).Visible         = false;
            chart.Wall(ChartWallType.Left).Visible          = false;
            chart.Wall(ChartWallType.Back).Width            = 0;
            chart.Wall(ChartWallType.Back).FillStyle        = new NColorFillStyle(Color.FromArgb(239, 245, 239));
            chart.Wall(ChartWallType.Back).ShadowStyle.Type = ShadowType.Solid;

            // create a bar series
            NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);

            bar.Name                   = "Bar 1";
            bar.Legend.Mode            = SeriesLegendMode.DataPoints;
            bar.DataLabelStyle.Visible = false;
            bar.InflateMargins         = true;
            bar.FillStyle              = new NColorFillStyle(color);
            bar.Values.ValueFormatter  = new NNumericValueFormatter("0.00");

            for (int i = 0; i < 15; i++)
            {
                bar.Values.Add(Random.NextDouble() * 900);
            }
        }
コード例 #21
0
        public override void Initialize()
        {
            base.Initialize();

            // add a label
            NLabel title = nChartControl1.Labels.AddHeader("Filtering Data");

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

            m_Chart = nChartControl1.Charts[0];
            m_Chart.Axis(StandardAxis.Depth).Visible = false;

            m_Bar                       = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar);
            m_Bar.Legend.Mode           = SeriesLegendMode.None;
            m_Bar.DataLabelStyle.Format = "<value>";
            m_Bar.Values.FillRandom(Random, 10);

            ResetFilter();

            compareMethodCombo.SelectedIndex   = 0;
            subsetOperationCombo.SelectedIndex = 0;
        }
コード例 #22
0
        private void DataLabelModeCombo_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            if (nChartControl1 == null)
            {
                return;
            }

            NBarSeries bar = (NBarSeries)nChartControl1.Charts[0].Series[0];

            switch (DataLabelModeCombo.SelectedIndex)
            {
            case 0:
                m_DataLabelStyle = bar.DataLabelStyle;
                break;

            case 1:
                m_DataLabelStyle = (NDataLabelStyle)bar.DataLabelStyles[3];
                break;
            }

            // init controls from data label
            ArrowLengthScroll.Value      = (int)(m_DataLabelStyle.ArrowLength.Value);
            FormatCombo.Text             = m_DataLabelStyle.Format;
            VertAlignCombo.SelectedIndex = (int)m_DataLabelStyle.VertAlign;
        }
コード例 #23
0
        private void StyleCombo_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            NBarSeries bar = (NBarSeries)nChartControl1.Charts[0].Series[0];

            bar.BarShape = (BarShape)StyleCombo.SelectedIndex;
            nChartControl1.Refresh();
        }
コード例 #24
0
        private void HasBottomEdgeCheckBox_Checked(object sender, System.Windows.RoutedEventArgs e)
        {
            NBarSeries bar = (NBarSeries)nChartControl1.Charts[0].Series[0];

            bar.HasBottomEdge = (bool)HasBottomEdgeCheckBox.IsChecked;
            nChartControl1.Refresh();
        }
コード例 #25
0
            public override bool IsEnabled()
            {
                NThinChartControl control = (NThinChartControl)this.m_Control;
                NBarSeries        bar     = control.Charts[0].Series[0] as NBarSeries;

                return(bar.DataLabelStyle.Visible);
            }
コード例 #26
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override NWidget CreateExampleContent()
        {
            NChartView chartView = CreateCartesianChartView();

            // configure title
            chartView.Surface.Titles[0].Text = "Series Legend View";

            // configure chart
            m_Chart = (NCartesianChart)chartView.Surface.Charts[0];

            m_Chart.SetPredefinedCartesianAxes(ENPredefinedCartesianAxis.XOrdinalYLinear);

            // add interlace stripe
            NLinearScale linearScale = m_Chart.Axes[ENCartesianAxis.PrimaryY].Scale as NLinearScale;
            NScaleStrip  strip       = new NScaleStrip(new NColorFill(ENNamedColor.Beige), null, true, 0, 0, 1, 1);

            strip.Interlaced = true;
            linearScale.Strips.Add(strip);

            // add a bar series
            NBarSeries bar1 = new NBarSeries();

            bar1.Name           = "Bar1";
            bar1.MultiBarMode   = ENMultiBarMode.Series;
            bar1.DataLabelStyle = new NDataLabelStyle(false);
            bar1.ValueFormatter = new NNumericValueFormatter("0.###");
            m_Chart.Series.Add(bar1);

            // add another bar series
            NBarSeries bar2 = new NBarSeries();

            bar2.Name           = "Bar2";
            bar2.MultiBarMode   = ENMultiBarMode.Clustered;
            bar2.DataLabelStyle = new NDataLabelStyle(false);
            bar2.ValueFormatter = new NNumericValueFormatter("0.###");
            m_Chart.Series.Add(bar2);

            // add another bar series
            NBarSeries bar3 = new NBarSeries();

            bar3.Name           = "Bar2";
            bar3.MultiBarMode   = ENMultiBarMode.Clustered;
            bar3.DataLabelStyle = new NDataLabelStyle(false);
            bar3.ValueFormatter = new NNumericValueFormatter("0.###");
            m_Chart.Series.Add(bar3);

            Random random = new Random();

            for (int i = 0; i < 5; i++)
            {
                bar1.DataPoints.Add(new NBarDataPoint(random.Next(10, 100)));
                bar2.DataPoints.Add(new NBarDataPoint(random.Next(10, 100)));
                bar3.DataPoints.Add(new NBarDataPoint(random.Next(10, 100)));
            }

            chartView.Document.StyleSheets.ApplyTheme(new NChartTheme(ENChartPalette.Bright, false));

            return(chartView);
        }
コード例 #27
0
        public override void Initialize()
        {
            base.Initialize();

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

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

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

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

            chart.BoundsMode = BoundsMode.Stretch;

            NLinearScaleConfigurator linearScale = chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator as NLinearScaleConfigurator;

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

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

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

            NDateTimeScaleConfigurator dateTimeScale = new NDateTimeScaleConfigurator();

            dateTimeScale.LabelFitModes       = new LabelFitMode[] { LabelFitMode.AutoScale };
            dateTimeScale.LabelGenerationMode = LabelGenerationMode.Stagger2;
            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = dateTimeScale;

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

            bar.Name                   = "Bar Series";
            bar.InflateMargins         = true;
            bar.UseXValues             = true;
            bar.UseZValues             = false;
            bar.DataLabelStyle.Visible = false;
            bar.ShadowStyle.Type       = ShadowType.Solid;
            bar.ShadowStyle.Color      = Color.FromArgb(30, 0, 0, 0);

            GenerateYValues(nValuesCount);
            GenerateXValues(nValuesCount);

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

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

            styleSheet.Apply(nChartControl1.Document);
        }
コード例 #28
0
        protected void PositiveAndNegativeDataButton_Click(object sender, EventArgs e)
        {
            NBarSeries bar = (NBarSeries)nChart.Series[0];

            bar.Values.FillRandomRange(Random, categoriesCount, -100, 100);

            PositiveDataCheckBox.Checked = false;
        }
コード例 #29
0
        public override void Initialize()
        {
            base.Initialize();
            nChartControl1.Controller.Tools.Add(new NPanelSelectorTool());
            nChartControl1.Controller.Tools.Add(new NTrackballTool());

            nChartControl1.Legends.Clear();

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

            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(3, NRelativeUnit.ParentPercentage));

            NChart chart = nChartControl1.Charts[0];

            chart.Enable3D   = true;
            chart.Width      = 55;
            chart.Height     = 25;
            chart.Depth      = 40;
            chart.BoundsMode = BoundsMode.Fit;
            chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted);
            chart.LightModel.GlobalAmbientLight = Color.FromArgb(20, 20, 20);

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

            stripStyle.Interlaced  = true;
            stripStyle.ShowAtWalls = new ChartWallType[] {
                ChartWallType.Back,
                ChartWallType.Left,
                ChartWallType.Right,
                ChartWallType.Front
            };

            NStandardScaleConfigurator scaleY = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;

            scaleY.StripStyles.Add(stripStyle);

            // create several series
            for (int i = 0; i < 4; i++)
            {
                NBarSeries bar = (NBarSeries)chart.Series.Add(SeriesType.Bar);
                bar.Values.FillRandom(Random, 6);
                bar.DataLabelStyle.Visible = false;
            }

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

            styleSheet.Apply(nChartControl1.Document);

            // init form controls
            AutoWallVisibilityCheck.Checked    = true;
            LightsInCameraSpaceCheck.Checked   = true;
            AxisAnchorsModeCombo.SelectedIndex = 0;
        }
コード例 #30
0
        void GenerateYData(NBarSeries bar)
        {
            bar.Values.Clear();

            for (int i = 0; i < nItemsCount; i++)
            {
                bar.Values.Add(Random.NextDouble());
            }
        }
コード例 #31
0
ファイル: Graph.cs プロジェクト: lewis810/HueApp
        private void callPersonalGraph(string projectName, string ScenarioName, int idx)
        {
            nChartControl1.Clear();

            //rData.getRData()[0].taskName 이런식으로 인덱스 줘서 사용하면 될 듯
            m_FuncCalculator = new NFunctionCalculator();

            nChartControl1.Legends.Clear();



            // set a chart title
            NLabel title = nChartControl1.Labels.AddHeader("Task x 소요 시간");
            //title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 18, FontStyle.Regular);
            title.TextStyle.FontStyle = new NFontStyle(pfc.Families[0].ToString(), 18, FontStyle.Regular);
            title.ContentAlignment = ContentAlignment.BottomCenter;
            title.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage));

            // setup chart
            m_Chart = nChartControl1.Charts[0];
            m_Chart.BoundsMode = BoundsMode.Stretch;
            m_Chart.Location = new NPointL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(15, NRelativeUnit.ParentPercentage));
            m_Chart.Size = new NSizeL(new NLength(80, NRelativeUnit.ParentPercentage), new NLength(75, NRelativeUnit.ParentPercentage));
            


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


            // add a line series for the function
            m_Line = (NLineSeries)m_Chart.Series.Add(SeriesType.Line);
            m_Line.MarkerStyle.Visible = true;
            m_Line.MarkerStyle.BorderStyle.Color = Color.DarkGreen;
            m_Line.MarkerStyle.BorderStyle.Width = new NLength(2, NGraphicsUnit.Pixel);
            m_Line.MarkerStyle.Width = new NLength(1.2f, NRelativeUnit.ParentPercentage);
            m_Line.MarkerStyle.Height = new NLength(1.2f, NRelativeUnit.ParentPercentage);
            m_Line.MarkerStyle.PointShape = PointShape.Cylinder;
            m_Line.MarkerStyle.FillStyle = new NColorFillStyle(Color.Gold);
            m_Line.BorderStyle.Color = Color.DarkGreen;
            m_Line.BorderStyle.Width = new NLength(2, NGraphicsUnit.Pixel);
            m_Line.Legend.Mode = SeriesLegendMode.None;
            m_Line.DataLabelStyle.Format = "<value>";
            m_Line.Values.ValueFormatter = new NNumericValueFormatter("0.0");
            m_Line.ShadowStyle.Type = ShadowType.GaussianBlur;
            m_Line.ShadowStyle.Offset = new NPointL(2, 2);
            m_Line.ShadowStyle.Color = Color.FromArgb(120, 0, 0, 0);
            m_Line.ShadowStyle.FadeLength = new NLength(5);


            // add the bar series
            m_Bar = (NBarSeries)m_Chart.Series.Add(SeriesType.Bar);
            m_Bar.Name = "Bar1";
            m_Bar.Values.Name = "values";
            m_Bar.Values.ValueFormatter = new NNumericValueFormatter("0.0");
            m_Bar.MultiBarMode = MultiBarMode.Stacked;
            m_Bar.DataLabelStyle.Visible = true; // 바에 보이는 값
            //m_Bar.Legend.Mode = SeriesLegendMode.None; // 범례 안보이게 하는 거
            m_Bar.BarShape = BarShape.Cylinder;
            m_Bar.BorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel);
            m_Bar.FillStyle = new NColorFillStyle(Color.DarkKhaki);
            m_Bar.ShadowStyle.Type = ShadowType.Solid;
            m_Bar.ShadowStyle.Offset = new NPointL(2, 2);
            m_Bar.ShadowStyle.Color = Color.FromArgb(80, 0, 0, 0);
            //m_Bar.Values.FillRandomRange(new Random(), 14, 0, 100);

            NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator();
            //m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale;
            m_Chart.Axis(StandardAxis.PrimaryX).ScrollBar.ResetButton.Visible = false;

            NNumericAxisPagingView numericPagingView = new NNumericAxisPagingView(new NRange1DD(0, 10));
            m_Chart.Axis(StandardAxis.PrimaryX).PagingView = numericPagingView;
            m_Chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true;
            nChartControl1.Controller.Tools.Add(new NAxisScrollTool());

            NStandardScaleConfigurator scaleConfiguratorX = (NStandardScaleConfigurator)m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;
            scaleConfiguratorX.MajorTickMode = MajorTickMode.AutoMaxCount;

            scaleConfiguratorX.AutoLabels = false;

            foreach (ResultData.ResultInfo temp in rData.getRData())
            {
                // 현재 찾고자 하는 프로젝트와 시나리오랑 같으면
                if (temp.projectName == projectName && temp.taskName == ScenarioName)
                {
                    if (idx == -1 /*&& temp.isMin == true*/) // ***************************************************************************************************************** check
                    {
                        ImgAverageInfo.Clear();

                        // 해당 시나리오 값에서 이동한 path 이미지들 값 가져오기
                        foreach (ResultData.ImgTime imgTemp in temp.pathInfo)
                        {
                            bool inList = false;

                            float timeValue = System.Convert.ToSingle(imgTemp.timeImg);

                            // 리스트 내에 같은 값 찾기

                            if (ImgAverageInfo.Count != 0)
                            {
                                foreach (ImgAverageTime inListImg in ImgAverageInfo)
                                {
                                    // 같은게 있다면
                                    if (inListImg.imgName == imgTemp.imgName)
                                    {
                                        inListImg.count += 1;
                                        inListImg.imgTime += timeValue;
                                        inList = true;
                                        break;
                                    }
                                }
                            }

                            // 리스트 내에 없다면
                            if (inList == false)
                                ImgAverageInfo.Add(new ImgAverageTime() { imgName = imgTemp.imgName, imgTime = timeValue, count = 1 });
                        }
                    }
                    // Idx랑 같으면
                    else if (temp.idx == idx)
                    {
                        // 해당 시나리오 값에서 이동한 path 이미지들 값 가져오기
                        foreach (ResultData.ImgTime imgTemp in temp.pathInfo)
                        {
                            scaleConfiguratorX.Labels.Add(imgTemp.imgName);
                            m_Bar.Values.Add(imgTemp.timeImg);
                        }
                    }
                }
            }


            if (idx == -1)
            {
                foreach (ImgAverageTime listImg in ImgAverageInfo)
                {
                    scaleConfiguratorX.Labels.Add(listImg.imgName);
                    m_Bar.Values.Add(listImg.imgTime / listImg.count);
                }
            }





            //m_FuncCalculator.Arguments.Add(m_Line.Values);
            m_FuncCalculator.Arguments.Add(m_Bar.Values);
            m_FuncCalculator.Expression = "CUMSUM(values)";
            m_Line.Values = m_FuncCalculator.Calculate();

            m_Line.Values.ValueFormatter = new NNumericValueFormatter("0.0");


            // form controls
            /*m_FunctionCombo.Items.Add("Power");
            m_FunctionCombo.Items.Add("Cumulative");
            m_FunctionCombo.Items.Add("Exponential Average");
            m_FunctionCombo.SelectedIndex = 0;*/


            nChartControl1.Refresh();
        }