Created:
Oct 1, 2022 01:37 PM
| Last Modified: Jun 11, 2023 4:28 AM(1012 views)
In the exmple below, a data filter is used to pre-select "groups" of data points. These groups are plotted in Graph Builder. The good thing: once the Graph Builder is available, the user can select different entries in the Data Filter and the graph will show up almost instantaneously. The disadvantage: It takes some time for the GraphBuilder to load. The Heatmap Plot takes almost a factor 10 longer than a Points Plot. It's not the number of plotted data points which determines the loading time, it's the total number of data points in the table.
My workaround at the moment: Reduce the number of data points in the table: Use a list box instead of a data filter and use it to generate a subset of the original data set. Then use the subset as input for the GraphBuilder. This solves the speed issue, but there are other drawbacks.
Why does it take so much longer to generate a "Heatmap"? Is there some clever way to increase the speed? At some time, I thought that switching from continuous to ordinal values on the axes reduces the plotting time. But in this example the loading time is quite similar for the 3 "variant" options.
Another thing that I noticed: If I use Today() before and after a Graphbuilder command, the time difference is quite small, much smaller than the waiting time until the Graph Builder Window gets visible. A time measurement with a "new window" around the Graph Builder gives a more realistic value.
Maybe for some reason heatmap gets built without local filter applying and after it is ready local data filter is applied and that's why it is so slow. Maybe you could try to speed it up by first creating graph builder with points and then "changing" points to heatmap
Names Default To Here(1);
groups = 500;
dt = New Table("dt",
Add Rows(10000 * groups),
New Column("X", Numeric, Ordinal, Format("Best", 12), <<Set Each Value(Floor(Modulo((Row() - 1), 10000) / 100))),
New Column("Y", Numeric, Ordinal, Format("Best", 12), <<Set Each Value(Modulo((Row() - 1), 100))),
New Column("group", Numeric, Ordinal, Format("Best", 12), <<Set Each Value(Floor((Row() - 1) / 10000))),
New Column("value", Numeric, "Continuous", Format("Best", 12), <<Set Each Value(Random Normal(0, 0.001) + If(Random Integer(10000) < 5, 1, 0)))
);
Wait(0);
start = HP Time();
gb = Graph Builder(
Variables(X(:X), Y(:Y), Wrap(:group), Color(:value)),
Elements(Points(X, Y, Legend(27))),
Local Data Filter(Add Filter(columns(:group), Where(:group == 0), Display(:group, N Items(15), Find(Set Text(""))))),
SendToReport(
Dispatch({}, "X", ScaleBox, {Min(0), Max(100), Inc(10), Minor Ticks(9)}),
Dispatch({}, "Y", ScaleBox, {Min(0), Max(100), Inc(10), Minor Ticks(9)}),
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
27,
Properties(
-1,
{gradient({Color Theme("Black Body"), Scale Values([0 1]), Range Type("Exact Data Range"), Reverse Gradient(1), Width(12)})},
Item ID("Count", 1)
)
)}
)
)
);
gbb = Report(gb)[Graph Builder Box(1)];
Wait(0);
Show((HP Time() - start) / 1e6);
gbb << Remove Element(1, 1, 1);
gbb << Add Element(1, 1, {Type("Heatmap"), X, Y});
Wait(0);
Show((HP Time() - start) / 1e6);
Write();
Maybe for some reason heatmap gets built without local filter applying and after it is ready local data filter is applied and that's why it is so slow. Maybe you could try to speed it up by first creating graph builder with points and then "changing" points to heatmap
Names Default To Here(1);
groups = 500;
dt = New Table("dt",
Add Rows(10000 * groups),
New Column("X", Numeric, Ordinal, Format("Best", 12), <<Set Each Value(Floor(Modulo((Row() - 1), 10000) / 100))),
New Column("Y", Numeric, Ordinal, Format("Best", 12), <<Set Each Value(Modulo((Row() - 1), 100))),
New Column("group", Numeric, Ordinal, Format("Best", 12), <<Set Each Value(Floor((Row() - 1) / 10000))),
New Column("value", Numeric, "Continuous", Format("Best", 12), <<Set Each Value(Random Normal(0, 0.001) + If(Random Integer(10000) < 5, 1, 0)))
);
Wait(0);
start = HP Time();
gb = Graph Builder(
Variables(X(:X), Y(:Y), Wrap(:group), Color(:value)),
Elements(Points(X, Y, Legend(27))),
Local Data Filter(Add Filter(columns(:group), Where(:group == 0), Display(:group, N Items(15), Find(Set Text(""))))),
SendToReport(
Dispatch({}, "X", ScaleBox, {Min(0), Max(100), Inc(10), Minor Ticks(9)}),
Dispatch({}, "Y", ScaleBox, {Min(0), Max(100), Inc(10), Minor Ticks(9)}),
Dispatch(
{},
"400",
ScaleBox,
{Legend Model(
27,
Properties(
-1,
{gradient({Color Theme("Black Body"), Scale Values([0 1]), Range Type("Exact Data Range"), Reverse Gradient(1), Width(12)})},
Item ID("Count", 1)
)
)}
)
)
);
gbb = Report(gb)[Graph Builder Box(1)];
Wait(0);
Show((HP Time() - start) / 1e6);
gbb << Remove Element(1, 1, 1);
gbb << Add Element(1, 1, {Type("Heatmap"), X, Y});
Wait(0);
Show((HP Time() - start) / 1e6);
Write();