void setHoles(Chart3DDataSetGrid grset, bool enable) { int i, j; if (enable) { for (i = 0; i < grset.ColumnCount; i++) { for (j = 0; j < grset.RowCount; j++) { float x; float y; if (grset is Chart3DDataSetIrGrid) { Chart3DDataSetIrGrid s = (Chart3DDataSetIrGrid)grset; x = (float)s.GetColumnValue(i); y = (float)s.GetRowValue(j); } else { x = (float)(grset.MinX + i * grset.RowDelta); y = (float)(grset.MinY + j * grset.ColumnDelta); } float val = 0.1f * x * x - 0.4f * y * y; if (i == j || i == grset.RowCount - j) { grset.SetValue(i, j, val); } } } } else { for (i = 0; i < grset.ColumnCount; i++) { for (j = 0; j < grset.RowCount; j++) { // holes if (i == j || i == grset.RowCount - j) { grset.SetValue(i, j, grset.Hole); } } } } }
private C1Chart3D.Chart3DDataSetGrid CreateSet(Chart3DDataSetGrid set) { var group = set.GetChartGroup(); if (group == null) { return(null); } var data = group.ChartData; var c1Chart = new C1Chart3D.C1Chart3D(); var c1Group = c1Chart.ChartGroups.Group0; var c1Data = c1Group.ChartData; c1Data.Layout = C1Chart3D.DataLayoutEnum.GridData; var values = set.GridData ?? new double[0, 0]; var c1Set = new C1Chart3D.Chart3DDataSetGrid(0, 0, 1, 1, values); c1Set.Hole = data.Hole; c1Data.SetGrid = c1Set; return(c1Set); }
private void SurfaceCharts_Load(object sender, EventArgs e) { Chart3DDataSetGrid grid = c1Chart3D1.ChartGroups.Group0.ChartData.SetGrid; IList rows = categorySales1.List; Chart3DAxis x = c1Chart3D1.ChartArea.AxisX; Chart3DAxis y = c1Chart3D1.ChartArea.AxisY; Chart3DAxis z = c1Chart3D1.ChartArea.AxisZ; grid.RowCount = rows.Count; grid.ColumnCount = 4; for (int i = 0; i < rows.Count; i++) { DataRowView view = rows[i] as DataRowView; DataRow r = view.Row; grid[0, i] = System.Convert.ToDouble(r[1]); grid[1, i] = System.Convert.ToDouble(r[2]); grid[2, i] = System.Convert.ToDouble(r[3]); grid[3, i] = System.Convert.ToDouble(r[4]); y.ValueLabels.Add(i, r[0].ToString()); } x.ValueLabels.Add(0, "Q1"); x.ValueLabels.Add(1, "Q2"); x.ValueLabels.Add(2, "Q3"); x.ValueLabels.Add(3, "Q4"); x.AnnoMethod = AnnotationMethodEnum.ValueLabels; x.AnnoPosition = AnnoPositionEnum.Both; x.MajorGrid.IsOnXYPlane = true; x.MajorGrid.IsOnXZPlane = true; x.MajorGrid.Style.Color = SystemColors.ControlDarkDark; y.AnnoMethod = AnnotationMethodEnum.ValueLabels; y.AnnoRotated = true; y.AnnoPosition = AnnoPositionEnum.Both; y.MajorGrid.IsOnXYPlane = true; y.MajorGrid.IsOnYZPlane = true; y.MajorGrid.Style.Color = SystemColors.ControlDarkDark; z.AnnoFormat = FormatEnum.NumericManual; z.AnnoFormatString = "#,"; z.Text = "$1,000's"; z.UnitMajor = z.UnitMinor; z.MajorGrid.IsOnXZPlane = true; z.MajorGrid.IsOnYZPlane = true; z.MajorGrid.Style.Color = SystemColors.ControlDarkDark; InitComboFromEnum(cbChartTypes, typeof(Chart3DTypeEnum)); InitComboFromEnum(cbProjections, typeof(View3DEnum)); cbChartTypes.SelectedItem = Chart3DTypeEnum.Surface; //Adjust zoom level c1Chart3D1.Legend.Compass = CompassEnum.South; c1Chart3D1.Style.Font = new System.Drawing.Font(c1Chart3D1.Font.FontFamily, 8); c1Chart3D1.Legend.Style.Font = new System.Drawing.Font(c1Chart3D1.Font.FontFamily, 8); c1Chart3D1.ChartArea.Axes.AxisFont = new System.Drawing.Font(c1Chart3D1.Font.FontFamily, 8); c1Chart3D1.ChartArea.Axes.AxisTitleFont = new System.Drawing.Font(c1Chart3D1.Font.FontFamily, 8); c1Chart3D1.ChartArea.View.ViewportScale = 1.6f; c1Chart3D1.ChartArea.View.ViewportHorizontalShift = .18f; c1Chart3D1.ChartArea.View.ViewportVerticalShift = -.17f; c1Chart3D1.UseAntiAliasedGraphics = true; }
private void SurfaceCharts_Load(object sender, EventArgs e) { Chart3DDataSetGrid grid = c1Chart3D1.ChartGroups.Group0.ChartData.SetGrid; IList rows = categorySales1.List; Chart3DAxis x = c1Chart3D1.ChartArea.AxisX; Chart3DAxis y = c1Chart3D1.ChartArea.AxisY; Chart3DAxis z = c1Chart3D1.ChartArea.AxisZ; grid.RowCount = rows.Count; grid.ColumnCount = 4; for (int i = 0; i < rows.Count; i++) { DataRowView view = rows[i] as DataRowView; DataRow r = view.Row; grid[0, i] = System.Convert.ToDouble(r[1]); grid[1, i] = System.Convert.ToDouble(r[2]); grid[2, i] = System.Convert.ToDouble(r[3]); grid[3, i] = System.Convert.ToDouble(r[4]); y.ValueLabels.Add(i, r[0].ToString()); } x.ValueLabels.Add(0, "Q1"); x.ValueLabels.Add(1, "Q2"); x.ValueLabels.Add(2, "Q3"); x.ValueLabels.Add(3, "Q4"); x.AnnoMethod = AnnotationMethodEnum.ValueLabels; x.AnnoPosition = AnnoPositionEnum.Both; x.MajorGrid.IsOnXYPlane = true; x.MajorGrid.IsOnXZPlane = true; x.MajorGrid.Style.Color = SystemColors.ControlDarkDark; y.AnnoMethod = AnnotationMethodEnum.ValueLabels; y.AnnoRotated = true; y.AnnoPosition = AnnoPositionEnum.Both; y.MajorGrid.IsOnXYPlane = true; y.MajorGrid.IsOnYZPlane = true; y.MajorGrid.Style.Color = SystemColors.ControlDarkDark; z.AnnoFormat = FormatEnum.NumericManual; z.AnnoFormatString = "#,"; z.Text = "$1,000's"; z.UnitMajor = z.UnitMinor; z.MajorGrid.IsOnXZPlane = true; z.MajorGrid.IsOnYZPlane = true; z.MajorGrid.Style.Color = SystemColors.ControlDarkDark; InitComboFromEnum(cbChartTypes, typeof(Chart3DTypeEnum)); InitComboFromEnum(cbProjections, typeof(View3DEnum)); cbChartTypes.SelectedItem = Chart3DTypeEnum.Surface; //Adjust zoom level c1Chart3D1.ChartArea.View.ViewportScale = 1.4f; c1Chart3D1.ChartArea.View.ViewportHorizontalShift = .15f; c1Chart3D1.ChartArea.View.ViewportVerticalShift = -.17f; c1Chart3D1.UseAntiAliasedGraphics = true; // Add demo properties AddProperty("Boxed", c1Chart3D1.ChartArea.View); AddProperty("DropLines", c1Chart3D1.ChartGroups.Group0.Elevation); AddProperty("IsInteractive", c1Chart3D1.ChartArea.View); AddProperty("IsMeshed", c1Chart3D1.ChartGroups.Group0.Elevation); AddProperty("Perspective", c1Chart3D1.ChartArea.View); AddPropertyHeader("Axis Properties"); AddProperty("AnnoPosition", c1Chart3D1.ChartArea.AxisX, "AxisX.AnnoPosition"); AddProperty("AnnoPosition", c1Chart3D1.ChartArea.AxisY, "AxisY.AnnoPosition"); AddProperty("AnnoPosition", c1Chart3D1.ChartArea.AxisZ, "AxisZ.AnnoPosition"); AddProperty("GridLines", this); AddPropertyHeader("Contour Properties"); AddProperty("IsContoured", c1Chart3D1.ChartGroups.Group0.Contour); AddProperty("NumLevels", c1Chart3D1.ChartGroups.Group0.Contour); AddProperty("ZoneMethod", c1Chart3D1.ChartGroups.Group0.Contour); AddPropertyHeader("Ceiling Properties"); AddProperty("IsContoured", c1Chart3D1.ChartArea.View.Ceiling); AddProperty("IsZoned", c1Chart3D1.ChartArea.View.Ceiling); AddPropertyHeader("Floor Properties"); AddProperty("IsContoured", c1Chart3D1.ChartArea.View.Floor); AddProperty("IsZoned", c1Chart3D1.ChartArea.View.Floor); }
void createTestData() { int i, j; float x, y; // init point dataset setPoint = new Chart3DDataSetPoint(); for (int ix = 0; ix < 3; ix++) { for (int iy = 0; iy < 3; iy++) { for (int iz = 0; iz < 3; iz++) { pointData[ix + 3 * iy + 9 * iz].X = ix; pointData[ix + 3 * iy + 9 * iz].Y = iy; pointData[ix + 3 * iy + 9 * iz].Z = iz; pointData1[ix + 3 * iy + 9 * iz].X = 3 + 2 * ix; pointData1[ix + 3 * iy + 9 * iz].Y = 2 * iy; pointData1[ix + 3 * iy + 9 * iz].Z = 2 * iz; } } } setPoint.AddSeries(pointData); setPoint.AddSeries(pointData1); //float[,] gridData = new float[ 11, 11]; float[,] gridData = (float[, ])Array.CreateInstance(typeof(float), 11, 11); for (i = 0; i < gridData.GetLength(0); i++) { for (j = 0; j < gridData.GetLength(1); j++) { x = -5 + i; y = -5 + j; gridData[i, j] = 0.1f * x * x - 0.4f * y * y; } } setGrid = new Chart3DDataSetGrid(-5, -5, 1, 1, gridData); // contour data for 4d chart contourData = (double[, ])Array.CreateInstance(typeof(double), setGrid.ColumnCount, setGrid.RowCount); for (i = 0; i < setGrid.ColumnCount; i++) { for (j = 0; j < setGrid.RowCount; j++) { contourData[i, j] = i + j; } } // init irregular grid dataset float[] xdata = { 1, 2, 6, 8, 9, 13, 15 }; float[] ydata = { 1, 2, 4, 8, 11, 12, 15 }; float[,] vals = (float[, ])Array.CreateInstance(typeof(float), xdata.Length, ydata.Length); setIrGrid = new Chart3DDataSetIrGrid(xdata, ydata, vals); { x = (float)setIrGrid.ColumnOrigin; for (i = 0; i < setIrGrid.ColumnCount; i++) { x += (float)setIrGrid.ColumnDeltaArray[i]; y = (float)setIrGrid.RowOrigin; for (j = 0; j < setIrGrid.RowCount; j++) { y += (float)setIrGrid.RowDeltaArray[j]; float val = 0.1f * x * x - 0.4f * y * y; setIrGrid.SetValue(i, j, val); } } } // starting dataset c1Chart3D1.ChartGroups[0].ChartData.Set = setGrid; // adding labels to chart Chart3DLabel labelC = c1Chart3D1.ChartLabels.LabelsCollection.AddNewLabel(); labelC.Text = "Label(Coordinate)"; labelC.LabelCompass = LabelCompassEnum.SouthEast; labelC.AttachMethodData.X = 20; labelC.AttachMethodData.Y = 20; labelC.Visible = true; Chart3DLabel labelD = c1Chart3D1.ChartLabels.LabelsCollection.AddNewLabel(); labelD.Text = "Label(DataCoordinate)"; labelD.LabelCompass = LabelCompassEnum.SouthEast; labelD.Offset = 50; labelD.Connected = true; labelD.AttachMethod = AttachMethodEnum.DataCoordinate; labelD.AttachMethodData.X = 0; labelD.AttachMethodData.Y = 0; labelD.AttachMethodData.Z = 0; labelD.Visible = true; Chart3DLabel labelI = c1Chart3D1.ChartLabels.LabelsCollection.AddNewLabel(); labelI.Text = "Label(DataIndex)"; labelI.LabelCompass = LabelCompassEnum.SouthWest; labelI.Offset = 25; labelI.Connected = true; labelI.AttachMethod = AttachMethodEnum.DataIndex; labelI.AttachMethodData.SeriesIndex = 2; labelI.AttachMethodData.PointIndex = 4; labelI.Visible = true; // adding data labels c1Chart3D1.DefaultLabelStyle.BackColor = Color.MistyRose; c1Chart3D1.DefaultLabelStyle.Border.BorderStyle = BorderStyleEnum.Solid; for (i = 0; i < setGrid.RowCount; i++) { Chart3DDataLabel lab = c1Chart3D1.ChartGroups.RowLabels.AddNewLabel(); lab.Index = i; lab.Text = "Row " + i.ToString(); } for (j = 0; j < setGrid.ColumnCount; j++) { Chart3DDataLabel lab = c1Chart3D1.ChartGroups.ColumnLabels.AddNewLabel(); lab.Index = j; lab.Text = "Col " + j.ToString(); } // adding labels to axis foreach (Chart3DAxis axis in c1Chart3D1.ChartArea.Axes) { Chart3DAxisLabel alab1 = axis.ValueLabels.AddNewLabel(); alab1.Value = -1; alab1.Text = "minus one"; Chart3DAxisLabel alab2 = axis.ValueLabels.AddNewLabel(); alab2.Value = +1; alab2.Text = "plus one"; } // set bar colors c1Chart3D1.ChartGroups[0].Bar.SetBarColor(1, 1, Color.Red); c1Chart3D1.ChartGroups[0].Bar.SetBarColor(1, 2, Color.Red); c1Chart3D1.ChartGroups[0].Bar.SetBarColor(-1, 3, Color.Blue); c1Chart3D1.ChartGroups[0].Bar.SetBarColor(3, -1, Color.Green); }