Пример #1
0
        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();
        }
Пример #2
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 NChartControl CreateModifiedChartControl()
        {
            // create a duplicate of this chart control
            MemoryStream memoryStream = new MemoryStream();

            nChartControl1.Serializer.SaveControlStateToStream(memoryStream, PersistencyFormat.Binary, null);

            memoryStream.Seek(0, SeekOrigin.Begin);
            NChartControl chartControl = new NChartControl();

            chartControl.Serializer.LoadControlStateFromStream(memoryStream, PersistencyFormat.Binary, null);

            INObjectConverter fillStyleConverter = null;

            // apply a chart attribute converter
            if (ConvertToGrayScaleRadioButton.Checked)
            {
                fillStyleConverter = new NFillStyleToGrayScaleConverter();
            }
            else
            {
                fillStyleConverter = new NFillStyleColorToHatchConverter();
            }

            INObjectConverter[] converters = new INObjectConverter[] { fillStyleConverter,
                                                                       new NStrokeStyleToGrayScaleConverter(),
                                                                       new NShadowStyleToGrayScaleConverter(),
                                                                       new NLightModelToGrayScaleConverter() };


            NNodeTreeAttributeConverter grayScaleConverter = new NNodeTreeAttributeConverter();

            grayScaleConverter.Converters = converters;
            grayScaleConverter.Convert(chartControl.Document);

            if (PrintBackgroundFrameCheckBox.Checked == false)
            {
                NStandardFrameStyle standardFrameStyle = new NStandardFrameStyle();
                standardFrameStyle.InnerBorderWidth = new NLength(0);

                chartControl.BackgroundStyle.FrameStyle = standardFrameStyle;
            }

            chartControl.Refresh();

            return(chartControl);
        }
Пример #4
0
        /// <summary>
        /// Gets the first pie series in the current chart control
        /// </summary>
        /// <returns></returns>
        protected NPieSeries GetPieSeries()
        {
            NChartControl chartControl = base.ChartControl;

            if (chartControl == null)
            {
                return(null);
            }

            // first chart is not a pie or chart does not contain series
            if (chartControl.Charts.Count == 0 || !(chartControl.Charts[0] is NPieChart) || (chartControl.Charts[0].Series.Count == 0))
            {
                return(null);
            }

            return((NPieSeries)(chartControl.Charts[0].Series[0]));
        }
Пример #5
0
        public NMainForm()
        {
            InitializeComponent();

            InitFromConfig(new NChartExamplesConfig());

            this.StartPosition = FormStartPosition.CenterScreen;
            this.WindowState   = FormWindowState.Maximized;

            this.chartControl = new Nevron.Chart.WinForm.NChartControl();

            this.chartCommandBarsManager = new NChartCommandBarsManager();
            this.chartCommandBarsManager.ChartControl       = chartControl;
            this.chartCommandBarsManager.ParentControl      = this.MainControlHost;
            this.chartCommandBarsManager.AllowCustomize     = false;
            this.chartCommandBarsManager.ContextMenuEnabled = true;
            SetupToolbarCommands();

            this.MainControlHost.Controls.Add(chartControl);

            this.chartControl.Dock = DockStyle.Fill;
            this.chartControl.BringToFront();
        }
        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);
        }
