Ejemplo n.º 1
0
            private void ExplodePieSegment(NStateObject state, EventArgs e, int offset)
            {
                //	this method is called when the web control operates in the Nevron Instant Callback mode
                NCallbackMouseEventArgs  args       = e as NCallbackMouseEventArgs;
                NChartSessionStateObject chartState = state as NChartSessionStateObject;
                NHitTestResult           result     = chartState.HitTest(args);
                NRootPanel rootPanel = chartState.Document.RootPanel;

                if (result.ChartElement == ChartElement.DataPoint)
                {
                    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(offset);
                        }
                        else
                        {
                            pieSeries.Detachments.Add(0);
                        }
                    }
                }
            }
            public override void OnAsyncCustomCommand(string webControlId, System.Web.HttpContext context, NStateObject state, NCallbackCustomCommandArgs args)
            {
                switch (args.Command.Name)
                {
                case "displayHitsForDate":
                    NChartSessionStateObject chartState = state as NChartSessionStateObject;
                    NRootPanel rootPanel = chartState.Document.RootPanel;
                    NPieSeries pieSeries = rootPanel.Charts[0].Series[0] as NPieSeries;

                    int   dataPointIndex = int.Parse(args.Command.Arguments["dataPointIndex"] as string);
                    int[] data           = NDrillDownDemoUC.hitsPerDayPerRegion[dataPointIndex];

                    pieSeries.Values.Clear();
                    pieSeries.Labels.Clear();
                    int length = hitsPerDayPerRegion[0].Length;
                    for (int i = 0; i < length; i++)
                    {
                        pieSeries.Values.Add(data[i]);
                        pieSeries.Labels.Add(NDrillDownDemoUC.regionNames[i]);
                    }

                    DateTime selectedDate = NDrillDownDemoUC.startDate.AddDays(dataPointIndex);
                    NLabel   header       = rootPanel.Labels[0];
                    header.Text = selectedDate.ToString("dd/MMM/yyyy") + ", Hits per Region";

                    break;
                }
            }
            public override void OnAsyncRefresh(string webControlId, System.Web.HttpContext context, NStateObject state, EventArgs args)
            {
                NChartSessionStateObject chartState = state as NChartSessionStateObject;
                NRootPanel  rootPanel = chartState.Document.RootPanel;
                NLineSeries line      = (NLineSeries)chartState.Document.RootPanel.Charts[0].Series[0];

                if (line == null)
                {
                    return;
                }

                if (line.Values.Count == 0)
                {
                    return;
                }

                double dPrev = (double)line.Values[line.Values.Count - 1];

                double value;

                GenerateDataPoint(dPrev, new NRange1DD(50, 350), out value);
                line.Values.RemoveAt(0);
                line.XValues.RemoveAt(0);

                line.Values.Add(value);

                int nLast = (line.XValues.Count > 0 ? line.XValues.Count - 1 : 0);

                double dLastValue = (double)line.XValues[nLast];

                line.XValues.Add(DateTime.Now);
                UpdateIndicators(chartState.Document);
            }
            private void ColorPieSegment(NStateObject state, EventArgs e, Color c)
            {
                NCallbackMouseEventArgs  args       = e as NCallbackMouseEventArgs;
                NChartSessionStateObject chartState = state as NChartSessionStateObject;
                NHitTestResult           result     = chartState.HitTest(args);
                NRootPanel rootPanel = chartState.Document.RootPanel;

                if (result.ChartElement == ChartElement.DataPoint)
                {
                    NPieSeries pieSeries = result.Series as NPieSeries;
                    for (int i = 0; i < pieSeries.Values.Count; i++)
                    {
                        if (i == result.DataPointIndex)
                        {
                            pieSeries.FillStyles[i]   = new NColorFillStyle(c);
                            pieSeries.BorderStyles[i] = new NStrokeStyle(1, Color.White);
                        }
                        else
                        {
                            int   colorIndex = i % NExampleUC.arrCustomColors2.Length;
                            Color color      = NExampleUC.arrCustomColors2[colorIndex];

                            pieSeries.FillStyles[i]   = new NColorFillStyle(color);
                            pieSeries.BorderStyles[i] = new NStrokeStyle(1, color);
                        }
                    }
                }
            }
