Dustin and Gotham Site

トップ | DusGraphの使い方 | 掲示板 | リンク | このサイトについて | 更新履歴


※サンプルコードに”System.IO”の参照が抜けていたので追加しました。


使い方
シンプルなグラフのサンプルコード
積層棒グラフのサンプルコード
円グラフのサンプルコード
バブルチャートのサンプルコード
スプライン曲線グラフのサンプルコード
OnDrawBackground、OnDrawForeground


サンプルソースファイルのダウンロード




使い方

当クラスをプロジェクトに追加してください。
ダウンロードしたdllへの参照を設定するか、ソースファイルを追加してください。

当クラス群は、下図の階層構造になっています。



まずは、グラフ描画クラスのインスタンスを作成します。
このインスタンスが階層のルートです。
using  System.IO;
using  System.Drawing;
using  System.Drawing.Imaging;
using  System.Drawing.Drawing2D;
using  Dustin.Utils;
using  Dustin.Drawing;
using  Dustin.Graph;


// グラフ描画クラスのインスタンスを作成(引数はグラフの幅・高さ)
IGraphPainter  graph = DusGraph.CreateGraph( 600, 400 );
グラフのタイトルを設定します。
// タイトル文字列
graph.Title.Text           = "テスト グラフ";
// フォント
graph.Title.Font           = new Font( graph.Title.Font.FontFamily, 12, FontStyle.Bold );
// ブラシ
graph.Title.Brush          = Brushes.White;
// 背景ブラシ
graph.Title.BackBrush      = Brushes.DarkGray;
// サイズ
graph.Title.Size           = new SizeF( 140, 30 );
// 位置
graph.Title.Location       = new PointF( graph.Width / 2.0f - graph.Title.Size.Width / 2.0f, 5f );
// 横方向の配置(この例では中央寄せ)
graph.Title.StringFormat.Alignment     = StringAlignment.Center;
// 縦方向の配置(この例では中央寄せ)
graph.Title.StringFormat.LineAlignment = StringAlignment.Center;
// 枠線の表示
graph.Title.Border.Visible = true;
// 枠線のペン
graph.Title.Border.Pen     = new Pen( Color.Purple, 2 );
// 枠線の角の丸み半径
graph.Title.CornerRadius   = 8;
// 影の表示
graph.Title.Shadow.Visible = true;
// 影の幅
graph.Title.Shadow.Width   = 5;
// タイトルの表示
graph.Title.Visible        = true;
グラフの背景、マージンを設定します。
// グラフの背景ブラシ
graph.BackBrush              = Brushes.Gray;
// グラフの枠線のペン
graph.Border.Pen             = Pens.Gray;
// プロット領域の背景ブラシ
graph.PlotArea.BackBrush     = Brushes.White;
// プロット領域の枠線のペン
graph.PlotArea.Border.Pen    = Pens.Black;
// プロット領域の左マージン
graph.PlotArea.Margin.Left   = 40;
// プロット領域の右マージン
graph.PlotArea.Margin.Right  = 20;
// プロット領域の上マージン
graph.PlotArea.Margin.Top    = 20;
// プロット領域の下マージン
graph.PlotArea.Margin.Bottom = 40;
// アンチエイリアス設定
graph.SmoothingMode          = SmoothingMode.AntiAlias;
Y軸を設定します。
IAxis  axis;