Пример #7
0
        private void BuildNewNChart(byte[] m_map_content)
        {
            try
            {
                DataTable dt = (DataTable)gridControl1.DataSource;

                nChartControl1 = new NChartControl();
                nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.HighSpeed;
                nChartControl1.Controller.Tools.Add(new NSelectorTool());
                nChartControl1.Controller.Tools.Add(new NTrackballTool());
                nChartControl1.MouseWheel += new MouseEventHandler(nChartControl1_MouseWheel);
                nChartControl1.MouseDown  += new MouseEventHandler(nChartControl1_MouseDown);
                nChartControl1.MouseUp    += new MouseEventHandler(nChartControl1_MouseUp);

                nChartControl1.Dock = DockStyle.Fill;
                xtraTabPage2.Controls.Add(nChartControl1);
                //nChartControl1.Charts.Clear();

                NChart chart = nChartControl1.Charts[0];
                nChartControl1.Legends.Clear();
                chart.Enable3D = true;
                chart.Width    = 60.0f;
                chart.Depth    = 60.0f;
                chart.Height   = 35.0f;
                chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted);
                chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft);

                NStandardScaleConfigurator scaleConfiguratorX = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;
                scaleConfiguratorX.MaxTickCount  = dt.Rows.Count;
                scaleConfiguratorX.MajorTickMode = MajorTickMode.AutoMaxCount;
                //scaleConfiguratorX.AutoLabels = true;
                NScaleTitleStyle titleStyleX = (NScaleTitleStyle)scaleConfiguratorX.Title;
                titleStyleX.Text = Y_axis_name;
                //<GS-08032010> as waarden nog omzetten indien noodzakelijk (MAP etc)
                scaleConfiguratorX.AutoLabels = false;
                scaleConfiguratorX.Labels.Clear();

                for (int t = y_axisvalues.Length - 1; t >= 0; t--)
                {
                    string yvalue = y_axisvalues.GetValue(t).ToString();
                    //if (Y_axis_name == "MAP" || Y_axis_name == "Pressure error (bar)")
                    {
                        try
                        {
                            float v = (float)Convert.ToDouble(yvalue);
                            yvalue = v.ToString("F2");
                        }
                        catch (Exception cE)
                        {
                            logger.Debug(cE.Message);
                        }
                    }
                    scaleConfiguratorX.Labels.Add(yvalue);
                }
                NStandardScaleConfigurator scaleConfiguratorY = (NStandardScaleConfigurator)chart.Axis(StandardAxis.Depth).ScaleConfigurator;
                scaleConfiguratorY.MajorTickMode = MajorTickMode.AutoMaxCount;
                scaleConfiguratorY.MaxTickCount  = dt.Columns.Count;
                //scaleConfiguratorY.AutoLabels = true;
                NScaleTitleStyle titleStyleY = (NScaleTitleStyle)scaleConfiguratorY.Title;
                titleStyleY.Text = X_axis_name;
                scaleConfiguratorY.AutoLabels = false;
                scaleConfiguratorY.Labels.Clear();
                for (int t = 0; t < x_axisvalues.Length; t++)
                {
                    string xvalue = x_axisvalues.GetValue(t).ToString();
                    //if (X_axis_name == "MAP" || X_axis_name == "Pressure error (bar)")
                    {
                        try
                        {
                            float v = (float)Convert.ToDouble(xvalue);
                            xvalue = v.ToString("F2");
                        }
                        catch (Exception cE)
                        {
                            logger.Debug(cE.Message);
                        }
                    }
                    scaleConfiguratorY.Labels.Add(xvalue);
                }

                NStandardScaleConfigurator scaleConfiguratorZ = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
                scaleConfiguratorZ.MajorTickMode = MajorTickMode.AutoMaxCount;
                NScaleTitleStyle titleStyleZ = (NScaleTitleStyle)scaleConfiguratorZ.Title;
                titleStyleZ.Text = Z_axis_name;
                scaleConfiguratorZ.AutoLabels           = true;
                chart.Wall(ChartWallType.Back).Visible  = false;
                chart.Wall(ChartWallType.Left).Visible  = false;
                chart.Wall(ChartWallType.Right).Visible = false;
                chart.Wall(ChartWallType.Floor).Visible = false;
                NMeshSurfaceSeries surface = null;
                chart.Series.Clear();
                if (chart.Series.Count == 0)
                {
                    surface = (NMeshSurfaceSeries)chart.Series.Add(SeriesType.MeshSurface);
                }
                else
                {
                    surface = (NMeshSurfaceSeries)chart.Series[0];
                }
                surface.Name          = "Surface";
                surface.PositionValue = 10.0;

                surface.Palette.Clear();
                surface.Data.SetGridSize(dt.Columns.Count, dt.Rows.Count);
                surface.ValueFormatter.FormatSpecifier = "0.00";
                surface.FillMode       = SurfaceFillMode.Zone; // <GS-08032010>
                surface.SmoothPalette  = true;
                surface.FrameColorMode = SurfaceFrameColorMode.Uniform;
                surface.FillStyle.SetTransparencyPercent(25);
                surface.FrameMode = SurfaceFrameMode.MeshContour;

                double diff = m_realMaxValue - m_realMinValue;

                surface.Palette.Add(m_realMinValue, Color.Green);
                surface.Palette.Add(m_realMinValue + 0.25 * diff, Color.Yellow);
                surface.Palette.Add(m_realMinValue + 0.50 * diff, Color.Orange);
                surface.Palette.Add(m_realMinValue + 0.75 * diff, Color.OrangeRed);
                surface.Palette.Add(m_realMinValue + diff, Color.Red);

                surface.PaletteSteps     = 4;
                surface.AutomaticPalette = false;

                FillData(surface, dt);
                // hier
                nChartControl1.Refresh();
            }
            catch (Exception E)
            {
                logger.Debug("Failed to refresh mesh chart: " + E.Message);
            }
        }
        private void PrintPreviewButton_Click(object sender, System.EventArgs e)
        {
            NChartControl chartControl = CreateModifiedChartControl();

            chartControl.PrintManager.ShowPrintPreview();
        }
        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);
        }
