private void GenerateData(NErrorBarSeries series)
        {
            series.ClearDataPoints();

            NVector3DF v       = new NVector3DF();
            Random     randrom = new Random();

            for (int i = 0; i < 10; i++)
            {
                v.X = (float)(0.5 - randrom.NextDouble());
                v.Y = (float)(0.5 - randrom.NextDouble());
                v.Z = (float)(0.5 - randrom.NextDouble());

                v.Normalize(40.0f);

                series.Values.Add(v.X);
                series.XValues.Add(v.Y);
                series.ZValues.Add(v.Z);

                series.LowerErrorsX.Add(3 + 5 * randrom.NextDouble());
                series.UpperErrorsX.Add(3 + 5 * randrom.NextDouble());
                series.LowerErrorsY.Add(3 + 5 * randrom.NextDouble());
                series.UpperErrorsY.Add(3 + 5 * randrom.NextDouble());
                series.LowerErrorsZ.Add(3 + 5 * randrom.NextDouble());
                series.UpperErrorsZ.Add(3 + 5 * randrom.NextDouble());
            }
        }
Exemple #2
0
            void INCustomSeriesCallback.Paint2D(NChartRenderingContext2D context, NGraphics graphics)
            {
                NVector3DF  vecView  = new NVector3DF();
                NVector3DF  vecModel = new NVector3DF();
                NScaleRuler rulerX   = m_Chart.Axis(m_Series.HorizontalAxes[0]).Scale.Ruler;
                NScaleRuler rulerY   = m_Chart.Axis(m_Series.VerticalAxes[0]).Scale.Ruler;

                // current number of accumulated Bezier points
                int bpCount = 0;

                // accumulated Bezier points
                PointF[] bezierPoints = new PointF[4];

                for (int i = 0; i < Points.Length; i++)
                {
                    // Transform values to chart model coorinates
                    vecModel.X = rulerX.LogicalToScale(Points[i].X);
                    vecModel.Y = rulerY.LogicalToScale(Points[i].Y);

                    // Transform model coordinates to view coordinates
                    m_Chart.TransformModelToClient(vecModel, ref vecView);

                    // Draw the current point
                    bool isControlPoint = (i % 3) != 0;
                    if (isControlPoint)
                    {
                        NRectangleF rect = new NRectangleF(vecView.X - 3, vecView.Y - 3, 6, 6);
                        graphics.PaintEllipse(ControlPointFill, null, rect);
                    }
                    else
                    {
                        NRectangleF rect = new NRectangleF(vecView.X - 5, vecView.Y - 5, 10, 10);
                        graphics.PaintEllipse(PointFill, null, rect);
                    }

                    // Accumulate Bezier point
                    bezierPoints[bpCount] = new PointF(vecView.X, vecView.Y);
                    bpCount++;

                    if (bpCount == 4)
                    {
                        // Draw tangents
                        graphics.DrawLine(TangentStroke, new NPointF(bezierPoints[0]), new NPointF(bezierPoints[1]));
                        graphics.DrawLine(TangentStroke, new NPointF(bezierPoints[2]), new NPointF(bezierPoints[3]));

                        // Draw Bezier line
                        GraphicsPath path = new GraphicsPath();
                        path.AddBezier(bezierPoints[0], bezierPoints[1], bezierPoints[2], bezierPoints[3]);
                        graphics.PaintPath(null, BezierStroke, path);
                        path.Dispose();

                        // Update accumultaed points
                        bezierPoints[0] = bezierPoints[3];
                        bpCount         = 1;
                    }
                }
            }
Exemple #3
0
        private void FillData()
        {
            NChart chart = nChartControl1.Charts[0];
            NTriangulatedSurfaceSeries surface = (NTriangulatedSurfaceSeries)chart.Series[0];

            Stream       stream = null;
            BinaryReader reader = null;

            try
            {
                // fill the XYZ data from a binary resource
                stream = NResourceHelper.GetResourceStream(GetType().Assembly, "DataXYZ.bin", "Nevron.Examples.Chart.Wpf.Resources");
                reader = new BinaryReader(stream);

                int nDataPointsCount = (int)stream.Length / 12;

                //surface.Data.SetCapacity(nDataPointsCount);
                NVector3DF[] data = new NVector3DF[nDataPointsCount];

                // fill Y values
                for (int i = 0; i < nDataPointsCount; i++)
                {
                    data[i].Y = reader.ReadSingle();
                }

                // fill X values
                for (int i = 0; i < nDataPointsCount; i++)
                {
                    data[i].X = reader.ReadSingle();
                }

                // fill Z values
                for (int i = 0; i < nDataPointsCount; i++)
                {
                    data[i].Z = reader.ReadSingle();
                }

                for (int i = 0; i < nDataPointsCount; i++)
                {
                    surface.Data.AddValue(data[i]);
                }
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }

                if (stream != null)
                {
                    stream.Close();
                }
            }
        }
