當前位置: 首頁>>代碼示例>>C#>>正文


C# ZedGraphControl.GetImage方法代碼示例

本文整理匯總了C#中ZedGraph.ZedGraphControl.GetImage方法的典型用法代碼示例。如果您正苦於以下問題:C# ZedGraphControl.GetImage方法的具體用法?C# ZedGraphControl.GetImage怎麽用?C# ZedGraphControl.GetImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ZedGraph.ZedGraphControl的用法示例。


在下文中一共展示了ZedGraphControl.GetImage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreateBarChartImageFile


//.........這裏部分代碼省略.........
                pane.X2Axis.MajorGrid.IsVisible = false;
                pane.X2Axis.MinorGrid.IsVisible = false;
                pane.X2Axis.MajorTic.IsInside = false;
                pane.X2Axis.MajorTic.IsOutside = false;
                pane.X2Axis.MinorTic.IsInside = false;
                pane.X2Axis.MinorTic.IsOutside = false;

                pane.YAxis.MajorGrid.IsVisible = true;
                pane.YAxis.MajorGrid.Color = Color.LightSteelBlue;

                pane.YAxis.MajorTic.IsInside = false;

                pane.YAxis.MinorTic.IsInside = false;
                pane.YAxis.MinorTic.IsOutside = false;

                pane.YAxis.Scale.FontSpec.Family = fontFamily;
                pane.YAxis.Scale.FontSpec.Size = fontSize;

                pane.YAxis.Title.FontSpec.Family = fontFamily;
                pane.YAxis.Title.FontSpec.Size = fontSize;
                pane.YAxis.Title.IsVisible = false;
                pane.YAxis.Title.Text = string.Empty;

                pane.Y2Axis.IsVisible = false;
                pane.Y2Axis.MajorGrid.IsVisible = false;
                pane.Y2Axis.MinorGrid.IsVisible = false;
                pane.Y2Axis.MajorTic.IsInside = false;
                pane.Y2Axis.MajorTic.IsOutside = false;
                pane.Y2Axis.MinorTic.IsInside = false;
                pane.Y2Axis.MinorTic.IsOutside = false;

                int idx = 0;
                string[] labels = new string[ barChartData.Count ];

                PointPairList nPoints = new PointPairList();
                PointPairList pPoints = new PointPairList();
                foreach( KeyValuePair<int, double> yearValue in barChartData )
                {
                    int yr = yearValue.Key % 100;
                    labels[ idx ] = "'" + yr.ToString( "00" );

                    double value = yearValue.Value * 100;
                    if( yearValue.Value >= 0 )
                    {
                        nPoints.Add( yearValue.Key, 0.0 );
                        pPoints.Add( yearValue.Key, value );
                    }
                    else
                    {
                        nPoints.Add( yearValue.Key, value );
                        pPoints.Add( yearValue.Key, 0.0 );
                    }

                    idx++;
                }

                pane.XAxis.Scale.TextLabels = labels;
                pane.XAxis.Type = AxisType.Text;

                //negative values
                BarItem nBar = pane.AddBar( string.Empty, nPoints, Color.Empty );
                nBar.Bar.Fill = new Fill( Color.FromArgb( 227, 99, 52 ), Color.FromArgb( 255, 177, 126 ), Color.FromArgb( 227, 99, 52 ) );

                //positive values
                BarItem pBar = pane.AddBar( string.Empty, pPoints, Color.Empty );
                pBar.Bar.Fill = new Fill( Color.FromArgb( 81, 148, 157 ), Color.FromArgb( 107, 197, 222 ), Color.FromArgb( 81, 148, 157 ) );

                //1 - Update the chart with the series
                chart.AxisChange();

                //2 - Process the value labels for each point
                this.WriteValueLabels( pane, nBar, fontFamily, fontSize, true );
                this.WriteValueLabels( pane, pBar, fontFamily, fontSize, false );

                //3 - Update the chart again
                chart.AxisChange();

                using( Image img = chart.GetImage() )
                {
                    EncoderParameters parms = new EncoderParameters( 1 );
                    EncoderParameter parm = new EncoderParameter( System.Drawing.Imaging.Encoder.Quality, 80L );
                    parms.Param[ 0 ] = parm;

                    ImageCodecInfo jgpEncoder = GetEncoder( ImageFormat.Jpeg );
                    img.Save( completeFileName, jgpEncoder, parms );
                }

                try
                {
                    chart.Dispose();
                    chart = null;
                }
                catch { }

                return true;
            }
            catch { }

            return false;
        }
開發者ID:plamikcho,項目名稱:xbrlpoc,代碼行數:101,代碼來源:ReportBuilder.Charting.cs


注:本文中的ZedGraph.ZedGraphControl.GetImage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。