Пример #10
0
        private void InitMap(NChartControl nChartControl)
        {
            // configure the chart
            NCartesianChart chart = (NCartesianChart)nChartControl.Charts[0];

            chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalTop);
            chart.BoundsMode       = BoundsMode.Stretch;
            chart.Enable3D         = true;
            chart.Fit3DAxisContent = false;

            // No Legend & No Update
            nChartControl.Legends.Clear();
            nChartControl.ServiceManager.LegendUpdateService.UpdateAutoLegends();
            nChartControl.ServiceManager.LegendUpdateService.Stop();

            chart.Width  = _gridSizeX;
            chart.Height = 20;
            chart.Depth  = _gridSizeY;

            // Wall Setup
            NChartWall backWall = chart.Wall(ChartWallType.Back);

            backWall.Visible = false;

            NChartWall leftWall = chart.Wall(ChartWallType.Left);

            leftWall.Visible = false;

            // setup axes
            //NOrdinalScaleConfigurator ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;
            //ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);
            //ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            //ordinalScale.DisplayDataPointsBetweenTicks = false;

            //ordinalScale = (NOrdinalScaleConfigurator)chart.Axis(StandardAxis.Depth).ScaleConfigurator;
            //ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);
            //ordinalScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true);
            //ordinalScale.DisplayDataPointsBetweenTicks = false;

            NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator();

            chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale;
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true);
            linearScale.RoundToTickMax = false;
            linearScale.RoundToTickMin = false;

            linearScale = new NLinearScaleConfigurator();
            chart.Axis(StandardAxis.Depth).ScaleConfigurator = linearScale;
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true);
            linearScale.RoundToTickMax = false;
            linearScale.RoundToTickMin = false;

            linearScale = new NLinearScaleConfigurator();
            chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale;
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true);
            linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true);
            linearScale.RoundToTickMax = false;
            linearScale.RoundToTickMin = false;

            chart.Axis(StandardAxis.SecondaryY).Anchor = new NDockAxisAnchor(AxisDockZone.FrontLeft, false, 50.0f, 50.0f);

            // Axis Visable Setup.
            //chart.Axis(StandardAxis.PrimaryX).Visible = false;
            chart.Axis(StandardAxis.PrimaryY).Visible = false;
            //chart.Axis(StandardAxis.Depth).Visible = false;

            for (int i = 0; i < _gridSizeY; i++)
            {
                // add the first line
                NBarSeries bar = new NBarSeries();
                chart.Series.Add(bar);

                bar.WidthPercent = 100.0f;
                bar.DepthPercent = 100.0f;

                bar.EnableDepthSort        = false;
                bar.DataLabelStyle.Visible = false;

                //bar.Values.ValueFormatter = new NNumericValueFormatter("0.0");
                bar.Values.EmptyDataPoints.ValueMode = EmptyDataPointsValueMode.Skip;

                //bar.Values.Clear();
                bar.FillStyles.StorageType = IndexedStorageType.Array;
                bar.DataPointOriginIndex   = 0;

                // turn off bar border to improve performance
                bar.BorderStyle.Width = new NLength(0.5f);
            }
            nChartControl.Settings.RenderSurface = RenderSurface.Window;

            nChartControl.Controller.Tools.Add(new NPanelSelectorTool());
            nChartControl.Controller.Tools.Add(new NTrackballTool());
        }
Пример #11
0
        public void InitNChart(ref NChartControl ncc, out NCartesianChart chart)
        {
            // 2D line chart
            ncc.Settings.RenderDevice = RenderDevice.GDI;

            // Add tools to chart controller
            ncc.Controller.Tools.Add(new NSelectorTool());
            ncc.Controller.Tools.Add(new NDataZoomTool());
            //ncc.Controller.Tools.Add(new NDataPanTool());
            ncc.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(OnChartMouseDoubleClick);
            ncc.MouseMove += new System.Windows.Forms.MouseEventHandler(OnChartMouseMove);

            chart = (NCartesianChart)ncc.Charts[0];

            // Set range selections property
            NRangeSelection rangeSelection = new NRangeSelection();

            // Reset Axis when zoom out
            rangeSelection.ZoomOutResetsAxis = true;
            chart.RangeSelections.Add(rangeSelection);

            // Set chart axis property
            chart.Axis(StandardAxis.Depth).Visible = false;
            SetMapProperty();
        }