Ejemplo n.º 5
0
            public override void OnAsyncRefresh(string webControlId, System.Web.HttpContext context, NStateObject state, EventArgs args)
            {
                NChartSessionStateObject chartState = state as NChartSessionStateObject;
                NRootPanel rootPanel = chartState.Document.RootPanel;
                NPieChart  pieChart  = rootPanel.Charts[0] as NPieChart;

                pieChart.BeginAngle += 1;
                if (pieChart.BeginAngle >= 360)
                {
                    pieChart.BeginAngle = 0;
                }
            }
Ejemplo n.º 6
0
            public override void OnAsyncRefresh(string webControlId, System.Web.HttpContext context, NStateObject state, EventArgs args)
            {
                //	this method is called when the web control operates in the Nevron Instant Callback mode
                DoSimulateResponseDelay();

                NChartSessionStateObject chartState = state as NChartSessionStateObject;
                NRootPanel rootPanel = chartState.Document.RootPanel;
                NPieChart  pieChart  = rootPanel.Charts[0] as NPieChart;

                pieChart.BeginAngle += 1;
                if (pieChart.BeginAngle >= 360)
                {
                    pieChart.BeginAngle = 0;
                }
            }
            private void ExplodePieSegment(NStateObject state, EventArgs e, int offset)
            {
                NCallbackMouseEventArgs  args       = e as NCallbackMouseEventArgs;
                NChartSessionStateObject chartState = state as NChartSessionStateObject;
                NHitTestResult           result     = chartState.HitTest(args);

                if (result.ChartElement == ChartElement.DataPoint)
                {
                    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(offset);
                        }
                        else
                        {
                            pieSeries.Detachments.Add(0);
                        }
                    }
                }
            }
            void UpdateDataWindow(string webControlId, System.Web.HttpContext context, NStateObject state, NPointF ptViewPoint)
            {
                NChartSessionStateObject chartState = state as NChartSessionStateObject;
                NRootPanel      rootPanel           = chartState.Document.RootPanel;
                NCartesianChart chart         = rootPanel.Charts[0] as NCartesianChart;
                NVector2DD      vecScalePoint = new NVector2DD();
                NAxis           xAxis         = chart.Axis(StandardAxis.PrimaryX);
                NAxis           yAxis         = chart.Axis(StandardAxis.PrimaryY);

                using (NChartRasterView view = new NChartRasterView(chartState.Document, chartState.Size, NResolution.ScreenResolution))
                {
                    view.RecalcLayout();

                    NViewToScale2DTransformation viewToScale = new NViewToScale2DTransformation(
                        view.Context,
                        chart,
                        (int)StandardAxis.PrimaryX,
                        (int)StandardAxis.PrimaryY
                        );

                    if (viewToScale.Transform(ptViewPoint, ref vecScalePoint))
                    {
                        double rangeMin = vecScalePoint.X - DataWindowWidth / 2;
                        rangeMin = xAxis.Scale.ViewRange.GetValueInRange(rangeMin);

                        double rangeMax = rangeMin + DataWindowWidth;
                        rangeMax = xAxis.Scale.ViewRange.GetValueInRange(rangeMax);

                        rangeMin = rangeMax - DataWindowWidth;

                        NRangeSelection selection = chart.RangeSelections[0] as NRangeSelection;
                        selection.HorizontalAxisRange = new NRange1DD(rangeMin, rangeMax);
                        selection.VerticalAxisRange   = new NRange1DD(-waveDataWave1Factor, waveDataWave1Factor);
                    }
                }
            }
            private void ProcessMouseEvent(NStateObject state, EventArgs e, Color c)
            {
                NCallbackMouseEventArgs  args       = e as NCallbackMouseEventArgs;
                NChartSessionStateObject chartState = state as NChartSessionStateObject;
                NHitTestResult           result     = chartState.HitTest(args);
                NRootPanel rootPanel = chartState.Document.RootPanel;

                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 rootPanel.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 = rootPanel.ChildPanels.Count;
                        for (int i = 0; i < nCount; i++)
                        {
                            if (rootPanel.ChildPanels[i] is NRoundedRectangularCallout)
                            {
                                rootPanel.ChildPanels.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();
                        rootPanel.ChildPanels.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;
                    }
                }
            }