// グラフのデフォルトY軸(左軸)
axis = graph.YAxis;
// 軸へのアクセスはこのようにもできます。
axis = graph.Axis.Left;
// スケールの最小値
axis.Scale.Min =  0;
// スケールの最大値
axis.Scale.Max = 12;
// 目盛ラベルの印字フォーマット
axis.Ticks.Labels.LabelFormat = "0.0";
// 目盛ラベルの印字間隔
axis.Ticks.Labels.Interval    = 2;
// 主目盛マークの長さ
axis.Ticks.Major.LineLength   = 5;
// 主目盛マークのペン
axis.Ticks.Major.Pen          = new Pen( Color.Red, 1 );
// 主目盛マークの間隔
axis.Ticks.Major.Interval     = 1;
// 最初の主目盛マークを表示しないか
axis.Ticks.Major.SuppressFirst = true;
// 最後の主目盛マークを表示しないか
axis.Ticks.Major.SuppressLast  = true;
// 目盛の配置(この例ではプロット領域の左)
axis.Ticks.Side               = DusGraph.eTickSide.Left;
// 目盛マークの描画方向(この例ではプロット領域の内側方向)
axis.Ticks.Direction          = DusGraph.eTickDirection.Inside;
// 主グリッド線を描画するか
axis.Grid.Major.Visible       = true;
// 主グリッド線の間隔
axis.Grid.Major.Interval      = 1.0;
// 最初の主グリッド線を表示しないか
axis.Grid.Major.SuppressFirst = true;
// 最後の主グリッド線を表示しないか
axis.Grid.Major.SuppressLast  = true;
// 主グリッド線のペン
axis.Grid.Major.Pen           = new Pen( Color.FromArgb(100, 100, 100), 1 );
axis.Grid.Major.Pen.DashPattern = new float[] { 4, 3 };
// 副グリッド線を描画するか
axis.Grid.Minor.Visible       = true;
// 副グリッド線の間隔
axis.Grid.Minor.Interval      = 0.5;
// 最初の副グリッド線を表示しないか
axis.Grid.Minor.SuppressFirst = true;
// 最後の副グリッド線を表示しないか
axis.Grid.Minor.SuppressLast  = true;
// 副グリッド線のペン
axis.Grid.Minor.Pen           = Pens.LightGray;
同様にX軸を設定します。
// グラフのデフォルトX軸(下軸)
axis = graph.XAxis;
// 軸へのアクセスはこのようにもできます。
axis = graph.Axis.Bottom;
// スケールの最小値
axis.Scale.Min =  0;
// スケールの最大値
axis.Scale.Max = 10;
// 目盛ラベルの印字フォーマット
axis.Ticks.Labels.LabelFormat = "0.0";
// 目盛ラベルの印字間隔
axis.Ticks.Labels.Interval    = 2;
系統データを作成します。
ISeriesXYPlot  sr;

// 折れ線タイプの系統を作成
sr = graph.CreateSeries( DusGraph.ePlotType.Line ).asXYPlot;
// 関連付けるY軸を明示的に設定(デフォルトはgraph.YAxisと同じ左軸)
sr.YAxis = graph.Axis.Left;
// マークを表示するか
sr.Mark.Visible = true;
// マークのタイプ
sr.Mark.Type    = DusGraph.ePlotMarkType.Circle;
// マークのブラシ
sr.Mark.Brush   = new SolidBrush( Color.FromArgb( 255, 200, 200 ) );
// 折れ線の描画用のペン
sr.asLine.Pen = new Pen( Color.FromArgb( 180, 128, 10, 10 ), 2 );
sr.asLine.Pen.DashStyle = DashStyle.Dash;

// プロットするデータを追加します。
// new ST_PlotPoint(X値, Y値)
sr.Data.Add( new ST_PlotPoint( 0, 0.3 ) );
sr.Data.Add( new ST_PlotPoint( 1, 1.0 ) );
sr.Data.Add( new ST_PlotPoint( 2, 2.4 ) );
sr.Data.Add( new ST_PlotPoint( 3, 4.0 ) );

// 作成した系統データを登録します。
graph.Series.Add( sr );
必要な設定が終わったら、内部イメージバッファへのグラフ描画を指示します。
graph.Draw();
内部イメージバッファへのアクセスは下記のようにします。
// グラフィックハンドルを取得します。
using( Graphics  g = graph.CreateGraphics() ) {
	// グラフィック描画
	g.DrawLine( Pens.Red, 10, 10, 20, 20 );
}

// graph.Imageプロパティで直接アクセスすることもできます。
Response.ContentType = "image/png";
MemoryStream  o = new MemoryStream();
graph.Image.Save( o, ImageFormat.Png );
o.WriteTo( Response.OutputStream );
最後にリソースの破棄を指示します。
graph.Dispose();
ページ上部へ


シンプルなグラフのサンプルコード

下図のグラフを描画するサンプルコードを掲載します(ASP.NET)。