Пример #12
0
        private void BuildNewNChart(byte[] m_map_content)
        {
            try
            {
                DataTable dt = (DataTable)gridControl1.DataSource;

                nChartControl1 = new NChartControl();
                nChartControl1.Settings.ShapeRenderingMode = ShapeRenderingMode.HighSpeed;
                nChartControl1.Controller.Tools.Add(new NSelectorTool());
                nChartControl1.Controller.Tools.Add(new NTrackballTool());
                nChartControl1.MouseWheel += new MouseEventHandler(nChartControl1_MouseWheel);
                nChartControl1.MouseDown += new MouseEventHandler(nChartControl1_MouseDown);
                nChartControl1.MouseUp += new MouseEventHandler(nChartControl1_MouseUp);

                nChartControl1.Dock = DockStyle.Fill;
                xtraTabPage2.Controls.Add(nChartControl1);
                //nChartControl1.Charts.Clear();

                NChart chart = nChartControl1.Charts[0];
                nChartControl1.Legends.Clear();
                chart.Enable3D = true;
                chart.Width = 60.0f;
                chart.Depth = 60.0f;
                chart.Height = 35.0f;
                chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted);
                chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.ShinyTopLeft);

                NStandardScaleConfigurator scaleConfiguratorX = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator;
                scaleConfiguratorX.MaxTickCount = dt.Rows.Count;
                scaleConfiguratorX.MajorTickMode = MajorTickMode.AutoMaxCount;
                //scaleConfiguratorX.AutoLabels = true;
                NScaleTitleStyle titleStyleX = (NScaleTitleStyle)scaleConfiguratorX.Title;
                titleStyleX.Text = Y_axis_name;
                //<GS-08032010> as waarden nog omzetten indien noodzakelijk (MAP etc)
                scaleConfiguratorX.AutoLabels = false;
                scaleConfiguratorX.Labels.Clear();

                for (int t = y_axisvalues.Length - 1; t >= 0; t--)
                {
                    string yvalue = y_axisvalues.GetValue(t).ToString();
                    //if (Y_axis_name == "MAP" || Y_axis_name == "Pressure error (bar)")
                    {
                        try
                        {
                            float v = (float)Convert.ToDouble(yvalue);
                            yvalue = v.ToString("F2");
                        }
                        catch (Exception cE)
                        {
                            Console.WriteLine(cE.Message);
                        }
                    }
                    scaleConfiguratorX.Labels.Add(yvalue);

                }
                NStandardScaleConfigurator scaleConfiguratorY = (NStandardScaleConfigurator)chart.Axis(StandardAxis.Depth).ScaleConfigurator;
                scaleConfiguratorY.MajorTickMode = MajorTickMode.AutoMaxCount;
                scaleConfiguratorY.MaxTickCount = dt.Columns.Count;
                //scaleConfiguratorY.AutoLabels = true;
                NScaleTitleStyle titleStyleY = (NScaleTitleStyle)scaleConfiguratorY.Title;
                titleStyleY.Text = X_axis_name;
                scaleConfiguratorY.AutoLabels = false;
                scaleConfiguratorY.Labels.Clear();
                for (int t = 0; t < x_axisvalues.Length; t++)
                {
                    string xvalue = x_axisvalues.GetValue(t).ToString();
                    //if (X_axis_name == "MAP" || X_axis_name == "Pressure error (bar)")
                    {
                        try
                        {
                            float v = (float)Convert.ToDouble(xvalue);
                            xvalue = v.ToString("F2");
                        }
                        catch (Exception cE)
                        {
                            Console.WriteLine(cE.Message);
                        }
                    }
                    scaleConfiguratorY.Labels.Add(xvalue);
                }

                NStandardScaleConfigurator scaleConfiguratorZ = (NStandardScaleConfigurator)chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator;
                scaleConfiguratorZ.MajorTickMode = MajorTickMode.AutoMaxCount;
                NScaleTitleStyle titleStyleZ = (NScaleTitleStyle)scaleConfiguratorZ.Title;
                titleStyleZ.Text = Z_axis_name;
                scaleConfiguratorZ.AutoLabels = true;
                chart.Wall(ChartWallType.Back).Visible = false;
                chart.Wall(ChartWallType.Left).Visible = false;
                chart.Wall(ChartWallType.Right).Visible = false;
                chart.Wall(ChartWallType.Floor).Visible = false;
                NMeshSurfaceSeries surface = null;
                chart.Series.Clear();
                if (chart.Series.Count == 0)
                {
                    surface = (NMeshSurfaceSeries)chart.Series.Add(SeriesType.MeshSurface);
                }
                else
                {
                    surface = (NMeshSurfaceSeries)chart.Series[0];
                }
                surface.Name = "Surface";
                surface.PositionValue = 10.0;

                surface.Palette.Clear();
                surface.Data.SetGridSize(dt.Columns.Count, dt.Rows.Count);
                surface.ValueFormatter.FormatSpecifier = "0.00";
                surface.FillMode = SurfaceFillMode.Zone; // <GS-08032010>
                surface.SmoothPalette = true;
                surface.FrameColorMode = SurfaceFrameColorMode.Uniform;
                surface.FillStyle.SetTransparencyPercent(25);
                surface.FrameMode = SurfaceFrameMode.MeshContour;

                double diff = m_realMaxValue - m_realMinValue;

                surface.Palette.Add(m_realMinValue, Color.Green);
                surface.Palette.Add(m_realMinValue + 0.25 * diff, Color.Yellow);
                surface.Palette.Add(m_realMinValue + 0.50 * diff, Color.Orange);
                surface.Palette.Add(m_realMinValue + 0.75 * diff, Color.OrangeRed);
                surface.Palette.Add(m_realMinValue + diff, Color.Red);

                surface.PaletteSteps = 4;
                surface.AutomaticPalette = false;

                FillData(surface, dt);
                // hier
                nChartControl1.Refresh();
            }
            catch (Exception E)
            {
                Console.WriteLine("Failed to refresh mesh chart: " + E.Message);
            }
        }
