Crea un grafico a barre orizzontali della sequenza temporale con categorie variabili nel tempoCiao a tutti,
Ho una tabella dati con un gruppo di unità che rientrano in diverse categorie per diversi periodi di tempo.Questo set di dati è definito nella tabella dati come qui: Ci sono quattro colonne di dati: (i) identificatore dell'unità (un numero discreto), (ii) data di inizio, (iii) data di fine e (iv) categoria.La colonna delle categorie elenca le categorie in cui rientra l'unità tra l'ora di inizio e quella di fine.Una determinata unità può avere più righe di dati corrispondenti a vari periodi.La tabella dei dati è quella allegata.
Sto cercando di creare un grafico: con l'asse X come tempo, l'asse Y come unità e per ciascuna unità ho bisogno di un grafico a barre orizzontale che mostri la categoria in base a un colore per un determinato periodo di tempo.Allego uno schizzo del grafico per mostrare come dovrebbe apparire il grafico.Lo schizzo serve a guidare la mia idea del grafico.
Ho fatto del mio meglio, ma non sono riuscito a ottenere quello che cercavo.Apprezzo il tuo aiuto su questo.O tramite un generatore di grafici o uno script JSL va bene.Sto usando JMP 16pro.
Esplorazione e visualizzazione dei datiRe: Creare un grafico a barre orizzontali della sequenza temporale con categorie variabili nel tempoEcco l'inizio di uno script che dovresti essere in grado di espandere.Ho eseguito il componente aggiuntivo Gantt, che non consente più intervalli per riga, e ho aggiunto alcuni elementi allo script che fanno ciò che desideri.

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: Creare un grafico a barre orizzontali della sequenza temporale con categorie variabili nel tempoGrazie mille!La tua soluzione è quasi esatta a quello che stavo cercando.Non sono riuscito a comprendere appieno come hai manipolato i dati per ottenere barre di colore diverse per ogni periodo di tempo.Ecco 2 domande dal tuo script:
1. Come posso mostrare la legenda per ogni categoria?in alto a destra? - come i valori A,B,C,D,E ecc nella tabella?È possibile mostrarli anche sopra o all'interno di ciascuna barra colore per ciascuna unità?
2. Vedo spazi rettangolari di colore bianco dietro le barre di colore rosso.Cosa sono e posso non mostrarli nel grafico?
Apprezzo il tuo aiuto per perfezionarlo ulteriormente.Molte grazie!
Re: Creare un grafico a barre orizzontali della sequenza temporale con categorie variabili nel tempoJMP non dispone di un grafico integrato per produrre ciò che desideri.Tuttavia, ha la capacità di modificare i grafici predefiniti per ottenere ciò che desideri.Pertanto, il JSL che ho fornito in precedenza, a cui ho aggiunto ulteriori annotazioni ed elencato di seguito, utilizza la piattaforma di creazione di grafici per creare il modulo generale per il grafico richiesto, ma poi lo script aggiunge grafica ad esso, che fornisce i risultati desiderati, e cancella i risultati originali.Nel mio primo elenco dello script, ho semplicemente modificato le barre prodotte dal GB originale, affinché venissero visualizzate utilizzando il bianco.Tuttavia, l'ho modificato per eliminare semplicemente le barre originali.Le barre originali sono ciò che vedi sullo sfondo del grafico.
Per quanto riguarda la Leggenda, è necessario crearla.Devi accettare questa sfida.Innanzitutto, devi studiare la sceneggiatura attuale.Rea
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;
d la Guida allo scripting e familiarizzare con l'indice degli script.Quindi puoi affrontare la costruzione della leggenda.