<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="Dustin.Utils" %>
<%@ Import Namespace="Dustin.Drawing" %>
<%@ Import Namespace="Dustin.Graph" %>
<script runat="server">
</script>
<%
	// グラフ描画クラスのインスタンスを作成
	IGraphPainter  graph = DusGraph.CreateGraph(300, 200);
	// プロット領域のマージンを設定
	graph.PlotArea.Margin.Left   = 30;
	graph.PlotArea.Margin.Right  = 10;
	graph.PlotArea.Margin.Top    = 10;
	graph.PlotArea.Margin.Bottom = 20;


	IAxis  axis;
	// Y軸のスケールを設定
	axis = graph.YAxis;
	axis.Scale.Min = -3;
	axis.Scale.Max = 10;
	axis.Scale.Base=  0;
	axis.Grid.Major.Visible  = true;
	axis.Grid.Major.Interval = 1;
	// X軸のスケールを設定
	axis = graph.XAxis;
	axis.Scale.Min =  0;
	axis.Scale.Max =  5;
	axis.Grid.Major.Visible  = true;
	axis.Grid.Major.Interval = 1;


	ISeriesXYPlot  sr;

	// 棒タイプの系統を作成
	sr = graph.CreateSeries( DusGraph.ePlotType.Bar ).asXYPlot;
	sr.Data.Add( new ST_PlotPoint(0, 5) );
	sr.Data.Add( new ST_PlotPoint(1, -2) );
	sr.Data.Add( new ST_PlotPoint(2, 8) );
	sr.Data.Add( new ST_PlotPoint(3, 6) );
	sr.Data.Add( new ST_PlotPoint(4, -1.2) );
	sr.Data.Add( new ST_PlotPoint(5, 5.5) );
	sr.asBar.Brush      = Brushes.Chocolate;
	sr.asBar.Border.Pen = Pens.Brown;
	sr.asBar.BarWidth   = 8;
	graph.Series.Add( sr );
	
	// 折れ線タイプの系統を作成
	sr = graph.CreateSeries( DusGraph.ePlotType.Line ).asXYPlot;
	sr.Data.Add( new ST_PlotPoint(0, 1) );
	sr.Data.Add( new ST_PlotPoint(1, 0.5) );
	sr.Data.Add( new ST_PlotPoint(2, 2) );
	sr.Data.Add( new ST_PlotPoint(3, 2.5) );
	sr.Data.Add( new ST_PlotPoint(4, 3.6) );
	sr.Data.Add( new ST_PlotPoint(5, 4) );
	sr.Mark.Visible    = true;
	sr.Mark.Type       = DusGraph.ePlotMarkType.Star;
	sr.Mark.Brush      = Brushes.LightBlue;
	sr.Mark.Width      = 10;
	sr.Mark.Height     = 10;
	sr.Mark.Border.Pen = Pens.Blue;
	sr.asLine.Pen      = Pens.Blue;
	graph.Series.Add( sr );
	
	// X軸のラベルを設定
	ITickLabels  labels = graph.Axis.Bottom.Ticks.Labels;
	System.Collections.Generic.IList<ST_TickLabelPoint>  labelPoints = labels.Points;
	for( int  i = 0; i <= 10; i++ ) {
		labelPoints.Add( new ST_TickLabelPoint((double)i, i.ToString("00") + ".") );
	}
	
	// 内部イメージバッファへの描画を指示する
	graph.Draw();
	
	// ブラウザへのレスポンスとして出力する
	Response.ContentType = "image/png";
	MemoryStream  o = new MemoryStream();
	graph.Image.Save( o, ImageFormat.Png );
	o.WriteTo( Response.OutputStream );
	
	graph.Dispose();
%>
ページ上部へ


積層棒グラフのサンプルコード

下図のグラフを描画するサンプルコードを掲載します(ASP.NET)。


