private void ChartControl_OnMouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { NHitTestResult result = nChartControl1.HitTest(e.X, e.Y); NWatermark watermark = result.Object as NWatermark; if (watermark == null) { return; } CarData car = watermark.Tag as CarData; if (car == null) { return; } m_ReviewLabel.Text = "Concept car from " + car.AuthorName; NSeries series = (NSeries)nChartControl1.Charts[0].Series[0]; series.Values.Clear(); series.Values.AddRange(car.Values); nChartControl1.Refresh(); }
private void ChartControl_OnMouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (nChartControl1.Controller.ActiveTool != null) { return; } NHitTestResult result = nChartControl1.HitTest(e.X, e.Y); NWatermark watermark = result.Object as NWatermark; if (watermark == null || watermark.Tag == null) { if (SetWatermarkTransparency((byte)(TransparencyScrollBar.Value * 255 / 100))) { nChartControl1.Refresh(); } } else { NImageFillStyle imageFillStyle = (NImageFillStyle)watermark.FillStyle; if (imageFillStyle.Alpha != 255) { SetWatermarkTransparency((byte)(TransparencyScrollBar.Value * 255 / 100)); imageFillStyle.Alpha = 255; nChartControl1.Refresh(); } } }
private bool SetWatermarkTransparency(byte alpha) { bool alphaChanged = false; for (int i = 0; i < nChartControl1.Watermarks.Count; i++) { NWatermark watermark = (NWatermark)nChartControl1.Watermarks[i]; if (watermark.Tag != null) { NImageFillStyle imageFillStyle = watermark.FillStyle as NImageFillStyle; if (imageFillStyle != null) { if (imageFillStyle.Alpha != alpha) { imageFillStyle.Alpha = alpha; alphaChanged = true; } } } } return(alphaChanged); }
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 AddWatermark(NDockPanel containerPanel, String sFileName) { NWatermark watermark = new NWatermark(); watermark.StandardFrameStyle.InnerBorderWidth = new NLength(0, NGraphicsUnit.Pixel); watermark.StandardFrameStyle.OuterBorderWidth = new NLength(0, NGraphicsUnit.Pixel); watermark.FillStyle = new NImageFillStyle(this.MapPathSecure(this.TemplateSourceDirectory + "\\" + sFileName)); watermark.Location = new NPointL(new NLength(50, NRelativeUnit.ParentPercentage), new NLength(55, NRelativeUnit.ParentPercentage)); watermark.ContentAlignment = ContentAlignment.MiddleCenter; watermark.UseAutomaticSize = false; watermark.Size = new NSizeL(new NLength(100, NGraphicsUnit.Pixel), new NLength(100, NGraphicsUnit.Pixel)); containerPanel.ChildPanels.Add(watermark); }
private NPanel ConfigureLabel(string text, float orientation, NLength fontSize, ContentAlignment contentAlignment, PanelDockMode dockMode) { NLabel label = new NLabel(text); label.TextStyle.BackplaneStyle.Visible = false; label.TextStyle.Orientation = orientation; label.TextStyle.FontStyle.EmSize = fontSize; label.ContentAlignment = contentAlignment; label.DockMode = PanelDockMode.Fill; label.BoundsMode = BoundsMode.Fit; label.TextStyle.StringFormatStyle.VertAlign = VertAlign.Center; NWatermark labelHostPanel = new NWatermark(); labelHostPanel.DockMode = dockMode; labelHostPanel.UseAutomaticSize = false; labelHostPanel.Size = new NSizeL(new NLength(10, NRelativeUnit.ParentPercentage), new NLength(10, NRelativeUnit.ParentPercentage)); labelHostPanel.ChildPanels.Add(label); return(labelHostPanel); }
private void CreateConceptCarPanels(NDockPanel parentPanel, CarData car) { Bitmap conceptImage = NResourceHelper.BitmapFromResource(this.GetType(), car.ImageResourceName, "Nevron.Examples.Chart.WinForm.Resources"); NLabel label = new NLabel(car.AuthorName); label.DockMode = PanelDockMode.Top; label.BoundsMode = BoundsMode.Fit; label.UseAutomaticSize = true; label.Padding = new NMarginsL(10, 0, 0, 0); label.TextStyle.FontStyle = new NFontStyle("Times New Roman", 20, FontStyle.Italic); label.TextStyle.FillStyle = new NGradientFillStyle(Nevron.GraphicsCore.GradientStyle.Horizontal, GradientVariant.Variant1, Color.DarkKhaki, Color.White); parentPanel.ChildPanels.Add(label); NWatermark watermark = new NWatermark(); watermark.FillStyle = new NImageFillStyle(conceptImage); watermark.DockMode = PanelDockMode.Top; watermark.UseAutomaticSize = true; watermark.Padding = new NMarginsL(10, 0, 0, 0); watermark.Tag = car; parentPanel.ChildPanels.Add(watermark); }
private NPanel ConfigurePieChart() { // configure the chart bounds, contentalign, docking, light model and projection. NChart chart = new NPieChart(); chart.Enable3D = true; chart.BoundsMode = BoundsMode.Fit; chart.ContentAlignment = ContentAlignment.MiddleCenter; chart.DockMode = PanelDockMode.Fill; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); chart.Projection.SetPredefinedProjection(PredefinedProjection.OrthogonalElevated); // create the pie series NPieSeries pie = new NPieSeries(); chart.Series.Add(pie); pie.PieStyle = PieStyle.SmoothEdgePie; pie.DataLabelStyle.Format = "<percent>"; pie.LabelMode = PieLabelMode.Center; pie.DataLabelStyle.TextStyle.BackplaneStyle.Visible = false; pie.DataLabelStyle.TextStyle.FontStyle.Style |= FontStyle.Bold; pie.DataLabelStyle.TextStyle.FontStyle.EmSize = new NLength(12, NGraphicsUnit.Point); for (int i = 0; i < colors.Length; i++) { pie.AddDataPoint(new NDataPoint(Random.Next(10) + 5, new NColorFillStyle(colors[i]))); } // create a watermark and nest the chart inside NWatermark chartHostPanel = new NWatermark(); chartHostPanel.DockMode = PanelDockMode.Fill; chartHostPanel.ChildPanels.Add(chart); return(chartHostPanel); }
protected void Page_Load(object sender, EventArgs e) { nChartControl1.BackgroundStyle.FrameStyle.Visible = false; nChartControl1.Settings.JitterMode = JitterMode.Enabled; nChartControl1.Settings.JitteringSteps = 4; nChartControl1.Panels.Clear(); NWatermark watermark = new NWatermark(); nChartControl1.Panels.Add(watermark); NLabel title = new NLabel("Ship Sales by Company"); nChartControl1.Panels.Add(title); NLegend legend = new NLegend(); nChartControl1.Panels.Add(legend); NPieChart chart = new NPieChart(); nChartControl1.Panels.Add(chart); // setup the watermark watermark.FillStyle = new NImageFillStyle(this.MapPathSecure("~\\Images\\ship.png")); watermark.StandardFrameStyle.InnerBorderWidth = new NLength(0); watermark.Location = new NPointL(new NLength(5, NRelativeUnit.ParentPercentage), new NLength(5, NRelativeUnit.ParentPercentage)); watermark.ContentAlignment = ContentAlignment.BottomRight; // setup the chart title title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; title.ContentAlignment = ContentAlignment.BottomRight; title.Location = new NPointL( new NLength(2, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // setup the legend legend.ContentAlignment = ContentAlignment.BottomLeft; legend.Location = new NPointL( new NLength(98, NRelativeUnit.ParentPercentage), new NLength(2, NRelativeUnit.ParentPercentage)); // setup the chart chart.DisplayOnLegend = legend; chart.Enable3D = true; chart.LightModel.EnableLighting = true; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.NorthernLights); chart.BoundsMode = BoundsMode.Fit; chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated); chart.Location = new NPointL( new NLength(27, NRelativeUnit.ParentPercentage), new NLength(25, NRelativeUnit.ParentPercentage)); chart.Size = new NSizeL( new NLength(70, NRelativeUnit.ParentPercentage), new NLength(70, NRelativeUnit.ParentPercentage)); // add a pie series NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie); pie.LabelMode = PieLabelMode.Center; pie.DataLabelStyle.Format = "<value>"; pie.DataLabelStyle.TextStyle.BackplaneStyle.Shape = BackplaneShape.SmoothEdgeRectangle; pie.DataLabelStyle.TextStyle.BackplaneStyle.FillStyle = new NColorFillStyle(Color.FromArgb(200, 255, 255, 255)); pie.DataLabelStyle.TextStyle.FontStyle = new NFontStyle("Arial", 10, FontStyle.Bold); pie.DataLabelStyle.TextStyle.FillStyle = new NGradientFillStyle(GradientStyle.Horizontal, GradientVariant.Variant1, Color.LightSeaGreen, Color.Navy); pie.Legend.Mode = SeriesLegendMode.DataPoints; pie.Legend.Format = "<label> <percent>"; pie.PieStyle = PieStyle.SmoothEdgePie; // add data pie.Values.FillRandomRange(new Random(), 3, 10, 30); pie.Labels.Add("Mitsubishi"); pie.Labels.Add("Austal"); pie.Labels.Add("Norfolk naval"); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.CoolMultiColor); styleSheet.Apply(nChartControl1.Charts[0]); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CountryDropDownList.Items.Add("USA"); CountryDropDownList.Items.Add("CHINA"); CountryDropDownList.Items.Add("JAPAN"); CountryDropDownList.Items.Add("GERMANY"); CountryDropDownList.Items.Add("FRANCE"); CountryDropDownList.Items.Add("UK"); CountryDropDownList.SelectedIndex = 0; WebExamplesUtilities.FillComboWithPercents(XPositionDropDownList, 10); XPositionDropDownList.SelectedIndex = 0; WebExamplesUtilities.FillComboWithPercents(YPositionDropDownList, 10); YPositionDropDownList.SelectedIndex = 0; WebExamplesUtilities.FillComboWithPercents(FlagTransparencyDropDownList, 10); FlagTransparencyDropDownList.SelectedIndex = 5; ContentAlignmentDropDownList.Items.Add("BottomCenter"); ContentAlignmentDropDownList.Items.Add("BottomLeft"); ContentAlignmentDropDownList.Items.Add("BottomRight"); ContentAlignmentDropDownList.Items.Add("MiddleCenter"); ContentAlignmentDropDownList.Items.Add("MiddleLeft"); ContentAlignmentDropDownList.Items.Add("MiddleRight"); ContentAlignmentDropDownList.Items.Add("TopCenter"); ContentAlignmentDropDownList.Items.Add("TopLeft"); ContentAlignmentDropDownList.Items.Add("TopRight"); ContentAlignmentDropDownList.SelectedIndex = 2; } // enable the antialiasing of the whole scene nChartControl1.Settings.JitterMode = JitterMode.Enabled; nChartControl1.BackgroundStyle.FrameStyle.Visible = false; // by default the chart contains a cartesian chart which cannot display a pie series nChartControl1.Charts.Clear(); // create the legend NLegend legend = new NLegend(); legend.HorizontalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.VerticalBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.FillStyle.SetTransparencyPercent(50); legend.OuterBottomBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterLeftBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterRightBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.OuterTopBorderStyle.Width = new NLength(0, NGraphicsUnit.Pixel); legend.SetPredefinedLegendStyle(PredefinedLegendStyle.TopRight); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Car sales for " + CountryDropDownList.SelectedItem.Text); title.ContentAlignment = ContentAlignment.TopRight; title.Location = new NPointL(new NLength(2, NRelativeUnit.ParentPercentage), new NLength(98, NRelativeUnit.ParentPercentage)); title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic); title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur; // create the watermark NWatermark watermark = new NWatermark(); watermark.FillStyle = new NImageFillStyle(this.MapPathSecure(this.TemplateSourceDirectory + "\\" + CountryDropDownList.SelectedItem.Text + ".GIF")); watermark.Location = new NPointL(new NLength(XPositionDropDownList.SelectedIndex * 10, NRelativeUnit.ParentPercentage), new NLength(YPositionDropDownList.SelectedIndex * 10, NRelativeUnit.ParentPercentage)); watermark.UseAutomaticSize = false; watermark.Size = new NSizeL(150, 100); watermark.ContentAlignment = (ContentAlignment)ContentAlignment.Parse(typeof(ContentAlignment), ContentAlignmentDropDownList.SelectedItem.Text); watermark.FillStyle.SetTransparencyPercent(FlagTransparencyDropDownList.SelectedIndex * 10.0f); watermark.StandardFrameStyle.Visible = false; // create the chart NPieChart chart = new NPieChart(); chart.Enable3D = true; chart.Depth = 5; if (ShowFlagAboveChartBox.Checked) { nChartControl1.Panels.Add(chart); nChartControl1.Panels.Add(legend); nChartControl1.Panels.Add(watermark); } else { nChartControl1.Panels.Add(watermark); nChartControl1.Panels.Add(chart); nChartControl1.Panels.Add(legend); } chart.DisplayOnLegend = legend; chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.MetallicLustre); chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveElevated); NPieSeries pie = (NPieSeries)chart.Series.Add(SeriesType.Pie); pie.PieStyle = PieStyle.SmoothEdgePie; pie.LabelMode = PieLabelMode.Center; pie.Legend.Mode = SeriesLegendMode.DataPoints; pie.DataLabelStyle.Visible = false; pie.AddDataPoint(new NDataPoint(0, "Toyota")); pie.AddDataPoint(new NDataPoint(0, "Honda")); pie.AddDataPoint(new NDataPoint(0, "Volkswagen")); pie.AddDataPoint(new NDataPoint(0, "Chrysler")); pie.AddDataPoint(new NDataPoint(0, "Ford")); pie.Values.FillRandom(Random, 5); // apply style sheet NStyleSheet styleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor); styleSheet.Apply(pie); }
public override void Initialize() { base.Initialize(); nChartControl1.Controller.Tools.Add(new NPanelSelectorTool()); nChartControl1.Controller.Tools.Add(new NTrackballTool()); // set a chart title NLabel title = nChartControl1.Labels.AddHeader("Converting from scale to viewport coordinates"); 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)); // create the watermark that we're about to position in the AfterPaint event of the chart NWatermark watermark = new NWatermark(); Bitmap bitmap = GetWatermarkBitmap(); watermark.FillStyle = new NImageFillStyle(bitmap); watermark.StandardFrameStyle.InnerBorderWidth = new NLength(0, NGraphicsUnit.Pixel); watermark.ContentAlignment = ContentAlignment.MiddleCenter; nChartControl1.Panels.Add(watermark); // configure a free xyz point chart m_Chart = nChartControl1.Charts[0]; m_Chart.Enable3D = true; m_Chart.BoundsMode = BoundsMode.Fit; m_Chart.Location = new NPointL(new NLength(8, NRelativeUnit.ParentPercentage), new NLength(8, NRelativeUnit.ParentPercentage)); m_Chart.Size = new NSizeL(new NLength(84, NRelativeUnit.ParentPercentage), new NLength(84, NRelativeUnit.ParentPercentage)); m_Chart.Depth = 55.0f; m_Chart.Width = 55.0f; m_Chart.Height = 55.0f; m_Chart.Projection.SetPredefinedProjection(PredefinedProjection.PerspectiveTilted); m_Chart.LightModel.SetPredefinedLightModel(PredefinedLightModel.GlitterLeft); NLinearScaleConfigurator linearScale = new NLinearScaleConfigurator(); m_Chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale = new NLinearScaleConfigurator(); m_Chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Back, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; linearScale = new NLinearScaleConfigurator(); m_Chart.Axis(StandardAxis.Depth).ScaleConfigurator = linearScale; linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Left, true); linearScale.MajorGridStyle.SetShowAtWall(ChartWallType.Floor, true); linearScale.MajorGridStyle.LineStyle.Pattern = LinePattern.Dot; nChartControl1.Controller.Selection.Add(m_Chart); m_Point = (NPointSeries)m_Chart.Series.Add(SeriesType.Point); m_Point.Name = "Point Series"; m_Point.DataLabelStyle.Visible = false; m_Point.Legend.Mode = SeriesLegendMode.DataPoints; m_Point.Legend.Format = "<label>"; m_Point.PointShape = PointShape.Sphere; m_Point.FillStyle = new NColorFillStyle(Color.Red); m_Point.UseXValues = true; m_Point.UseZValues = true; // add xyz values m_Point.AddDataPoint(new NDataPoint(10, 15, 34, "Item1")); m_Point.AddDataPoint(new NDataPoint(23, 25, -20, "Item2")); m_Point.AddDataPoint(new NDataPoint(12, 45, 45, "Item3")); m_Point.AddDataPoint(new NDataPoint(24, 35, -12, "Item4")); m_Point.AddDataPoint(new NDataPoint(16, 41, 3, "Item5")); m_Point.AddDataPoint(new NDataPoint(17, 15, -34, "Item6")); m_Point.AddDataPoint(new NDataPoint(13, -25, -20, "Item7")); m_Point.AddDataPoint(new NDataPoint(12, 45, 1, "Item8")); m_Point.AddDataPoint(new NDataPoint(4, -21, -12, "Item9")); m_Point.AddDataPoint(new NDataPoint(16, -24, 47, "Item10")); m_Chart.PaintCallback = new CustomPaintCallback(this); // init form controls DataPointNumericUpDown.Minimum = 0; DataPointNumericUpDown.Maximum = m_Point.Values.Count - 1; DataPointNumericUpDown.Value = 0; WatermarkPositionComboBox.Items.Add("Position in scale Units"); WatermarkPositionComboBox.Items.Add("Position from Data Point"); WatermarkPositionComboBox.SelectedIndex = 1; m_bUpdateWatermark = true; nChartControl1.Refresh(); }