Q2 Chart Area
- Updated:
Documentation
Chart Data
The chart data is an array of objects that are set on the data
property of the q2-chart-area
component. Each object must have an id
, name
, and value
property.
Data Structure
type Data = {
id: string;
value: number;
name: string;
};
Example
const chart = document.querySelector("q2-chart-area");
chart.data = [
{
value: 45,
name: 'Sun',
id: 'sunday',
},
{
value: 36,
name: 'Mon',
id: 'monday',
},
{
value: 62,
name: 'Tue',
id: 'tuesday',
},
{
value: 51,
name: 'Wed',
id: 'wednesday',
},
{
value: 104,
name: 'Thu',
id: 'thursday',
},
{
value: 122,
name: 'Fri',
id: 'friday',
},
{
value: 215,
name: 'Sat',
id: 'saturday',
}
]
Attributes API
The q2-chart-area
element has several properties that support text localization. Those properties are indicated by the localizable badge below.
Property | Attribute | Type | Default | Description |
---|---|---|---|---|
alignChartName | alignChartName | string | left | Controls alignment of chart name when visible. Type
Example
|
areaColor | area-color | string | var(--t-primary) | Controls area fill color of chart. Accepts variables, hex. and CSS color names. Examples
|
chartName | chart-name | string |
| Name of the chart. Hidden by default, but can be made visible with the Example
|
dataNamesOverflow | data-names-overflow | string |
| Allows control of how labels on the name axis will be handled if the text length is wider than the available space. Values will ellipsize when the Type
Example
|
dataNamesWidth | data-names-width | number | 50 | Sets width available for labels on the name axis. It can be used in coordination with Example
|
format | format | string | default | Controls whether values on the chart and axis are shown as numbers or as currency. Type
Example
|
formatModifier | format-modifier | string |
| Can be used in coordination with the currency format property to control decimal handling. Accepts Example
|
gridLines | grid-lines | string | horizontal | Controls the direction or visibility of grid lines on the chart. Type
Example
|
hideNameAxisLabels | hide-name-axis-labels | boolean | false | Controls visibility of labels on the name axis. Example
|
hideValueAxisLabels | hide-value-axis-labels | boolean | false | Controls visibility of labels on the value axis. Example
|
lineColor | line-color | string | var(--t-primary) | Controls color of data line on chart. Accepts variables, hex. and CSS color names. Examples
|
offsetDataNames | offset-data-names | boolean | false | Controls position of text on the names axis. When Example
|
offsetDataValues | offset-data-values | boolean | false | Controls position of text on the values axis. When Example
|
pointerLineColor | pointer-line-color | string | var(--t-gray-10) | Controls color of vertical pointer line on chart. Accepts variables, hex. and CSS color names. Examples
Example
|
pointerLineStyle | pointer-line-style | string | solid | Controls style of vertical pointer line on chart. Type
Example
|
showChartName | show-chart-name | boolean | false | Controls visibility of the chart name at the top of the chart. Example
|
showDatapointLabels | show-datapoint-labels | boolean | false | Controls visibility of a value label when a data point is shown on the chart. Example
|
showGradient | show-gradient | boolean | false | Controls making the area fill color, set via Example
|
Events API
The q2-chart-area
element exposes events that can be used to send and receive data from the component.
Event | Details |
---|---|
change | Emitted when the pointer line is aligned with a data point on the chart. Returns index and data item from passed data array. Type
Example
|
The lists below contain references to all the CSS variables available for use in the q2-chart-area
component.
The following CSS variables are available to override the default theme styles of the q2-chart-area
component.
The following CSS variables are used by the q2-chart-area
component and available for theming.