<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="Dustin.Utils" %>
<%@ Import Namespace="Dustin.Drawing" %>
<%@ Import Namespace="Dustin.Graph" %>
<script runat="server">
</script>
<%
	// グラフ描画クラスのインスタンスを作成
	IGraphPainter  graph = DusGraph.CreateGraph(280, 200);
	// プロット領域のマージンを設定
	graph.PlotArea.Margin.Left   = 30;
	graph.PlotArea.Margin.Right  =100;
	graph.PlotArea.Margin.Top    = 10;
	graph.PlotArea.Margin.Bottom = 20;
	graph.PlotArea.InnerMargin.Left  = 20;
	graph.PlotArea.InnerMargin.Right = 20;
	// 凡例ボックスを設定
	graph.Legend.Visible  = true;
	graph.Legend.Location = new PointF( 190, 5 );
	graph.Legend.Size     = new SizeF( 80, 80 );


	IAxis  axis;
	// Y軸のスケールを設定
	axis = graph.YAxis;
	axis.Scale.Min =  0;
	axis.Scale.Max =  7;
	axis.Grid.Major.Visible  = true;
	axis.Grid.Major.Interval = 1;
	// X軸のスケールを設定
	axis = graph.XAxis;
	axis.Scale.Min =  0;
	axis.Scale.Max =  2;


	ISeriesStackedBarPlot  sr;

	// 積層棒タイプの系統を作成
	sr = graph.CreateSeries( DusGraph.ePlotType.StackedBar ).asStackedBar;
	// new TStackedBarPoint( X軸スケール値, Y軸スケール基準値, Y軸スケール値の配列 )
	sr.Data.Add( new TStackedBarPoint(0, 0, new double[] {1, 2, 3}) );
	sr.Data.Add( new TStackedBarPoint(1, 0, new double[] {0.5, 2, 0.5}) );
	sr.Data.Add( new TStackedBarPoint(2, 0, new double[] {2, 0.5, 2}) );
	sr.Brushes    = new Brush[]  { Brushes.Pink, Brushes.SkyBlue, Brushes.Chocolate };
	sr.Titles     = new String[] { "ピンク",     "ブルー",        "チョコ"          };
	sr.Pen        = new Pen( Color.Brown, 1 );
	sr.Pen.DashPattern = new float[] { 4, 3 };
	sr.Border.Pen = Pens.Brown;
	sr.BarWidth   = 12;
	graph.Series.Add( sr );
	
	// 内部イメージバッファへの描画を指示する
	graph.Draw();
	
	// ブラウザへのレスポンスとして出力する
	Response.ContentType = "image/png";
	MemoryStream  o = new MemoryStream();
	graph.Image.Save( o, ImageFormat.Png );
	o.WriteTo( Response.OutputStream );
	
	graph.Dispose();
%>
ページ上部へ


円グラフのサンプルコード

下図のグラフを描画するサンプルコードを掲載します(ASP.NET)。


<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="Dustin.Drawing" %>
<%@ Import Namespace="Dustin.Chart.PieChart" %>
<script runat="server">
</script>
<%
	using( Bitmap  img = new Bitmap(250, 140) )
	using( Graphics  g = Graphics.FromImage(img) ) {
		// イメージバッファを白で塗りつぶす
		g.Clear( Color.White );
		
		// 円グラフ描画クラスのインスタンスを作成
		TPieChart  pie = new TPieChart();
		// 円グラフのサイズ
		pie.Size       = new SizeF( 120, 120 );
		// 描画開始角度(右が0°で時計回りにプラス)
		pie.StartAngle = -90f;
		
		// データを追加する
		// new TPieData( 値, タイトル文字列, 塗り潰しブラシ )
		pie.Data.Add( new TPieData(50f, "ピンク",   Brushes.Pink) );
		pie.Data.Add( new TPieData(20f, "グリーン", Brushes.LightGreen) );
		pie.Data.Add( new TPieData(30f, "チョコ",   Brushes.Chocolate) );
		
		// 円の中心から切り離されたデータを作成する
		TPieData  pieData = new TPieData( 20f, "マゼンタ", Brushes.Magenta );
		pieData.OffsetR = 11;
		pie.Data.Add( pieData );
		
		// イメージバッファに描画する
		pie.Draw( g, new PointF(20, 15) );


		// 凡例ボックス描画クラスのインスタンスを作成
		TLegendBox  legend = new TLegendBox();
		legend.Size                  = new SizeF( 80, 80 );
		legend.ItemArea.Items        = pie.GetLegendItems();
		legend.ItemArea.BaseLocation = new PointF( 5, 5 );
		legend.Title.Visible         = false;
		// イメージバッファに描画する
		legend.Draw( g, new PointF(150, 5) );


		// ブラウザへのレスポンスとして出力する
		Response.ContentType = "image/png";
		MemoryStream  o = new MemoryStream();
		img.Save( o, ImageFormat.Png );
		o.WriteTo( Response.OutputStream );
	}