Exemple #4
0
        private void FillData()
        {
            NChart chart = nChartControl1.Charts[0];
            NTriangulatedSurfaceSeries surface = (NTriangulatedSurfaceSeries)chart.Series[0];

            Stream       stream = null;
            BinaryReader reader = null;

            try
            {
                // fill the XYZ data from a binary resource
                string path = MapPathSecure(TemplateSourceDirectory) + "\\DataXYZ.bin";
                stream = new FileStream(path, FileMode.Open, FileAccess.Read);
                reader = new BinaryReader(stream);

                int nDataPointsCount = (int)stream.Length / 12;

                //surface.Data.SetCapacity(nDataPointsCount);
                NVector3DF[] data = new NVector3DF[nDataPointsCount];

                // fill Y values
                for (int i = 0; i < nDataPointsCount; i++)
                {
                    data[i].Y = reader.ReadSingle();
                }

                // fill X values
                for (int i = 0; i < nDataPointsCount; i++)
                {
                    data[i].X = reader.ReadSingle();
                }

                // fill Z values
                for (int i = 0; i < nDataPointsCount; i++)
                {
                    data[i].Z = reader.ReadSingle();
                }

                surface.Data.Clear();
                surface.Data.AddValues(data);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }

                if (stream != null)
                {
                    stream.Close();
                }
            }
        }
Exemple #5
0
            public override void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs)
            {
                if (m_Parent.m_bUpdateWatermark == false)
                {
                    return;
                }

                // intercepts the on chart after paint event and converts
                // point or XYZ coordniates to chart viewport coordinates
                // used to position the custom watermark
                NChartControl chartControl = m_Parent.nChartControl1;
                NWatermark    watermark    = chartControl.Watermarks[0];
                NChart        chart        = m_Parent.nChartControl1.Charts[0];

                NPointF    viewPoint     = new NPointF();
                NVector3DF vecModelPoint = new NVector3DF();

                NModel3DToViewTransformation model3DToViewTransformation = new NModel3DToViewTransformation(chartControl.View.Context, chart.Projection);

                switch (m_Parent.WatermarkPositionComboBox.SelectedIndex)
                {
                case 0:
                    vecModelPoint.X = chart.Axis(StandardAxis.PrimaryX).TransformScaleToModel(false, (double)m_Parent.XPositionNumericUpDown.Value);
                    vecModelPoint.Y = chart.Axis(StandardAxis.PrimaryY).TransformScaleToModel(false, (double)m_Parent.YPositionNumericUpDown.Value);
                    vecModelPoint.Z = chart.Axis(StandardAxis.Depth).TransformScaleToModel(false, (double)m_Parent.ZPositionNumericUpDown.Value);
                    break;

                case 1:
                    NVector3DF vecPoint = new NVector3DF();
                    int        nIndex   = (int)m_Parent.DataPointNumericUpDown.Value;

                    vecPoint.X = (float)(double)(m_Parent.m_Point.XValues[nIndex]);
                    vecPoint.Y = (float)(double)(m_Parent.m_Point.Values[nIndex]);
                    vecPoint.Z = (float)(double)(m_Parent.m_Point.ZValues[nIndex]);

                    vecModelPoint.X = chart.Axis(StandardAxis.PrimaryX).TransformScaleToModel(false, vecPoint.X);
                    vecModelPoint.Y = chart.Axis(StandardAxis.PrimaryY).TransformScaleToModel(false, vecPoint.Y);
                    vecModelPoint.Z = chart.Axis(StandardAxis.Depth).TransformScaleToModel(false, vecPoint.Z);
                    break;
                }

                model3DToViewTransformation.Transform(vecModelPoint, ref viewPoint);

                // convert the view point to parent pixel coordinates
                watermark.TransformViewPointToParent(ref viewPoint);

                watermark.Location = new NPointL(
                    new NLength(viewPoint.X, NGraphicsUnit.Pixel),
                    new NLength(viewPoint.Y, NGraphicsUnit.Pixel));

                m_Parent.nChartControl1.RecalcLayout();
            }
        private void UpdateFilter()
        {
            if (m_Updating)
            {
                return;
            }

            NVector3DF vector = new NVector3DF(
                (float)PositionXnumericUpDown.Value,
                (float)PositionYnumericUpDown.Value,
                (float)PositionZnumericUpDown.Value);

            m_LightingFilter.Position        = vector;
            m_LightingFilter.LightSourceType = (LightSourceType)(LightSourceTypeComboBox.SelectedIndex);
            m_LightingFilter.BevelDepth      = new NLength((int)BevelDepthNumericUpDown.Value);
            m_LightingFilter.BlurType        = (BlurType)BlurTypeComboBox.SelectedIndex;
            m_LightingFilter.SurfaceScale    = (float)SurfaceScaleNumericUpDown.Value;
            m_LightingFilter.Shininess       = (float)ShininessNumericUpDown.Value;

            nChartControl1.Refresh();
        }
