Chart Line Hds
<sl-chart-line-hds> | SlChartLineHds
Line chart to display overlapping data over time.
Examples
Line Chart with Dark Popover
<sl-chart-line-hds id="hds-line-chart-dark"></sl-chart-line-hds> <script> const lineChart = document.getElementById('hds-line-chart-dark'); lineChart.chartTitle = "Portfolio Performance (Dark)" lineChart.popoverTheme = "dark" lineChart.yLabel = 'Y-axis title name goes here'; lineChart.xLabel = 'X-axis title name goes here'; lineChart.data = data </script>
Light theme
<sl-chart-line-hds id="hds-line-chart"></sl-chart-line-hds> <script> const lineChart = document.getElementById('hds-line-chart'); lineChart.chartTitle = "Portfolio Performance (Light)" lineChart.yLabel = 'Y-axis label'; lineChart.xLabel = 'X-axis label'; lineChart.popoverTheme = "light" lineChart.data = data; </script>
Formatting Y-axis and popover labels
Use the value-type
attribute to specify the value type. Valid values are ‘number’, ‘currency’,
and ‘default’. The default is ‘number’.
<sl-chart-line-hds value-type="percent" id="hds-line-chart-percent"></sl-chart-line-hds> <script> const lineChart = document.getElementById('hds-line-chart-percent'); lineChart.chartTitle = "Percentage values" lineChart.data = percentData; </script> <sl-chart-line-hds value-type="currency" id="hds-line-chart-currency"></sl-chart-line-hds> <script> const lineChart = document.getElementById('hds-line-chart-currency'); lineChart.chartTitle = "Currency values" lineChart.data = data; </script>
Changing chart appearance
Hide legend
<sl-chart-line-hds hide-legend title="Hide legend" id="hds-line-chart-hide-legend"></sl-chart-line-hds> <script> const lineChart = document.getElementById('hds-line-chart-hide-legend'); lineChart.data = data; </script>
Hide grid lines
<sl-chart-line-hds hide-grid-lines title="Hide gridlines" id="hds-line-chart-hide-gridlines"></sl-chart-line-hds> <script> const lineChart = document.getElementById('hds-line-chart-hide-gridlines'); lineChart.data = data; </script>
Show axes
<sl-chart-line-hds show-x-axis title="Show X Axis" id="hds-line-chart-show-x-axis"></sl-chart-line-hds> <script> const lineChart = document.getElementById('hds-line-chart-show-x-axis'); lineChart.data = data; </script> <sl-chart-line-hds show-y-axis title="Show X Axis" id="hds-line-chart-show-y-axis"></sl-chart-line-hds> <script> const lineChart = document.getElementById('hds-line-chart-show-y-axis'); lineChart.data = data; </script>
Next Steps
Task: Scale Jump
Definition: One or more metrics have a disproportionate value to the rest positive or negative
Potential Solution:
- Define the median range for all values
- Define the outliers
- Define the value that needs to be ‘skipped’
- Break the Y scale into 2 objects where the first object ends at the edge of the median range and the second object is defined by the remaining value minus the ‘skipped’ value.
- Break the outlier lines into 2 objects where the first object ends at the edge of the median range and the second object is defined by the remaining value minus the ‘skipped’ value.
This approach assumes the ‘skipped-value’ would be passed to the component manually
[component-metadata:sl-chart-line-hds]
Slots
Name | Description |
---|---|
(default) | The default slot. |
example
|
An example slot. |
Learn more about using slots.
Properties
Name | Description | Reflects | Type | Default |
---|---|---|---|---|
data
|
The data to be displayed in the chart. |
LineData[]
|
[]
|
|
chartTitle
chart-title
|
The title of the chart. |
string
|
''
|
|
height
|
The height of the chart. |
|
number
|
500
|
theme
|
The theme of the chart. |
|
string
|
'default'
|
themeColors
theme-colors
|
The theme colors of the chart. |
array
|
[]
|
|
isResponsive
responsive
|
The responsiveness of the chart. |
boolean
|
false
|
|
xLabel
x-label
|
Label for the X Axis of the chart. |
string
|
''
|
|
yLabel
y-label
|
Label for the Y Axis of the chart. |
string
|
''
|
|
showXAxis
show-x-axis
|
Show the X Axis of the chart. Default is to hide it. |
boolean
|
false
|
|
showYAxis
show-y-axis
|
Show the Y Axis of the chart. Default is to hide it. |
boolean
|
false
|
|
xTicks
x-ticks
|
The number of ticks to show on the X Axis. |
number | null
|
null
|
|
yTicks
y-ticks
|
The number of ticks to show on the Y Axis. |
number | null
|
null
|
|
valueType
value-type
|
The value type of the data. Used to control rendering of Y-axis labels and popup values |
'number' | 'percent' | 'currency'
|
'number'
|
|
valueDecimalPlaces
value-decimal-places
|
The number of decimal places to use on Y axis labels and popup values. If not provided, will default based on the valueType. |
number | null
|
null
|
|
hideLegend
hide-legend
|
Hide legend |
boolean
|
false
|
|
legendPosition
legend-position
|
Legend position |
'top' | 'bottom' | 'left' | 'right'
|
'bottom'
|
|
hideGridLines
hide-grid-lines
|
Hide grid lines |
boolean
|
false
|
|
strokeWidth
stroke-width
|
Set stroke with of graph line values |
number
|
3
|
|
updateComplete |
A read-only promise that resolves when the component has finished updating. |
Learn more about attributes and properties.
Events
Name | React Event | Description | Event Detail |
---|---|---|---|
sl-event-name |
|
Emitted as an example. | - |
Learn more about events.
Custom Properties
Name | Description | Default |
---|---|---|
--example |
An example CSS custom property. |
Learn more about customizing CSS custom properties.
Parts
Name | Description |
---|---|
base |
The component’s base wrapper. |
Learn more about customizing CSS parts.
Dependencies
This component automatically imports the following dependencies.
<sl-example>