%>
円グラフ描画クラスTPieChartは、IGraphPainterのクラス階層に属しておらず、
単独のインスタンスとして扱います。
// 円グラフ描画クラスのインスタンスを作成
TPieChart  pie = new TPieChart();
データを追加した後、TPieChartのDraw()メソッドにグラフィックハンドルを渡して呼び出すと、
イメージバッファに円グラフを描画します。
// 第2引数のPointFは描画位置
pie.Draw( g, new PointF(20, 15) );
凡例が必要な場合、TLegendBoxのインスタンスを作成します。
// 凡例ボックス描画クラスのインスタンスを作成
TLegendBox  legend = new TLegendBox();
TLegendBox.ItemArea.Itemsプロパティに、TPieChart.GetLegendItems()メソッドの戻り値を設定します。
これで円グラフのデータの凡例が設定されます。
legend.ItemArea.Items = pie.GetLegendItems();
TLegendBoxのDraw()メソッドにグラフィックハンドルを渡して呼び出すと、
イメージバッファに凡例ボックスを描画します。
// 第2引数のPointFは描画位置
legend.Draw( g, new PointF(150, 5) );

円グラフを、IGraphPainterのグラフと同じ画像に描画したい場合は、
IGraphPainter.Shapes.Add()メソッドにTPieChartのインスタンスを渡して呼び出します。
後は、IGraphPainterのDraw()メソッドで円グラフも同時に描画されます。
円グラフの描画位置はTPieChart.Locationプロパティで事前に設定します。
IGraphPainter  graph = DusGraph.CreateGraph();

pie.Location = new PointF( 20, 10 );
graph.Shapes.Add( pie );
ページ上部へ


バブルチャートのサンプルコード

下図のグラフを描画するサンプルコードを掲載します(ASP.NET)。


<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="Dustin.Utils" %>
<%@ Import Namespace="Dustin.Drawing" %>
<%@ Import Namespace="Dustin.Graph" %>
<script runat="server">
</script>
<%
	// グラフ描画クラスのインスタンスを作成
	IGraphPainter  graph = DusGraph.CreateGraph(300, 200);
	// プロット領域のマージンを設定
	graph.PlotArea.Margin.Left   = 20;
	graph.PlotArea.Margin.Right  = 10;
	graph.PlotArea.Margin.Top    = 20;
	graph.PlotArea.Margin.Bottom = 10;


	IAxis  axis;
	// Y軸のスケールを設定
	axis = graph.YAxis;
	axis.Scale.Min =  5;
	axis.Scale.Max =  0;
	axis.Scale.Base=  0;
	axis.Grid.Major.Visible  = true;
	axis.Grid.Major.Interval = 1;
	// X軸のスケールを設定
	axis = graph.XAxis;
	axis.Scale.Min =  0;
	axis.Scale.Max =  5;
	axis.Grid.Major.Visible  = true;
	axis.Grid.Major.Interval = 1;
	// 目盛は上側に配置する
	axis.Ticks.Side          = DusGraph.eTickSide.Top;
	axis.Ticks.Labels.Margin = 15;


	// バブルチャートタイプの系統を作成
	ISeriesBubbleChart  sr = graph.CreateSeries( DusGraph.ePlotType.BubbleChart ).asBubbleChart;
	// new TBubblePoint( X軸スケール値, Y軸スケール値, バブルの半径(ピクセル), 塗り潰しブラシ )
	sr.Data.Add( new TBubblePoint(  3, 1,  8, Brushes.Pink    ) );
	sr.Data.Add( new TBubblePoint(4.5, 2, 18, Brushes.Magenta ) );
	sr.Data.Add( new TBubblePoint(1.2, 4, 24, Brushes.SeaGreen) );
	graph.Series.Add( sr );
	
	// 内部イメージバッファへの描画を指示する
	graph.Draw();
	
	// ブラウザへのレスポンスとして出力する
	Response.ContentType = "image/png";
	MemoryStream  o = new MemoryStream();
	graph.Image.Save( o, ImageFormat.Png );
	o.WriteTo( Response.OutputStream );
	
	graph.Dispose();