Exemple #7
0
            public override void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs)
            {
                NGraphics graphics = eventArgs.Graphics;

                double     dPreviousValue, dCurrentValue;
                int        nBarCount = 10;
                NChart     chart     = panel as NChart;
                NBarSeries bar       = (NBarSeries)chart.Series[0];

                NAxis horzAxis = chart.Axis(StandardAxis.PrimaryX);
                NAxis vertAxis = chart.Axis(StandardAxis.PrimaryY);

                NVector3DF vecClientPoint = new NVector3DF();
                NVector3DF vecModelPoint  = new NVector3DF();

                int nBarSize = (int)(chart.ContentArea.Width * (int)bar.WidthPercent) / (nBarCount * 200);

                // init pens and brushes
                NStrokeStyle rectStrokeStyle = new NStrokeStyle(1, Color.DarkBlue);
                NFillStyle   rectFillStyle   = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.FromArgb(125, Color.LightBlue), Color.FromArgb(125, Color.DarkBlue));

                NLightingImageFilter lightingFilter = new NLightingImageFilter();

                NStrokeStyle positiveArrowStrokeStyle = new NStrokeStyle(1, Color.DarkGreen);
                NFillStyle   positiveArrowFillStyle   = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.Green, Color.DarkGreen);

                positiveArrowFillStyle.ImageFiltersStyle.Filters.Add(lightingFilter);

                NStrokeStyle equalSignStrokeStyle = new NStrokeStyle(1, Color.DarkGray);
                NFillStyle   equalSignFillStyle   = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.Gray, Color.DarkGray);

                positiveArrowFillStyle.ImageFiltersStyle.Filters.Add(lightingFilter);

                NStrokeStyle negativeArrowStrokeStyle = new NStrokeStyle(1, Color.DarkRed);
                NFillStyle   negativeArrowFillStyle   = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.Red, Color.DarkRed);

                positiveArrowFillStyle.ImageFiltersStyle.Filters.Add(lightingFilter);

                for (int i = 1; i < bar.Values.Count; i++)
                {
                    dPreviousValue = (double)bar.Values[i - 1];
                    dCurrentValue  = (double)bar.Values[i];

                    vecModelPoint.X = horzAxis.TransformScaleToModel(false, i);
                    vecModelPoint.Y = vertAxis.TransformScaleToModel(false, (float)(double)bar.Values[i]);
                    vecModelPoint.Z = 0;

                    if (!chart.TransformModelToClient(vecModelPoint, ref vecClientPoint))
                    {
                        continue;
                    }

                    RectangleF rcArrowRect = new RectangleF(vecClientPoint.X - nBarSize, vecClientPoint.Y - nBarSize, 2 * nBarSize, 2 * nBarSize);

                    if (rcArrowRect.Width <= 0 || rcArrowRect.Height <= 0)
                    {
                        continue;
                    }

                    if (!DisplayMark(dCurrentValue, dPreviousValue))
                    {
                        continue;
                    }

                    // draw arrow background
                    GraphicsPath path = GetRoundRectanglePath(rcArrowRect);

                    graphics.PaintPath(rectFillStyle, rectStrokeStyle, path);

                    path.Dispose();

                    rcArrowRect.Inflate(-5, -5);

                    // draw the arrow itself
                    if (rcArrowRect.Width <= 0 || rcArrowRect.Height <= 0)
                    {
                        continue;
                    }

                    if (dCurrentValue < dPreviousValue)
                    {
                        // draw negative arrow
                        path = GetArrowPath(rcArrowRect, false);

                        graphics.PaintPath(negativeArrowFillStyle, negativeArrowStrokeStyle, path);

                        path.Dispose();
                    }
                    else if (dCurrentValue > dPreviousValue)
                    {
                        // draw positive arrow
                        path = GetArrowPath(rcArrowRect, true);

                        graphics.PaintPath(positiveArrowFillStyle, positiveArrowStrokeStyle, path);

                        path.Dispose();
                    }
                    else
                    {
                        // draw equal sign
                        NRectangleF rect = new NRectangleF(rcArrowRect.Left, rcArrowRect.Top, rcArrowRect.Width, rcArrowRect.Height / 3.0f);

                        graphics.PaintRectangle(equalSignFillStyle, equalSignStrokeStyle, rect);

                        rect = new NRectangleF(rcArrowRect.Left, rcArrowRect.Bottom - rect.Height, rcArrowRect.Width, rect.Height);

                        graphics.PaintRectangle(equalSignFillStyle, equalSignStrokeStyle, rect);
                    }
                }
            }
        public override void Initialize()
        {
            base.Initialize();

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

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

            // setup chart
            m_Chart = nChartControl1.Charts[0];
            m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.Orthogonal);
            m_Chart.Axis(StandardAxis.Depth).Visible = false;

            NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator();

            m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale;
            linearScale.MajorGridStyle.LineStyle.Pattern          = LinePattern.Dot;

            linearScale = new NLinearScaleConfigurator();
            m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale;
            linearScale.MajorGridStyle.LineStyle.Pattern          = LinePattern.Dot;
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);

            m_Bubble = (NBubbleSeries)m_Chart.Series.Add(SeriesType.Bubble);
            m_Bubble.DataLabelStyle.Visible = false;
            m_Bubble.Legend.Format          = "<label> X:<xvalue> Y:<value> Size:<size>";
            m_Bubble.Legend.Mode            = SeriesLegendMode.DataPoints;
            m_Bubble.MinSize    = new NLength(10.0f, NRelativeUnit.ParentPercentage);
            m_Bubble.MaxSize    = new NLength(20.0f, NRelativeUnit.ParentPercentage);
            m_Bubble.UseXValues = true;

            m_Bubble.ShadowStyle.Type   = ShadowType.Solid;
            m_Bubble.ShadowStyle.Offset = new NPointL(3, 3);
            m_Bubble.ShadowStyle.Color  = Color.FromArgb(60, 0, 0, 0);
            m_Bubble.BorderStyle.Width  = new NLength(0, NGraphicsUnit.Pixel);
            m_Bubble.InflateMargins     = true;

            m_LightingFilter = new NLightingImageFilter();

            NFillStyle fillStyle = new NColorFillStyle(Color.Gold);

            fillStyle.ImageFiltersStyle.Filters.Add(m_LightingFilter);
            m_Bubble.AddDataPoint(new NBubbleDataPoint(10, 34, 10, "Company1", fillStyle));

            fillStyle = new NColorFillStyle(Color.DarkOrange);
            fillStyle.ImageFiltersStyle.Filters.Add(m_LightingFilter);
            m_Bubble.AddDataPoint(new NBubbleDataPoint(15, 12, 20, "Company2", fillStyle));

            fillStyle = new NColorFillStyle(Color.Crimson);
            fillStyle.ImageFiltersStyle.Filters.Add(m_LightingFilter);
            m_Bubble.AddDataPoint(new NBubbleDataPoint(12, 24, 25, "Company3", fillStyle));

            fillStyle = new NColorFillStyle(Color.DarkOrchid);
            fillStyle.ImageFiltersStyle.Filters.Add(m_LightingFilter);
            m_Bubble.AddDataPoint(new NBubbleDataPoint(8, 56, 15, "Company4", fillStyle));

            BubbleShapeCombo.FillFromEnum(typeof(PointShape));
            BubbleShapeCombo.SelectedIndex = 7;

            InflateMargins.Checked = true;

            LightSourceTypeComboBox.FillFromEnum(typeof(LightSourceType));
            BlurTypeComboBox.FillFromEnum(typeof(BlurType));

            BevelDepthNumericUpDown.Value         = (decimal)m_LightingFilter.BevelDepth.Value;
            BlurTypeComboBox.SelectedIndex        = (int)m_LightingFilter.BlurType;
            SurfaceScaleNumericUpDown.Value       = (decimal)m_LightingFilter.SurfaceScale;
            ShininessNumericUpDown.Value          = (decimal)m_LightingFilter.Shininess;
            LightSourceTypeComboBox.SelectedIndex = (int)m_LightingFilter.LightSourceType;

            NVector3DF vector = m_LightingFilter.Position;

            PositionXnumericUpDown.Value = (decimal)vector.X;
            PositionYnumericUpDown.Value = (decimal)vector.Y;
            PositionZnumericUpDown.Value = (decimal)vector.Z;

            m_Updating = false;
        }
