Chart Block Overview
Adding charts to your Softr app.
Using the Chart block, you can add different types of charts to your Softr app. The charts get the data from data sources.
In the following articles, you can get familiar with different chart layouts that are available. In this article, weโll set up a chart (using a Bar Chart as an example) from the scratch and explain each configuration option.
To start configuring the chart, you first need to link it to a data source to start displaying your data. We are going to use Airtable for that purpose. So, letโs start.
Linking a data source
This part is similar to the List block settings, where you need to connect a data source from the Data tab to get your chart data.
Conditional Filters
Under the Source tab, you also have the Conditional Filters section. Chart Conditional Filters work similar to List conditional filters.
Features
Now, let's see what we have in the Features tab of block's settings.
Title and Subtitle
Here you set a Title and Subtitle for the block.
Type
Next, you have the Type parameter where you select between different chart types. Letโs select the Bar Chart type and move on to configuring our data.
Metrics
Hereโs when we start connecting our data to display it through the chart. Weโre going to use an Airtable table with a database of quarterly incomes and expenses as shown below.
As you can see, each record has a Type field, a Sub-type, and a corresponding value, which is negative in case of expenses.
Letโs say we want to display the sum of incomes and expenses for each month.
For that, we have to define what is our metric. In our case incomes and expenses are stored in Airtable Value field, and the metric should be a sum of those.
In the chart block settings, we need to choose Aggregate function โ Sum, and Field โ Value
The Aggregate function has the following options:
- Sum. Calculates the Sum of all the values for a given category.
- Average. Calculates the average of all the values for a given category.
- Min. Picks the smallest value of all the values of the category.
- Max. Picks the biggest value of all the values of the category.
- Count distinct values. Adds up the number of records that contain a unique value.
- Count all. Adds up the number of records present in a given grouping category.
Groupings
Under Groupings, we need to select the field by which we want our metric to be grouped and shown on the X-axis. In our case it is the Date field.
As a result, we have the following chart that shows the sum of incomes and expenses for each month.
Now, letโs explore each setup option in greater detail.
Time interval
When using date or timestamp fields, you can further group your date-like records by Time interval option:
Letโs say our time interval is set to month:
When we change time interval to a year, metric values get aggregated for each year:
For the day and month time intervals you can choose relevant display formats:
Time interval | Display formats |
Day | YYYY-MM-DD
MM/DD/YYYY
DD/MM/YYYY
MMM DD, YYYY |
Month | YYYY-MM
MM/YYYY
YYYY/MM
MMM YYYY |
Sort by
Next, we have the Sort by dropdown, which will have the following options:
- Categories // A-Z. Order by the Category field values from A to Z.
- Categories // Z-A. Order by the Category field values from Z to A.
- Values // A-Z. Order by the Value field values from A to Z.
- Values // Z-A. Order by the Value field values from Z to A.
Example: If our Group by field is the Date field, and we select โCategories //A-Z,โ weโll have the following ordering: 2019-01, 2019-02, 2019-03, etc. (by alphabetical order), as on the screenshot above.
We can also sort by the Value field. So, if we select โValues // Z-A,โ the month with the highest value will come first, and chart bars will be sorted in ascending order as shown below.
Max categories
Further on, we can select how many categories (i.e. chart bars) should be displayed at most. So, if we set the number to 2, only the first two months will be visible on our chart.
Lastly, we have two toggles. The first lets you Show axis label, which is the Date field in our example.
Include empty cells
The last toggle lets you choose whether you want to include empty cells in the category field. In the example below, weโve removed one of the values in the Date field.
So, with โInclude empty cellsโ toggle turned on, the chart will look as follows.
Sub-grouping
Next, you can enable the Sub-grouping toggle to split up the chart into subcategories. In our data, we have a Sub-type field that indicates the exact type of each income or expense record. So, weโre going to segment our data by this field. The following image shows the resulting bar chart, where each month has four bars corresponding to each Sub-type value.
Lastly, we can choose to Treat empty cells as 0 as well as Show axis label.
Options
Orientation
This option can be used to change the orientation of the chart from horizontal to vertical.
Show zoom
When this option is enabled, the users will be able to zoom into any area of the chart. There's also a Zoom out option that reverts the last zoom in action. See below how that works.
Show tooltip
When this option is enabled, the users will see a tooltip when hovering over each individual bar. The tooltip contains all the information about that specific bar.
Enable download
When this option is enabled, the users will be able to download the chart to their device in .png format.
Data sampling and data freshness
Charts in edit mode
- Data sampling - only a small sample of records is used to generate your charts in edit mode to optimize performance
- Data freshness - data shown in edit mode is real-time.
Charts in preview mode
- Data sampling - all the specified records are being shown, limited by the max number of โrecords per dynamic blockโ specified in your plan.
- Data freshness - data refreshes every 15 minutes.
- Charts include the Information about when the data on the chart was last refreshed.
- App builders can instantly refresh data in preview mode. Instant data refresh is only available in preview mode for testing purposes. Not available to your end users in the live app.
Charts in live mode
- Data sampling - all the specified records are being shown, limited by the max number of โrecords per dynamic blockโ specified in your plan.
- Data freshness - data refreshes every 15 minutes. Charts include the Information about when the data on the chart was last refreshed.
Hiding data freshness information
Sometimes, you might want to hide data freshness information, typically in cases where a chart serves purely as a visual aid for your narration on a website, rather than being the object of analysis.
Hereโs a little custom CSS snippet that will allow you to hide the data freshness information:
<style> div[category='Chart'] span[class*='message'] { display: none!important; } </style>
Last updated on October 2, 2023