時間の経過とともにカテゴリが変化するタイムライン水平棒グラフを作成するこんにちは、みんな、
さまざまな期間のさまざまなカテゴリに分類される多数の単位を含むデータ テーブルがあります。このデータ セットはデータ テーブルで次のように定義されます。データには 4 つの列があります – (i) ユニット識別子 (離散的な数値)、(ii) 開始日、(iii) 終了日、および (iv) カテゴリ。カテゴリ列には、開始時刻と終了時刻の間にユニットが分類されるカテゴリがリストされます。特定のユニットには、さまざまな期間に対応する複数行のデータを含めることができます。データ表は添付の通りです。
X 軸を時間、Y 軸を単位としたグラフを作成しようとしています。単位ごとに、指定された期間のカテゴリを色で示す横棒グラフが必要です。グラフがどのように見えるかを示すグラフのスケッチを添付します。スケッチは私のグラフのアイデアを推進するものです。
最善を尽くしましたが、探していたものには到達できませんでした。ご協力に感謝いたします。グラフビルダーを使用しても、JSL スクリプトを使用しても問題ありません。JMP16プロを使用しています。
データの探索と視覚化Re: 時間の経過とともにカテゴリが変化するタイムライン水平棒グラフを作成するここはスクリプトの始まりであり、これを拡張していきます。1 行に複数の範囲を指定できない Gantt アドオンを実行し、必要なことを実行するいくつかの項目をスクリプトに追加しました。