Exemple #9
0
            public override void OnAfterPaint(NPanel panel, NPanelPaintEventArgs eventArgs)
            {
                Graphics graphics = eventArgs.Graphics.DeviceGraphics;

                double     dPreviousValue, dCurrentValue;
                int        nBarCount = 10;
                NChart     chart     = panel as NChart;
                NBarSeries bar       = (NBarSeries)chart.Series[0];

                NAxis horzAxis = chart.Axis(StandardAxis.PrimaryX);
                NAxis vertAxis = chart.Axis(StandardAxis.PrimaryY);

                NVector3DF vecClientPoint = new NVector3DF();
                NVector3DF vecModelPoint  = new NVector3DF();

                int nBarSize = (int)(chart.ContentArea.Width * (int)bar.WidthPercent) / (nBarCount * 200);

                // init pens and brushes
                Pen        penRectBorder = new Pen(Color.DarkBlue);
                SolidBrush brushRectFill = new SolidBrush(Color.FromArgb(125, Color.LightBlue));

                Pen        penPositiveArrowBorder = new Pen(Color.DarkGreen);
                SolidBrush brushPositiveArrowFill = new SolidBrush(Color.Green);

                Pen        penEqualSignBorder = new Pen(Color.DarkGray);
                SolidBrush brushEqualSignFill = new SolidBrush(Color.Gray);

                Pen        penNegativeArrowBorder = new Pen(Color.DarkRed);
                SolidBrush brushNegativeArrowFill = new SolidBrush(Color.Red);

                for (int i = 1; i < bar.Values.Count; i++)
                {
                    dPreviousValue = (double)bar.Values[i - 1];
                    dCurrentValue  = (double)bar.Values[i];

                    vecModelPoint.X = horzAxis.TransformScaleToModel(false, i);
                    vecModelPoint.Y = vertAxis.TransformScaleToModel(false, (float)(double)bar.Values[i]);
                    vecModelPoint.Z = 0;

                    if (!chart.TransformModelToClient(vecModelPoint, ref vecClientPoint))
                    {
                        continue;
                    }

                    RectangleF rcArrowRect = new RectangleF(vecClientPoint.X - nBarSize, vecClientPoint.Y - nBarSize, 2 * nBarSize, 2 * nBarSize);

                    if (rcArrowRect.Width <= 0 || rcArrowRect.Height <= 0)
                    {
                        continue;
                    }

                    if (!DisplayMark(dCurrentValue, dPreviousValue))
                    {
                        continue;
                    }

                    // draw arrow background
                    GraphicsPath path = GetRoundRectanglePath(rcArrowRect);

                    graphics.FillPath(brushRectFill, path);
                    graphics.DrawPath(penRectBorder, path);

                    path.Dispose();

                    rcArrowRect.Inflate(-5, -5);

                    // draw the arrow itself
                    if (rcArrowRect.Width <= 0 || rcArrowRect.Height <= 0)
                    {
                        continue;
                    }

                    if (dCurrentValue < dPreviousValue)
                    {
                        // draw negative arrow
                        path = GetArrowPath(rcArrowRect, false);

                        graphics.FillPath(brushNegativeArrowFill, path);
                        graphics.DrawPath(penNegativeArrowBorder, path);

                        path.Dispose();
                    }
                    else if (dCurrentValue > dPreviousValue)
                    {
                        // draw positive arrow
                        path = GetArrowPath(rcArrowRect, true);

                        graphics.FillPath(brushPositiveArrowFill, path);
                        graphics.DrawPath(penPositiveArrowBorder, path);

                        path.Dispose();
                    }
                    else
                    {
                        // draw equal sign
                        RectangleF rect = new RectangleF(rcArrowRect.Left, rcArrowRect.Top, rcArrowRect.Width, rcArrowRect.Height / 3.0f);

                        graphics.FillRectangle(brushEqualSignFill, rect.Left, rect.Top, rect.Width, rect.Height);
                        graphics.DrawRectangle(penEqualSignBorder, rect.Left, rect.Top, rect.Width, rect.Height);

                        rect = new RectangleF(rcArrowRect.Left, rcArrowRect.Bottom - rect.Height, rcArrowRect.Width, rect.Height);

                        graphics.FillRectangle(brushEqualSignFill, rect.Left, rect.Top, rect.Width, rect.Height);
                        graphics.DrawRectangle(penEqualSignBorder, rect.Left, rect.Top, rect.Width, rect.Height);
                    }
                }

                // dispose pens and brushes
                penPositiveArrowBorder.Dispose();
                brushPositiveArrowFill.Dispose();

                penNegativeArrowBorder.Dispose();
                brushNegativeArrowFill.Dispose();

                brushRectFill.Dispose();
                penRectBorder.Dispose();
            }