|
@@ -0,0 +1,659 @@
|
|
|
+using DevExpress.Utils;
|
|
|
+using DevExpress.XtraCharts;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+
|
|
|
+namespace OTSIncAReportApp._1_UI.Control_DEVCharts
|
|
|
+{
|
|
|
+ public static class DevFunctions
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// 饼状Series设置成百分比显示
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="series">Series</param>
|
|
|
+ public static void SetPiePercentage(this Series series)
|
|
|
+ {
|
|
|
+ if (series.View is PieSeriesView)
|
|
|
+ {
|
|
|
+ ((PiePointOptions)series.PointOptions).PercentOptions.ValueAsPercent = true;
|
|
|
+ ((PiePointOptions)series.PointOptions).ValueNumericOptions.Format = NumericFormat.Percent;
|
|
|
+ ((PiePointOptions)series.PointOptions).ValueNumericOptions.Precision = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 饼状Series设置显示格式,是以数字还是百分号显示
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="series">Series</param>
|
|
|
+ public static void SetPieNumber(Series series)
|
|
|
+ {
|
|
|
+ if (series.View is PieSeriesView)
|
|
|
+ {
|
|
|
+ //设置为值
|
|
|
+ ((PiePointOptions)series.PointOptions).PercentOptions.ValueAsPercent = false;
|
|
|
+ ((PiePointOptions)series.PointOptions).ValueNumericOptions.Format = NumericFormat.Number;
|
|
|
+ ((PiePointOptions)series.PointOptions).ValueNumericOptions.Precision = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void SetAxisForXYDiagram(Diagram diagram)
|
|
|
+ {
|
|
|
+ //坐标标题的定义
|
|
|
+ //坐标值说明的字体尺寸,颜色定义
|
|
|
+ ((XYDiagram)diagram).AxisY.Title.TextColor = System.Drawing.Color.Black;
|
|
|
+ //((XYDiagram)diagram).AxisY.Title.Text = "质量占比";
|
|
|
+ ((XYDiagram)diagram).AxisY.Title.Visible = true;
|
|
|
+ //((XYDiagram)diagram).AxisX.Title.Text = "矿物成分";
|
|
|
+ ((XYDiagram)diagram).AxisX.Title.Visible = true;
|
|
|
+ ((XYDiagram)diagram).AxisY.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+ // Access the type-specific options of the diagram.
|
|
|
+ ((XYDiagram)diagram).EnableAxisXZooming = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 饼状图突出设置
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="chart">ChartControl</param>
|
|
|
+ /// <param name="pieSeries">Series【仅仅适用于PieSeriesView】</param>
|
|
|
+ /// <param name="explodeMode">突出模式【枚举】</param>
|
|
|
+ /// <param name="explodedValue">突出间距</param>
|
|
|
+ /// <param name="dragPie">是否可以拖动突出饼状</param>
|
|
|
+ public static void SetPieExplode(this ChartControl chart, Series pieSeries, PieExplodeMode explodeMode, int explodedValue, bool dragPie)
|
|
|
+ {
|
|
|
+ if (pieSeries.View is PieSeriesView)
|
|
|
+ {
|
|
|
+ if (!chart.RuntimeHitTesting)
|
|
|
+ chart.RuntimeHitTesting = true;
|
|
|
+ PieSeriesView _pieView = pieSeries.View as PieSeriesView;
|
|
|
+ _pieView.ExplodeMode = explodeMode;
|
|
|
+ _pieView.ExplodedDistancePercentage = explodedValue;
|
|
|
+ _pieView.RuntimeExploding = dragPie;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Doughnut突出设置
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="chart">ChartControl</param>
|
|
|
+ /// <param name="series">Series【仅仅适用于PieSeriesView】</param>
|
|
|
+ /// <param name="explodeMode">突出模式【枚举】</param>
|
|
|
+ /// <param name="explodedValue">突出间距</param>
|
|
|
+ /// <param name="dragPie">是否可以拖动突出饼状</param>
|
|
|
+ public static void SetDoughnutExplode(this ChartControl chart, Series series, PieExplodeMode explodeMode, int explodedValue, bool dragPie)
|
|
|
+ {
|
|
|
+ if (series.View is DoughnutSeriesView)
|
|
|
+ {
|
|
|
+ if (!chart.RuntimeHitTesting)
|
|
|
+ chart.RuntimeHitTesting = true;
|
|
|
+ DoughnutSeriesView _View = series.View as DoughnutSeriesView;
|
|
|
+ _View.ExplodeMode = explodeMode;
|
|
|
+ _View.ExplodedDistancePercentage = explodedValue;
|
|
|
+ _View.RuntimeExploding = dragPie;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static void ChangeView(ChartControl chartControl, string Serie, string ChartType)
|
|
|
+ {
|
|
|
+ Series s = chartControl.GetSeriesByName(Serie);
|
|
|
+ s.Label.TextPattern = "{V:F2}";
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
|
|
|
+ s.PointOptions.ValueNumericOptions.Precision = 2;
|
|
|
+ s.Label.PointOptions.ValueNumericOptions.Precision = 2;
|
|
|
+ s.LegendTextPattern = "{A}: {VP:P3}";
|
|
|
+
|
|
|
+ switch (ChartType)
|
|
|
+ {
|
|
|
+ case "折线图":
|
|
|
+ s.ChangeView(ViewType.Line);
|
|
|
+
|
|
|
+ // Access the view-type-specific options of the series.
|
|
|
+ ((LineSeriesView)s.View).LineMarkerOptions.Kind = MarkerKind.Triangle;
|
|
|
+ ((LineSeriesView)s.View).LineStyle.DashStyle = DashStyle.Dash;
|
|
|
+ ((LineSeriesView)s.View).ColorEach = true;
|
|
|
+ SetAxisForXYDiagram(chartControl.Diagram);
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "柱状图":
|
|
|
+ s.ChangeView(ViewType.Bar);
|
|
|
+
|
|
|
+ SetAxisForXYDiagram(chartControl.Diagram);
|
|
|
+
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "饼图":
|
|
|
+ s.ChangeView(ViewType.Pie);
|
|
|
+
|
|
|
+ //s.LegendPointOptions.PointView = PointView.ArgumentAndValues;
|
|
|
+ ((PieSeriesLabel)s.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default;//检测标签重合
|
|
|
+ SetPiePercentage(s);
|
|
|
+ s.Label.TextPattern = "{A}: {VP:P2}";
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+
|
|
|
+ s.ToolTipEnabled = DefaultBoolean.True;
|
|
|
+ s.ToolTipPointPattern = "{A}: {VP:P3}";
|
|
|
+
|
|
|
+
|
|
|
+ SetPieExplode(chartControl, s, PieExplodeMode.MinValue, 9, true);
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "圆环图":
|
|
|
+ s.ChangeView(ViewType.Doughnut);
|
|
|
+
|
|
|
+ // Specify the text pattern of series labels.
|
|
|
+ s.Label.TextPattern = "{A}: {VP:P2}";
|
|
|
+
|
|
|
+ // Specify how series points are sorted.
|
|
|
+ s.SeriesPointsSorting = SortingMode.Ascending;
|
|
|
+ s.SeriesPointsSortingKey = SeriesPointKey.Argument;
|
|
|
+
|
|
|
+ // Specify the behavior of series labels.
|
|
|
+ ((DoughnutSeriesLabel)s.Label).Position = PieSeriesLabelPosition.TwoColumns;
|
|
|
+ ((DoughnutSeriesLabel)s.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default;
|
|
|
+ ((DoughnutSeriesLabel)s.Label).ResolveOverlappingMinIndent = 5;
|
|
|
+
|
|
|
+ // Access the diagram's options.
|
|
|
+ ((SimpleDiagram)chartControl.Diagram).Dimension = 2;
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+
|
|
|
+ s.ToolTipEnabled = DefaultBoolean.True;
|
|
|
+ s.ToolTipPointPattern = "{A}: {VP:P3}";
|
|
|
+
|
|
|
+ SetDoughnutExplode(chartControl, s, PieExplodeMode.MinValue, 5, true);
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "气泡图":
|
|
|
+ s.ChangeView(ViewType.Bubble);
|
|
|
+ ((BubbleSeriesView)s.View).BubbleMarkerOptions.Kind = MarkerKind.Circle;
|
|
|
+ ((BubbleSeriesView)s.View).ColorEach = true;
|
|
|
+ s.CrosshairLabelPattern = "{A}";//鼠标悬浮的时候的焦点显示的格式
|
|
|
+
|
|
|
+ SetAxisForXYDiagram(chartControl.Diagram);
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "簇状条形图":
|
|
|
+ s.ChangeView(ViewType.SideBySideStackedBar);
|
|
|
+ ((SideBySideStackedBarSeriesView)s.View).ColorEach = true;
|
|
|
+ SetAxisForXYDiagram(chartControl.Diagram);
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "堆积条形图":
|
|
|
+ s.ChangeView(ViewType.StackedBar);
|
|
|
+ ((StackedBarSeriesView)s.View).ColorEach = true;
|
|
|
+ SetAxisForXYDiagram(chartControl.Diagram);
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "瀑布图":
|
|
|
+ s.ChangeView(ViewType.Waterfall);
|
|
|
+ ((WaterfallSeriesView)s.View).ColorEach = true;
|
|
|
+ SetAxisForXYDiagram(chartControl.Diagram);
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "3D柱状图":
|
|
|
+ s.ChangeView(ViewType.Bar3D);
|
|
|
+
|
|
|
+ // Access the series options.
|
|
|
+ s.PointOptions.PointView = PointView.ArgumentAndValues;
|
|
|
+
|
|
|
+ // Customize the view-type-specific properties of the series.
|
|
|
+ Bar3DSeriesView Bar3DView = (Bar3DSeriesView)s.View;
|
|
|
+ Bar3DView.BarDepthAuto = false;
|
|
|
+ Bar3DView.BarDepth = 1;
|
|
|
+ Bar3DView.BarWidth = 1;
|
|
|
+ Bar3DView.Transparency = 80;
|
|
|
+ Bar3DView.ColorEach = true;
|
|
|
+
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeScrolling = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+
|
|
|
+ // Access the diagram's options.
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).ZoomPercent = 125;
|
|
|
+
|
|
|
+ s.Label.TextPattern = "{V:F2}";
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+
|
|
|
+ s.LegendTextPattern = "{A}: {V:F3}";
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "3D圆环图":
|
|
|
+ s.ChangeView(ViewType.Doughnut3D);
|
|
|
+
|
|
|
+ // Adjust the view-type-specific options of the series.
|
|
|
+ ((Doughnut3DSeriesView)s.View).Depth = 11;
|
|
|
+ ((Doughnut3DSeriesView)s.View).HoleRadiusPercent = 30;
|
|
|
+ ((Doughnut3DSeriesView)s.View).ExplodedPoints.Add(s.Points[0]);
|
|
|
+
|
|
|
+ // Access the diagram's options.
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RotationType = RotationType.UseAngles;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RotationAngleX = -35;
|
|
|
+
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RuntimeScrolling = false;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+ s.Label.TextPattern = "{A}: {VP:P2}";
|
|
|
+
|
|
|
+ s.ToolTipEnabled = DefaultBoolean.True;
|
|
|
+ s.ToolTipPointPattern = "{A}: {VP:P3}";
|
|
|
+
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).ZoomPercent = 110;
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "3D饼图":
|
|
|
+ s.ChangeView(ViewType.Pie3D);
|
|
|
+
|
|
|
+ // Adjust the value numeric options of the series.
|
|
|
+ s.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
|
|
|
+
|
|
|
+ // Adjust the view-type-specific options of the series.
|
|
|
+ ((Pie3DSeriesView)s.View).Depth = 11;
|
|
|
+
|
|
|
+ // Access the diagram's options.
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RotationType = RotationType.UseAngles;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RotationAngleX = -35;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).ZoomPercent = 110;
|
|
|
+
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RuntimeScrolling = false;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+ s.Label.TextPattern = "{A}: {VP:P2}";
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "3D折线图":
|
|
|
+ s.ChangeView(ViewType.Line3D);
|
|
|
+
|
|
|
+ Line3DSeriesView Line3DView = (Line3DSeriesView)s.View;
|
|
|
+ Line3DView.LineWidth = 3;
|
|
|
+ Line3DView.LineThickness = 3;
|
|
|
+
|
|
|
+
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeScrolling = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+
|
|
|
+ // Access the diagram's options.
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).ZoomPercent = 125;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).VerticalScrollPercent = 0;
|
|
|
+
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "3D百分比堆积条形图":
|
|
|
+ s.ChangeView(ViewType.FullStackedBar3D);
|
|
|
+
|
|
|
+ FullStackedBar3DSeriesView FullStackedBar3DView = (FullStackedBar3DSeriesView)s.View;
|
|
|
+ FullStackedBar3DView.Transparency = 160;
|
|
|
+ FullStackedBar3DView.Model = Bar3DModel.Cylinder;
|
|
|
+ FullStackedBar3DView.ShowFacet = false;
|
|
|
+ FullStackedBar3DView.ColorEach = true;
|
|
|
+
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeScrolling = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+
|
|
|
+ // Access the diagram's options.
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).ZoomPercent = 125;
|
|
|
+
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+ s.LegendTextPattern = "{A}: {V:F3}";
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "3D漏斗图":
|
|
|
+ s.ChangeView(ViewType.Funnel3D);
|
|
|
+
|
|
|
+ // Display a title for the series,
|
|
|
+ // and adjust another view-type-specific options of the series.
|
|
|
+ Funnel3DSeriesView funnelView = (Funnel3DSeriesView)s.View;
|
|
|
+ funnelView.HeightToWidthRatio = 1;
|
|
|
+ funnelView.HoleRadiusPercent = 70;
|
|
|
+ funnelView.PointDistance = 5;
|
|
|
+
|
|
|
+ // Adjust the value numeric options of the series.
|
|
|
+ s.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
|
|
|
+ s.PointOptions.ValueNumericOptions.Precision = 2;
|
|
|
+
|
|
|
+ // Access the view-type-specific series options.
|
|
|
+ ((FunnelPointOptions)s.PointOptions).PercentOptions.ValueAsPercent = true;
|
|
|
+
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+ s.Label.TextPattern = "{A}: {VP:P2}";
|
|
|
+
|
|
|
+ ((FunnelDiagram3D)chartControl.Diagram).RuntimeScrolling = true;
|
|
|
+ ((FunnelDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((FunnelDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((FunnelDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+
|
|
|
+ // Access the diagram's options.
|
|
|
+ ((FunnelDiagram3D)chartControl.Diagram).ZoomPercent = 100;
|
|
|
+
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "3DManhattan 条形图":
|
|
|
+ s.ChangeView(ViewType.ManhattanBar);
|
|
|
+
|
|
|
+ Bar3DSeriesView ManhattanBarView = (Bar3DSeriesView)s.View;
|
|
|
+ ManhattanBarView.BarDepthAuto = false;
|
|
|
+ ManhattanBarView.BarDepth = 1;
|
|
|
+ ManhattanBarView.Transparency = 80;
|
|
|
+ ManhattanBarView.ShowFacet = false;
|
|
|
+ ManhattanBarView.Model = Bar3DModel.Cylinder;
|
|
|
+ ManhattanBarView.ColorEach = true;
|
|
|
+
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeScrolling = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+
|
|
|
+ // Access the diagram's options.
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).ZoomPercent = 125;
|
|
|
+
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+ s.Label.TextPattern = "{V:F2}";
|
|
|
+
|
|
|
+ s.LegendTextPattern = "{A}: {V:F3}";
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "3D堆积条形图":
|
|
|
+ s.ChangeView(ViewType.StackedBar3D);
|
|
|
+
|
|
|
+ StackedBar3DSeriesView StackedBar3DView = (StackedBar3DSeriesView)s.View;
|
|
|
+ StackedBar3DView.BarDepthAuto = false;
|
|
|
+ StackedBar3DView.BarDepth = 1.5;
|
|
|
+ StackedBar3DView.BarWidth = 1;
|
|
|
+ StackedBar3DView.Transparency = 160;
|
|
|
+ StackedBar3DView.Model = Bar3DModel.Cylinder;
|
|
|
+ StackedBar3DView.ColorEach = true;
|
|
|
+
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeScrolling = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+
|
|
|
+ // Access the diagram's options.
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).ZoomPercent = 125;
|
|
|
+
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+ s.Label.TextPattern = "{V:F2}";
|
|
|
+
|
|
|
+ s.LegendTextPattern = "{A}: {V:F3}";
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "3D阶梯线图":
|
|
|
+ s.ChangeView(ViewType.StepLine3D);
|
|
|
+
|
|
|
+ StepLine3DSeriesView StepLine3DView = (StepLine3DSeriesView)s.View;
|
|
|
+ StepLine3DView.LineWidth = 5;
|
|
|
+ StepLine3DView.LineThickness = 3;
|
|
|
+
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeScrolling = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+
|
|
|
+ // Access the diagram's options.
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).ZoomPercent = 125;
|
|
|
+
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
|
|
|
+ s.Label.TextPattern = "{V:F2}";
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void ChangeView2(ChartControl chartControl, string ChartType)
|
|
|
+ {
|
|
|
+ foreach (Series s in chartControl.Series)
|
|
|
+ {
|
|
|
+ s.Label.TextPattern = "{V:F2}";
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
|
|
|
+ s.PointOptions.ValueNumericOptions.Precision = 2;
|
|
|
+ s.Label.PointOptions.ValueNumericOptions.Precision = 2;
|
|
|
+ s.LegendTextPattern = "{A}: {VP:P3}";
|
|
|
+
|
|
|
+ switch (ChartType)
|
|
|
+ {
|
|
|
+ case "折线图":
|
|
|
+ s.ChangeView(ViewType.Line);
|
|
|
+ ((LineSeriesView)s.View).LineMarkerOptions.Kind = MarkerKind.Triangle;
|
|
|
+ ((LineSeriesView)s.View).LineStyle.DashStyle = DashStyle.Dash;
|
|
|
+ SetAxisForXYDiagram(chartControl.Diagram);
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "柱状图":
|
|
|
+ s.ChangeView(ViewType.Bar);
|
|
|
+ SetAxisForXYDiagram(chartControl.Diagram);
|
|
|
+
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "饼图":
|
|
|
+ s.ChangeView(ViewType.Pie);
|
|
|
+ ((PieSeriesLabel)s.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default;//检测标签重合
|
|
|
+ SetPiePercentage(s);
|
|
|
+ s.Label.TextPattern = "{A}: {VP:P2}";
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+ s.ToolTipEnabled = DefaultBoolean.True;
|
|
|
+ s.ToolTipPointPattern = "{A}: {VP:P3}";
|
|
|
+ SetPieExplode(chartControl, s, PieExplodeMode.MinValue, 9, true);
|
|
|
+ break;
|
|
|
+ case "圆环图":
|
|
|
+ s.ChangeView(ViewType.Doughnut);
|
|
|
+ s.Label.TextPattern = "{A}: {VP:P2}";
|
|
|
+ s.SeriesPointsSorting = SortingMode.Ascending;
|
|
|
+ s.SeriesPointsSortingKey = SeriesPointKey.Argument;
|
|
|
+ ((DoughnutSeriesLabel)s.Label).Position = PieSeriesLabelPosition.TwoColumns;
|
|
|
+ ((DoughnutSeriesLabel)s.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default;
|
|
|
+ ((DoughnutSeriesLabel)s.Label).ResolveOverlappingMinIndent = 5;
|
|
|
+ ((SimpleDiagram)chartControl.Diagram).Dimension = 2;
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+ s.ToolTipEnabled = DefaultBoolean.True;
|
|
|
+ s.ToolTipPointPattern = "{A}: {VP:P3}";
|
|
|
+ SetDoughnutExplode(chartControl, s, PieExplodeMode.MinValue, 5, true);
|
|
|
+ break;
|
|
|
+ case "气泡图":
|
|
|
+ s.ChangeView(ViewType.Bubble);
|
|
|
+ ((BubbleSeriesView)s.View).BubbleMarkerOptions.Kind = MarkerKind.Circle;
|
|
|
+ s.CrosshairLabelPattern = "{A}";//鼠标悬浮的时候的焦点显示的格式
|
|
|
+ SetAxisForXYDiagram(chartControl.Diagram);
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "簇状条形图":
|
|
|
+ s.ChangeView(ViewType.SideBySideStackedBar);
|
|
|
+ ((SideBySideStackedBarSeriesView)s.View).ColorEach = true;
|
|
|
+ SetAxisForXYDiagram(chartControl.Diagram);
|
|
|
+ break;
|
|
|
+ case "堆积条形图":
|
|
|
+ s.ChangeView(ViewType.StackedBar);
|
|
|
+ ((StackedBarSeriesView)s.View).ColorEach = true;
|
|
|
+ SetAxisForXYDiagram(chartControl.Diagram);
|
|
|
+ break;
|
|
|
+ case "瀑布图":
|
|
|
+ s.ChangeView(ViewType.Waterfall);
|
|
|
+ ((WaterfallSeriesView)s.View).ColorEach = true;
|
|
|
+ SetAxisForXYDiagram(chartControl.Diagram);
|
|
|
+ break;
|
|
|
+ case "3D柱状图":
|
|
|
+ s.ChangeView(ViewType.Bar3D);
|
|
|
+ s.PointOptions.PointView = PointView.ArgumentAndValues;
|
|
|
+ Bar3DSeriesView Bar3DView = (Bar3DSeriesView)s.View;
|
|
|
+ Bar3DView.BarDepthAuto = false;
|
|
|
+ Bar3DView.BarDepth = 1;
|
|
|
+ Bar3DView.BarWidth = 1;
|
|
|
+ Bar3DView.Transparency = 80;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeScrolling = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).ZoomPercent = 125;
|
|
|
+ s.Label.TextPattern = "{V:F2}";
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+ s.LegendTextPattern = "{A}: {V:F3}";
|
|
|
+ break;
|
|
|
+ case "3D圆环图":
|
|
|
+ s.ChangeView(ViewType.Doughnut3D);
|
|
|
+ ((Doughnut3DSeriesView)s.View).Depth = 11;
|
|
|
+ ((Doughnut3DSeriesView)s.View).HoleRadiusPercent = 30;
|
|
|
+ ((Doughnut3DSeriesView)s.View).ExplodedPoints.Add(s.Points[0]);
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RotationType = RotationType.UseAngles;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RotationAngleX = -35;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RuntimeScrolling = false;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+ s.Label.TextPattern = "{A}: {VP:P2}";
|
|
|
+ s.ToolTipEnabled = DefaultBoolean.True;
|
|
|
+ s.ToolTipPointPattern = "{A}: {VP:P3}";
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).ZoomPercent = 110;
|
|
|
+ break;
|
|
|
+ case "3D饼图":
|
|
|
+ s.ChangeView(ViewType.Pie3D);
|
|
|
+ s.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
|
|
|
+ ((Pie3DSeriesView)s.View).Depth = 11;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RotationType = RotationType.UseAngles;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RotationAngleX = -35;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).ZoomPercent = 110;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RuntimeScrolling = false;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((SimpleDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+ s.Label.TextPattern = "{A}: {VP:P2}";
|
|
|
+ break;
|
|
|
+ case "3D折线图":
|
|
|
+ s.ChangeView(ViewType.Line3D);
|
|
|
+ Line3DSeriesView Line3DView = (Line3DSeriesView)s.View;
|
|
|
+ Line3DView.LineWidth = 3;
|
|
|
+ Line3DView.LineThickness = 3;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeScrolling = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).ZoomPercent = 125;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).VerticalScrollPercent = 0;
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
|
|
|
+ break;
|
|
|
+ case "3D百分比堆积条形图":
|
|
|
+ s.ChangeView(ViewType.FullStackedBar3D);
|
|
|
+ FullStackedBar3DSeriesView FullStackedBar3DView = (FullStackedBar3DSeriesView)s.View;
|
|
|
+ FullStackedBar3DView.Transparency = 160;
|
|
|
+ FullStackedBar3DView.Model = Bar3DModel.Cylinder;
|
|
|
+ FullStackedBar3DView.ShowFacet = false;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeScrolling = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).ZoomPercent = 125;
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+ s.LegendTextPattern = "{A}: {V:F3}";
|
|
|
+ break;
|
|
|
+ case "3D漏斗图":
|
|
|
+ s.ChangeView(ViewType.Funnel3D);
|
|
|
+ Funnel3DSeriesView funnelView = (Funnel3DSeriesView)s.View;
|
|
|
+ funnelView.HeightToWidthRatio = 1;
|
|
|
+ funnelView.HoleRadiusPercent = 70;
|
|
|
+ funnelView.PointDistance = 5;
|
|
|
+ s.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent;
|
|
|
+ s.PointOptions.ValueNumericOptions.Precision = 2;
|
|
|
+ ((FunnelPointOptions)s.PointOptions).PercentOptions.ValueAsPercent = true;
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+ s.Label.TextPattern = "{A}: {VP:P2}";
|
|
|
+ ((FunnelDiagram3D)chartControl.Diagram).RuntimeScrolling = true;
|
|
|
+ ((FunnelDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((FunnelDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((FunnelDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+ ((FunnelDiagram3D)chartControl.Diagram).ZoomPercent = 100;
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+ break;
|
|
|
+ case "3DManhattan 条形图":
|
|
|
+ s.ChangeView(ViewType.ManhattanBar);
|
|
|
+ Bar3DSeriesView ManhattanBarView = (Bar3DSeriesView)s.View;
|
|
|
+ ManhattanBarView.BarDepthAuto = false;
|
|
|
+ ManhattanBarView.BarDepth = 1;
|
|
|
+ ManhattanBarView.Transparency = 80;
|
|
|
+ ManhattanBarView.ShowFacet = false;
|
|
|
+ ManhattanBarView.Model = Bar3DModel.Cylinder;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeScrolling = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).ZoomPercent = 125;
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+ s.Label.TextPattern = "{V:F2}";
|
|
|
+ s.LegendTextPattern = "{A}: {V:F3}";
|
|
|
+ break;
|
|
|
+ case "3D堆积条形图":
|
|
|
+ s.ChangeView(ViewType.StackedBar3D);
|
|
|
+ StackedBar3DSeriesView StackedBar3DView = (StackedBar3DSeriesView)s.View;
|
|
|
+ StackedBar3DView.BarDepthAuto = false;
|
|
|
+ StackedBar3DView.BarDepth = 1.5;
|
|
|
+ StackedBar3DView.BarWidth = 1;
|
|
|
+ StackedBar3DView.Transparency = 160;
|
|
|
+ StackedBar3DView.Model = Bar3DModel.Cylinder;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeScrolling = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).ZoomPercent = 125;
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True;
|
|
|
+ s.Label.TextPattern = "{V:F2}";
|
|
|
+ s.LegendTextPattern = "{A}: {V:F3}";
|
|
|
+ break;
|
|
|
+ case "3D阶梯线图":
|
|
|
+ s.ChangeView(ViewType.StepLine3D);
|
|
|
+ StepLine3DSeriesView StepLine3DView = (StepLine3DSeriesView)s.View;
|
|
|
+ StepLine3DView.LineWidth = 5;
|
|
|
+ StepLine3DView.LineThickness = 3;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeScrolling = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeZooming = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RuntimeRotation = true;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).RotationType = RotationType.UseMouseAdvanced;
|
|
|
+ ((XYDiagram3D)chartControl.Diagram).ZoomPercent = 125;
|
|
|
+ chartControl.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False;
|
|
|
+ s.Label.TextPattern = "{V:F2}";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ #region 通用
|
|
|
+ /// <summary>
|
|
|
+ /// [颜色:16进制转成RGB]
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="strColor">设置16进制颜色 [返回RGB]</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static System.Drawing.Color colorHx16toRGB(string strHxColor)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (strHxColor.Length == 0)
|
|
|
+ {//如果为空
|
|
|
+ return System.Drawing.Color.FromArgb(255, 255, 204);//设为白色
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {//转换颜色
|
|
|
+ return System.Drawing.Color.FromArgb(System.Int32.Parse(strHxColor.Substring(1, 2), System.Globalization.NumberStyles.AllowHexSpecifier), System.Int32.Parse(strHxColor.Substring(3, 2), System.Globalization.NumberStyles.AllowHexSpecifier), System.Int32.Parse(strHxColor.Substring(5, 2), System.Globalization.NumberStyles.AllowHexSpecifier));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {//设为白色
|
|
|
+ return System.Drawing.Color.FromArgb(255, 255, 204);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|