Пример #13
0
        public static NChartControl GenerateChart(string func)
        {
            NZoomTool zt = new NZoomTool();

            zt.BeginDragMouseCommand = new NMouseCommand(MouseAction.Wheel, (MouseButton)System.Windows.Forms.MouseButtons.Middle, 0);
            zt.ZoomStep = 16;

            NChartControl nChartControl1 = new NChartControl();

            nChartControl1.Controller.Tools.Add(new NSelectorTool());
            nChartControl1.Controller.Tools.Add(new NTrackballTool());
            nChartControl1.Controller.Tools.Add(zt);
            nChartControl1.Legends[0].Mode = LegendMode.Disabled;

            NTriangulatedSurfaceSeries triangulatedSurface = new NTriangulatedSurfaceSeries();

            triangulatedSurface.UsePreciseGeometry       = true;
            triangulatedSurface.AutomaticPalette         = true;
            triangulatedSurface.SyncPaletteWithAxisScale = false;
            triangulatedSurface.PaletteSteps             = 6;
            triangulatedSurface.FrameMode = SurfaceFrameMode.Mesh;

            NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

            chart.Enable3D             = true;
            chart.Width                = width;
            chart.Depth                = depth;
            chart.Height               = height;
            chart.BoundsMode           = BoundsMode.Fit;
            chart.Projection.Type      = ProjectionType.Perspective;
            chart.Projection.Elevation = 30;
            chart.Projection.Rotation  = -60;
            chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights);
            chart.Series.Add(triangulatedSurface);

            string[] f2 = func.Split(Char.Parse("="));
            if (f2.Length == 2)
            {
                if (f2[0] == "y" || f2[0] == "f(x)") // f-cja w postaci y=costam
                {
                    float x, z;
                    try
                    {
                        for (x = startx; x < width; x++)     //x
                        {
                            for (z = startz; z < depth; z++) //z
                            {
                                NCalc.Expression ex = new NCalc.Expression(f2[1]);
                                ex.Parameters["x"] = x;
                                ex.Parameters["z"] = z;

                                ex.EvaluateParameter += delegate(string name, ParameterArgs args)
                                {
                                    if (name == "x")
                                    {
                                        args.Result = x;
                                    }
                                    else if (name == "z")
                                    {
                                        args.Result = z;
                                    }
                                };
                                var y = ex.Evaluate();

                                triangulatedSurface.XValues.Add(x);
                                triangulatedSurface.ZValues.Add(z);
                                triangulatedSurface.Values.Add(y);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Sprawdź, czy poprawnie wpisałeś równanie!", "Nie pykło");
                        return(null);
                    }
                }
                else
                {
                    MessageBox.Show("Niepoprawny zapis funkcji!", "Nie pykło");
                }
            }
            else
            {
                MessageBox.Show("Niepoprawny zapis funkcji!", "Nie pykło");
            }

            return(nChartControl1);
        }