Names Default To Here( 1 );
dt = Current Data Table();
gb = Graph Builder(
Size( 1121, 626 ),
Show Control Panel( 0 ),
Variables(
X( :Start Date ),
X( :End Date, Position( 1 ) ),
Y( :Unit/*, Order By( :Start Date, Descending, Order Statistic( "Mean" ) )*/ )
),
Elements( Bar( X( 1 ), X( 2 ), Y, Legend( 32 ), Bar Style( "Range" ) ) ),
SendToReport(
Dispatch(
{},
"Start Date",
ScaleBox,
{Min( 3790824458.85 ), Max( 3734876513.055 ), Interval( "Week" ), Inc( 1 ), Minor Ticks( 0 ),
Label Row( Label Orientation( "Angled" ) )}
),
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
32,
Level Name( 0, "Span of Task", Item ID( "Mean(Start Date)..Mean(End Date)", 1 ) ),
Properties( 0, {Fill Color( 2 )}, Item ID( "Mean(Start Date)..Mean(End Date)", 1 ) )
)}
),
Dispatch( {}, "graph title", TextEditBox, {Set Text( "Gantt Chart" )} ),
Dispatch( {}, "X title", TextEditBox, {Set Text( "Date" )} ),
Dispatch( {}, "Y title", TextEditBox, {Set Text( "Tasks" )} )
)
);
// set axis values
offset = (Col Max( :end date ) - Col Min( :end date )) / 20;
gbr = gb << report;
gbr["Graph Builder", AxisBox( 1 )] << Min( Col Min( :start date ) - offset );
gbr["Graph Builder", AxisBox( 1 )] << Max( Col Max( :end date ) + offset );
// Add the display
gbr["Graph Builder", FrameBox( 1 )] << Add Graphics Script(
// Get Category values
Summarize( dt, catGroups = by( :Category ) );
For Each Row(
Fill Color( Contains( catGroups, :category ) + 2 );
Rect( :Start Date, Num( :unit ) - .9, :End Date, Num( :unit ) - 1.1, fill = 1 );
);
)
;
Re: 時間の経過とともにカテゴリが変化するタイムライン水平棒グラフを作成するどうもありがとうございます!あなたの解決策は私が探していたものとほぼ正確です。期間ごとに異なるカラーバーを取得するためにデータをどのように操作するのか、完全には理解できませんでした。スクリプトからの 2 つの質問は次のとおりです。
1. 各カテゴリの凡例を表示するにはどうすればよいですか?右上にある? - 表の値 A、B、C、D、E などのようにしますか?各ユニットの各カラーバーの上または中に表示することもできますか?
2. 赤色のバーの後ろに白色の長方形のスペースが見えます。それらは何ですか?グラフに表示できないのでしょうか?
これをさらに改善するためにご協力をお願いいたします。どうもありがとう!
Re: 時間の経過とともにカテゴリが変化するタイムライン水平棒グラフを作成するJMP には、必要なものを作成するためのチャートが組み込まれていません。ただし、必要なものを得るためにデフォルトのグラフを変更する機能はあります。したがって、以前に提供し、さらに注釈を追加し、以下にリストした JSL は、グラフ ビルダー プラットフォームを使用して、必要なグラフの一般的なフォームを作成しますが、その後、スクリプトによってそれにグラフィックが追加され、望ましい結果が得られます。元の結果を削除します。スクリプトの最初のリストでは、元の GB によって生成されたバーを白で表示するように変更しました。ただし、元のバーを削除するように変更しました。元のバーは、チャートの背景に表示されているものです。
レジェンドに関しては作成する必要があります。あなたはその挑戦に取り組む必要があります。まず、現在のスクリプトを研究する必要があります。レア
Names Default To Here( 1 );
dt = Current Data Table();
// The Graph Builder Platform currently does not have the capability to create the
// needed Gantt like chart. The main issue is that it does not apppear that Graph
// Builder can display more than one Range Bar on a given line. If more than one
// range is input, then Graph Builder averages the start values and then averages
// the end values, and creates a range bar with the averaged values.
// However, Graph Builder does create a display window with the correct Axes etc.
// So the JSL below runs the Graph Builder Platform, and then adds the Gantt like
// bars, and then finally, deletes the original bars that Graph Builder created.
gb = Graph Builder(
Size( 1121, 626 ),
Show Control Panel( 0 ),
Variables(
X( :Start Date ),
X( :End Date, Position( 1 ) ),
Y( :Unit )
),
Elements( Bar( X( 1 ), X( 2 ), Y, Legend( 32 ), Bar Style( "Range" ) ) ),
SendToReport(
Dispatch(
{},
"Start Date",
ScaleBox,
{Min( 3790824458.85 ), Max( 3734876513.055 ), Interval( "Week" ), Inc( 1 ), Minor Ticks( 0 ),
Label Row( Label Orientation( "Angled" ) )}
),
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
32,
Level Name( 0, "Span of Task", Item ID( "Mean(Start Date)..Mean(End Date)", 1 ) )
)}
),
Dispatch( {}, "graph title", TextEditBox, {Set Text( "Gantt Chart" )} ),
Dispatch( {}, "X title", TextEditBox, {Set Text( "Date" )} ),
Dispatch( {}, "Y title", TextEditBox, {Set Text( "Tasks" )} )
)
);
// set axis values of the graph to make sure the complete date range is displayed
// Set the min date displayed to the earliest date - 5% of the overall range
// Set the max date displayed to the latest date + 5% of the overall range
offset = (Col Max( :end date ) - Col Min( :end date )) / 20;
gbr = gb << report;
gbr["Graph Builder", AxisBox( 1 )] << Min( Col Min( :start date ) - offset );
gbr["Graph Builder", AxisBox( 1 )] << Max( Col Max( :end date ) + offset );
// Add the color bars to the display
gbr["Graph Builder", FrameBox( 1 )] << Add Graphics Script(
// Get Category values
Summarize( dt, catGroups = by( :Category ) );
// Loop through each row in the data table and draw a filled rectangle on the
// display
For Each Row(
Fill Color( Contains( catGroups, :category ) + 2 );
Rect( :Start Date, Num( :unit ) - .9, :End Date, Num( :unit ) - 1.1, fill = 1 );
);
);
// Delete the bars created by Graph Builder
theBarSeg = gbr["Graph Builder", FrameBox( 1 )] << find seg( bar seg);
theBarSeg << delete;
「スクリプト ガイド」を参照し、「スクリプト索引」をよく理解してください。そうすれば、伝説の構築に取り組むことができます。