%>
ページ上部へ


スプライン曲線グラフのサンプルコード

下図のグラフを描画するサンプルコードを掲載します(ASP.NET)。


<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="Dustin.Utils" %>
<%@ Import Namespace="Dustin.Drawing" %>
<%@ Import Namespace="Dustin.Graph" %>
<script runat="server">
</script>
<%
	// グラフ描画クラスのインスタンスを作成
	IGraphPainter  graph = DusGraph.CreateGraph(300, 200);
	// プロット領域のマージンを設定
	graph.PlotArea.Margin.Left   = 30;
	graph.PlotArea.Margin.Right  = 10;
	graph.PlotArea.Margin.Top    = 10;
	graph.PlotArea.Margin.Bottom = 20;


	IAxis  axis;
	// Y軸のスケールを設定
	axis = graph.YAxis;
	axis.Scale.Min = -3;
	axis.Scale.Max =  5;
	axis.Scale.Base=  0;
	axis.Grid.Major.Visible  = true;
	axis.Grid.Major.Interval = 1;
	// X軸のスケールを設定
	axis = graph.XAxis;
	axis.Scale.Min =  0;
	axis.Scale.Max =  5;
	axis.Grid.Major.Visible  = true;
	axis.Grid.Major.Interval = 1;

	// スプライン曲線タイプの系統を作成
	ISeriesCurvePlot  sr = graph.CreateSeries( DusGraph.ePlotType.Curve ).asCurve;
	sr.Data.Add( new ST_PlotPoint(0,   2) );
	sr.Data.Add( new ST_PlotPoint(1, 1.5) );
	sr.Data.Add( new ST_PlotPoint(2,  -2) );
	sr.Data.Add( new ST_PlotPoint(3,   1) );
	sr.Data.Add( new ST_PlotPoint(4, 3.6) );
	sr.Data.Add( new ST_PlotPoint(5,   3) );
	// プロットマーク
	sr.Mark.Visible    = true;
	sr.Mark.Type       = DusGraph.ePlotMarkType.Star;
	sr.Mark.Brush      = Brushes.LightBlue;
	sr.Mark.Width      = 10;
	sr.Mark.Height     = 10;
	sr.Mark.Border.Pen = Pens.Blue;
	// 線を描画するペン
	sr.Pen             = Pens.Blue;
	// 曲線のテンションを0.0f〜1.0fの範囲内で指定。デフォルトは0.7f
	// この値はGraphics.DrawCurve()の引数に使用します。
	sr.Tension         = 0.7f;
	// HasWallをtrueにすると背景を描画します。
	sr.HasWall         = true;
	sr.WallBrush       = Brushes.SkyBlue;
	graph.Series.Add( sr );
	
	// 内部イメージバッファへの描画を指示する
	graph.Draw();
	
	// ブラウザへのレスポンスとして出力する
	Response.ContentType = "image/png";
	MemoryStream  o = new MemoryStream();
	graph.Image.Save( o, ImageFormat.Png );
	o.WriteTo( Response.OutputStream );
	
	graph.Dispose();
%>
ページ上部へ


OnDrawBackground、OnDrawForeground

IGraphPainter.OnDrawBackgroundイベントは、背景の描画時に発生します。
IGraphPainter.OnDrawForegroundイベントは、前景の描画時に発生します。

例えばグラフの背景に画像を描画する場合は下記のようにします。
graph.OnDrawBackground += delegate( Object  sender, TDrawEventArgs  e ) {
		// ここで背景画像を描画する
		String  fpath = Server.MapPath( "./picture.png" );
		using( System.Drawing.Image  img = System.Drawing.Image.FromFile(fpath) ) {
			e.Graphics.DrawImage( img, new Point(0, 0) );
		}
	};

ページ上部へ


ページ上部へ