Creating line charts
The line chart is used to show trends over time. The dimension is always on the x-axis, and the measures are always on the y-axis.
You can create a line chart on the sheet you are editing.
Do the following:
- In a sheet, click to add a new visualization.
- Under Visualization, select Line chart or Area line chart.
- Click Add and select a field or master dimension for the dimension.
- Click Add and select a field or master measure for the measure.
In a line chart you need at least one dimension and one measure.
You can include up to two dimensions and one measure, or one dimension and up to 15 measures in a line chart.
Dimensions | Measures | Result |
---|---|---|
1 dimension | 1 measure | A simple line chart with a single line. |
2 dimensions | 1 measure | A line chart with the first dimension on the X-axis, and a line for each value of the second dimension. |
1 dimension | up to 15 measures | A line chart with one line for each measure. |
When you have created the line chart, you may want to adjust its appearance and other settings in the properties panel. For information about styling, see Styling the line chart. For information about customizing other aspects of the chart's appearance, see Changing the appearance of a visualization.
Styling the line chart
With Advanced options turned on, you have a number of styling options available in the properties panel. Click Styling under Appearance > Presentation to style the text, background, data point size, and lines at the chart level (for the entire chart). The styling panel contains various sections under the General and Chart tabs. You can reset your styles by clicking next to each section. Clicking Reset all resets styles for all available tabs in the styling panel. Any customization you apply here overrides the styling set in the app theme.
For general information about styling an individual visualization, see Applying custom styling to a visualization.
Customizing the text
You can set the text for the title, subtitle, and footnote under Appearance > General. To hide these elements, turn off Show titles.
The visibility of the different labels on the chart depends on chart-specific settings and label display options. These can be configured in the properties panel.
You can style the text that appears in the chart.
Do the following:
-
Click Advanced options.
-
In the properties panel, expand the Appearance section.
-
Under Appearance > Presentation, click Styling.
-
On the General tab, set the font, emphasis style, font size, and color for the following text elements:
-
Title
-
Subtitle
-
Footnote
-
-
On the Chart tab, set the font, font size, and color for the following text elements:
-
Axis title: Style the titles on the axes.
-
Axis label: Style the labels on the axes.
-
Value label: Style the labels for the measure values that are configured as Lines.
-
Legend title: Style the title of the legend.
-
Legend labels: Style the labels of the individual legend items.
-
Customizing the background
You can customize the background of the chart. The background can be set by color and image.
Do the following:
-
Click Advanced options.
-
In the properties panel, expand the Appearance section.
-
Under Appearance > Presentation, click Styling.
-
On the General tab of the styling panel, you can select a background color (single color or expression). You can also set the background to an image from your media library or from a URL.
Information noteTo add a background image from a URL, the URL's origin needs to be added to the allowlist in your tenant's Content Security Policy. The origin must be added with the following Directive: img-src. This is done by a tenant administrator.
For more information, see Creating a CSP entry.
When using a background color, use the slider to adjust the opacity of the background.
When using a background image, you can adjust image sizing and position.
Customizing the data points at the chart level
You can set the size of the data points. The settings defined here apply to all measures in the chart.
Do the following:
-
Click Advanced options.
-
In the properties panel, expand the Appearance section.
-
Under Appearance > Presentation, click Styling.
-
On the Chart tab of the styling panel, under Data point size, adjust the slider to change the size of the data points in the chart.
Customizing the measure lines at the chart level
You can customize the appearance of the lines in the chart. The settings defined here apply to all measures in the chart.
Do the following:
-
Click Advanced options.
-
In the properties panel, expand the Appearance section.
-
Under Appearance > Presentation, click Styling.
-
Switch to the Chart tab of the styling panel.
-
In the Line options section, adjust the line thickness, line type (solid or dashed), and line curve (linear or monotone).
Styling each measure individually
Each measure line in the chart can be styled with separate settings. For each measure, you can customize the data point size, line thickness, line type, and line curve.
Do the following:
-
Click Advanced options.
-
In the properties panel, expand the Data section.
-
Click the measure you want to customize.
-
Under Styling, click Add.
-
Adjust the data point size, line thickness, line type (solid or dashed), and line curve (linear or monotone).
Repeat these steps for each individual measure you need to customize separately from the app theme or chart-level style settings.
Customizing the border and shadow
You can customize the border and shadow of the chart.
Do the following:
-
Click Advanced options.
-
In the properties panel, expand the Appearance section.
-
Under Appearance > Presentation, click Styling.
-
On the General tab of the styling panel, under Border, adjust the Outline size to increase or decrease the border lines around the chart.
-
Select a color for the border.
-
Adjust the Corner radius to control the roundness of the border.
-
Under Shadow in the General tab, select a shadow size and color. Select None to remove the shadow.
Showing or hiding dimensions and measures depending on a condition
You can show or hide a dimension or measure depending on if a condition is true or false. This is known as a show condition, and is entered as an expression. The dimension or measure is only shown if the expression is evaluated as true. If this field is empty, the dimension or measure is always shown. Expand the dimension or measure in the Data section of the properties panel and enter an expression under Show dimension if or Show measure if.
Let's say you have a dataset with the fields Sales, Quarter, Year, and Order Number, among others. You could configure your chart so that sales are displayed along a time-based dimension for yearly aggregations. You can add a second dimension for quarterly aggregations but only organize the data by this dimension if the total number of orders received by your company has reached a target goal of 100,000.
Do the following:
-
In edit mode, turn on the advanced options.
-
Drag a line chart from the assets panel onto the sheet.
-
Add Quarter as a dimension.
-
Add Year as a second dimension from the properties panel.
Each distinct year in the data model becomes a separate line in the chart.
-
Add Sum(Sales) as a measure.
-
In the properties panel, expand the dimension Manager. Under Show dimension if, add the following expression:
Count([Order Number])>100000
If your data contains 50,000 order records, the chart will not organize sales by quarter, since the expression is evaluated as false. If the data contains 100,000 or more order records, sales will be organized by both Year and Quarter.
Adding trend lines
You can add trend lines to the chart. Use trend lines to visualize how data changes over time.
For more information about trend lines, see Trend lines.
Do the following:
-
In sheet edit mode, click Advanced options.
-
In the properties panel, expand the Data section.
-
Under Measures, expand the measure for which you are adding trend lines.
-
Under Trend lines, click Add trend line.
-
Define the Label and Type for the trend line.
-
Use the Colors slider to define Custom or Auto coloring.
-
Use the checkbox to toggle a Dashed appearance on or off.