お知らせ

電子会議

ライブラリ

パレット

Delphi FAQ検索

Delphi FAQ一覧

サンプル蔵





FDelphi FAQ
16番会議室「玉石混淆みんなで作るSample蔵」に寄せられたサンプル

"Chartに不等間隔目盛線"

この発言に対し以下のコメントが寄せられています
#01311 TN さん RE:Chartに不等間隔目盛線

TChartは高機能で便利なコンポーネントですが、目盛り線を自由な場所に不等間隔 で入れる機能が無いので作ってみました。 Seriesを派生して作っていますので、Chartに貼り付けて使います。 <使い方> ・下記ユニットをパレットにインストール ・ChartのX軸(BottomAxis)には何も表示させないが、ラベルを表示するための スペースは取る Grid.Visible False Labels True LabelSize 13(適当に) LabelStyle tlNone Visible True Ticks.Visible False MinorTicks.Visible False ・Chartの上に貼り付ける(チャートをダブルクリックして出るプロパティシート  には出てこない) ・Chartの一番最初(実行時の表示は一番下)のシリーズとする ・実行時にAddGridLabelで好きな場所(Xの値と表示文字列で指定)に目盛を  追加していく ・フォントはBottomAxisのLabelsFont、線はGridで表示されます。 --------------------------------------------------------------- unit MySeries; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, TypInfo, TeEngine, TeCanvas, Math, Chart, ExtCtrls, Series; type TXGridSeries = class( TCustomSeries ) protected procedure DrawValue( ValueIndex: integer ); override; public procedure AddGridLabel( ValueIndex: integer; Text: string ); end; procedure Register; implementation procedure Register; begin RegisterComponents('Additional', [ TXGridSeries ]); end; { TXGridSeries } procedure TXGridSeries.AddGridLabel(AXValue: Double; AText: string) ; begin XValue[ Add(0, AText, clTeeColor) ] := AXValue; end; procedure TXGridSeries.DrawValue(ValueIndex: integer); var X0,Y0,Y1,W: integer; X: Double; HAxis: TChartAxis; begin if (csDesigning in ComponentState) then Exit; if ValueIndex >= Count then Exit; W := CalcXSizeValue(1); HAxis := GetHorizAxis; X := XValue[ValueIndex]; with ParentChart.Canvas do begin // Grid line ClipCube( Rect(0,0,ParentChart.ChartRect.Right, ParentChart.ChartRect.Bottom),0,0 ); Pen.Assign( HAxis.Grid ); X0 := CalcXPosValue( X ); X0 := X0 - W div 2; Y0 := ParentChart.ChartRect.Top; Y1 := ParentChart.ChartRect.Bottom; MoveTo( X0, Y1 - 1); LineTo( X0, Y0 ); ClipCube( Rect(0,0,ParentChart.Width, ParentChart.Height),0,0 ); Font.Assign( HAxis.LabelsFont ); Brush.Color := ParentChart.Color; TextOut(X0, Y1+1, XLabel[ValueIndex]); end; end; end. TN(CQJ01721)  Original document by TN 氏 ID:(CQJ01721)



ここにあるドキュメントは NIFTY SERVEの Delphi Users' Forum の16番会議室「玉石混淆みんなで作るSample蔵」に投稿されたサンプルです。これらのサンプルはボーランド株式会社がサポートする公式のものではありません。また、必ずしも動作が検証されているものではありません。これらのサンプルを使用したことに起因するいかなる損害も投稿者、およびフォーラムスタッフはその責めを負いません。使用者のリスクの範疇でご使用下さい。

Copyright 1996-2002 Delphi Users' Forum