Graphs
Implement
Add the ServerHostingGraphTrait to your Page and Action class:
Page handler
What backups do you want to load? This shortcut traits allows multiple, separate pages of graphs. Therefore, please specify all of your graphs in the page handler.
Your graph pages should have the graphs prefix so the shortcut trait can recognize them. If you module only has multiple separate graph pages, please pass the technical name of the page after graphs-
The following function in the page handler returns the data of the graph timeseries. The function returns a ServerHostingGraphResponse(), which has...
Array of graphItems
(optional) Array of available time series
The graphItems are an array of ServerHostingGraphItem() which has...
Title of the graph
Array of data series (more about that below)
Array of data labels
(optional) Data suffix
This is an example from Virtualizor, which create multiple graphs:
What are series?
So called series is the actual data which should be displayed in the graph. A graph can either have one or multiple series, depending on how many layers the graph should have.
The graph at the top only has one series, at the bottom has two series. Take a look:
If you have one series, the series property of the GraphItem can be a one dimensional array. If you have multiple series, create a multi dimensional graph. The key of the multi-array will be displayed as series label.
Optimizing series
Dont worry about calculating the average of the series to optimize the amount. Hostware already does that for you! Some integrations would return thousands of data points, which would be too much to display in the browser. Hostware automatically iterates each data point and calculates the average to shrink the overall size to about 200 data points per graph. No need to worry, just return all data points the integration has to offer!