Warp Chart demo — charts for Filament you can dig into: drill-down, last year, budget lines, linked charts. Click anything; the data is reset every hour. warpui.com About Warp Chart Docs Ask a question Support
Skip to content

Charts from your models

Give the chart an Eloquent query, say how to group it and what to add up. Warp Chart writes the aggregation, the same for SQLite, MySQL, MariaDB and PostgreSQL. The orders are those of Harbor Supply Co., up to today; “Sales” adds up only the orders that were not cancelled. The month or day that is not over yet is drawn paler (bars) or with a dotted end (lines).

Per month

->perMonth('ordered_at')->sum('total'). There are also perDay(), perWeek(), perQuarter() and perYear().

Note: Try it

Point at a month to read its sales. The last bar is paler: this month is not over yet, and its tooltip says so.

Per day, also the days without orders

->perDay('ordered_at')->count() over the last 30 days. Every day of the period is on the chart, also a day without a single order.

Note: Try it

Harbor Supply Co. is closed on Sundays: the line goes down to 0 there instead of skipping the day.

By the values of a column

->groupBy('status'), over the orders of the last 30 days. The column is cast to an enum, so the names and their order come from the enum.

Note: Try it

Point at a bar to read how many orders have that status. This chart counts all orders of the last 30 days, the cancelled ones too.

The largest three and “Other”

->top(3) keeps the three largest values and adds the rest up as “Other”, which is always gray.

Note: Try it

Point at the “Other” slice: it is the sum of the three categories that are not in the top three.

One series per category

->splitBy('category') makes a series for every value of the column; ->stacked() stacks them.

Note: Try it

Click “Furniture” in the legend to take it out and compare the smaller categories. Point at a month to read every category.

The same color for the same category

->colors(['Paper' => '#eda100', …]) gives a series or a slice its color by name. Every chart of this demo that shows categories uses the same list.

Note: Try it

Paper is yellow here, in the chart above and on every other page. Click “Furniture” in the legend to take it out: the other categories keep their colors.

Export the chart

->exportable() adds an “Export” menu: the chart as an image, its numbers as a CSV file, or printed (the print dialog can save a PDF). Everything is made in the browser from what is on the screen.

Note: Try it

Click “Export” above the chart and choose “Data (CSV)”: your browser downloads a file named “Sales per month” with today’s date. It has one line per month, with the numbers of this year and of the year before. “Image (PNG)” downloads the chart with its heading and legend.

Sales per month

Two measures in one chart

->average('total') and ->max('total'): two measures make two lines. There are also count(), sum() and min().

Note: Try it

Point at a month to read the average order and the largest order of that month.