こんにちは、
私はこのような棒グラフを作成しようとしています。
Graph Builder(
Size( 534, 418 ),
Show Control Panel( 0 ),
Variables(
Y( :Name( "A" ) ),
Y( :Name( "B" ), Position( 1 ) ),
Y( :Name( "C" ), Position( 1 ) ),
),
Elements(
Bar(
Y( 1 ),
Y( 2 ),
Y( 3 ),
Legend( 3 ),
Bar Style( "Stacked" )
)
)
)
問題なのは、リストにY変数があり、それは随時変更されるということです(例えば{A、B、D、Test、Bla})。
棒グラフをリスト "l"に応じて自動的に調整したいと思います。例えば:
l = {"A", "B", "D", "Test", "Bla"};
...the script should then be looks like this:
Variables(
Y( :Name( "A" ) ),
Y( :Name( "B" ), Position( 1 ) ),
Y( :Name( "D" ), Position( 1 ) ),
Y( :Name( "Test" ), Position( 1 ) ),
Y( :Name( "Bla" ), Position( 1 ) ),
),
Elements(
Bar(
Y( 1 ),
Y( 2 ),
Y( 3 ),
Y( 4 ),
Y( 5 ),
Legend( 3 ),
Bar Style( "Stacked" )
)
)
)
...
データベースへの問い合わせの後、リストlが変更され、棒グラフを自動的に更新する必要があります。
リストを列に変換してリストエントリの数をループしようとしましたが、1つの棒グラフではなく複数の棒グラフが生成される
for (i=1, i <= Nitems(l), i++,
show (l[i]);
dt << Graph Builder(
Size( 534, 418 ),
Show Control Panel( 0 ),
Variables(
Y( Eval (l[i] ))
),
Elements(
Bar(
Y( i ),
Legend( 3 ),
Bar Style( "Stacked" )
)
)
));
よろしく、
必要な列を積み重ねても、いくつ持っていてもかまいません。 このコードはあなたを始めさせるべきです:
dt1 = New Table( "Untitled 27", Add Rows( 3 ),
New Column( "A", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [6, 5, 4] ) ),
New Column( "B", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [7, 8, 9] ) ),
New Column( "C", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [3, 2, 1] ) )
);
col_list = dt1 << get column names(string);
dt2 = dt1 << Stack(
columns(col_list),
Source Label Column( "Variable" ),
Stacked Data Column( "Value" )
);
dt2 << Graph Builder(
Size( 526, 415 ),
Show Control Panel( 0 ),
Variables( Y( :Value ), Overlay( :Variable ) ),
Elements( Bar( Y, Legend( 8 ), Bar Style( "Stacked" ) ) ),
SendToReport( Dispatch( {}, "X title", TextEditBox, {Set Wrap( 2 )} ) )
)