- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
How do I make start/stop bar charts?
Suppose I have this data:
Step | Start | Stop |
mixer | 0 | 2 |
heater1 | 1 | 12.3 |
injector1 | 4 | 4.5 |
mixer | 6 | 8 |
heater2 | 10.3 | 13 |
injector1 | 12 | 12.5 |
heater1 | 16 | 25.4 |
mixer | 18 | 20 |
heater2 | 23.4 | 30 |
mixer | 24 | 26 |
fan | 24 | 45 |
mixer | 30 | 40 |
... and I want to make this plot (just the bars):
Is that possible with GraphBuilder? (note this image is a mockup with PowerPoint)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do I make start/stop bar charts?
For now I would go with the marker draw expression and possibly add extra points within the "rectangle". Handling the color is a bit annoying as I don't think you can access color within set marker expr function, but you can manage for example with row states, adding color column to your table or picking the color from the marker. There could be some issues with local data filters, so I would probably avoid picking them from marker -> use color column or row states.
I think marker draw expression should be handle the local data filter fine. I haven't tested how well this works when you have large amount of data but there are most likely optimizations which could be done if that becomes an issue. You can also increase the height of bars to 0.4 (or values very close to 0.5) and they shouldn't overlap. In this case I replace middle marker with the rectangle and directly pick the color from row state
Names Default To Here(1);
dt = New Table("Demo",
Add Rows(12),
Compress File When Saved(1),
New Column("Step", Character, "Nominal", Set Values({"mixer", "heater1", "injector1", "mixer", "heater2", "injector1", "heater1", "mixer", "heater2", "mixer", "fan", "mixer"})),
New Column("Start", Numeric, "Continuous", Format("Best", 12), Set Values([0, 1, 4, 6, 10.3, 12, 16, 18, 23.4, 24, 24, 30])),
New Column("Stop", Numeric, "Continuous", Format("Best", 12), Set Values([2, 12.3, 4.5, 8, 13, 12.5, 25.4, 20, 30, 26, 45, 40])),
New Column("G", Character, "Nominal", Set Values({"G1", "G1", "G1", "G1", "G1", "G1", "G2", "G2", "G2", "G2", "G2", "G2"}))
);
dt << New Column("Middle", Numeric, Continuous, Formula(
Mean(:Start, :Stop);
));
Column(dt, "Step") << Set Property("Value Colors", {"fan" = -15113984, "heater1" = -5682409, "heater2" = -40563, "injector1" = -29362, "mixer" = -13983232});
dt << Color or Mark by Column(:Step, Color(1), Marker(0));
gb = dt << Graph Builder(
Size(528, 454),
Show Control Panel(0),
Variables(X(:Start), X(:Stop, Position(1)), X(:Middle, Position(1)), Y(:Step), Color(:Step)),
Elements(Points(X(1), X(2), X(3), Y, Legend(10))),
Local Data Filter(Add Filter(columns(:G))),
SendToReport(
Dispatch({}, "400", ScaleBox,
{Legend Model(
10,
Properties(5, {Marker("Right Arrowhead")}, Item ID("Start", 1)),
Properties(6, {Marker("Left Arrowhead")}, Item ID("Stop", 1))
)}
),
Dispatch({}, "400", LegendBox, {Legend Position({10, [0, 1, 2, 3, 4, 5, 6, -1]})})
)
);
frame = Report(gb)[FrameBox(1)];
seg = (frame << FindSeg(Marker Seg(3)));
seg << Set Marker Draw Expr(
Function({this seg, this row, x, y, size, row state},
Fill Color(Color Of(row state));
Rect(:Start[this row], y + 0.4, :Stop[this row], y - 0.4, 1)
)
);
Also it is also fairly easy easy to crash JMP when you start playing around with these.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do I make start/stop bar charts?
Will get much easier in September
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do I make start/stop bar charts?
In the example that I gave, using Rect() in a << Add Graphics Script, you can click on the Start or Stop data Point and it will select the rows
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How do I make start/stop bar charts?
Here is my approach to creating the graph
Names Default To Here( 1 );
dt = Current Data Table();
gb = Graph Builder(
Size( 534, 456 ),
Show Control Panel( 0 ),
Variables( X( :Start ), X( :Stop, Position( 1 ) ), Y( :Step ), Color( :Step ) ),
Elements( Points( X( 1 ), X( 2 ), Y, Legend( 12 ) ) ),
SendToReport(
Dispatch( {}, "400", ScaleBox,
{Legend Model(
12,
Properties( 5, {Marker( "FilledCircle" )}, Item ID( "Start", 1 ) ),
Properties( 6, {Marker( "FilledCircle" )}, Item ID( "Stop", 1 ) )
)}
),
Dispatch( {}, "graph title", TextEditBox, {Set Text( "Start - Stop Chart" )} )
)
);
// Remove Start and Stop from legend
lgnd = gb << Get Legend Display;
items = lgnd << Get Items;
For Each( {item}, items,
If( item << Get Label == "Start" | item << Get Label == "Stop",
item << Set Visible( 0 )
)
);
// Set default Value Colors if not set
if( isEmpty(dt:step << get property( "value colors" )),
dt:step << set property( "value colors", "" );
);
// Get the colors to use
colors = dt:step << get property( "value colors" );
// Find the labels for the Y Axis
Summarize( dt, levels = by( :step ) );
// Add a Graphics Script to create the bars on the graph
fb = Report( gb )[framebox( 1 )];
fb << add graphics script(
// Get the colors to use
colors = dt:step << get property( "value colors" );
For Each Row(
cpoint = Contains( levels, :step ) - 1;
Fill Color( Num( Word( 3, Char( colors[cpoint + 1] ), " " ) ) );
Rect( :start, cPoint + .4, :stop, cPoint - .4, 1 );
);
);
- « Previous
-
- 1
- 2
- Next »