Visually presents data in a linear format.
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',
}
]The q2-chart-area element has one or more properties that support text localization. Those properties are indicated by the localizable badge in the description.
alignChartNamealign-chart-nameControls alignment of the chart name when its visible.
areaColorarea-colorControls area fill color of chart. Accepts variables, hex codes, and CSS color names.
Examples:
element.areaColor = "#ff0000";
element.areaColor = "papayawhip";
element.areaColor = "var(--t-accent-1)";chartNamechart-nameThe title of the chart. We recommend always including this for accessibility purposes.
It is hidden by default, but can be made visible with the showChartName variable.
chartSubTitlechart-sub-titleA subtitile to the chart name. Often used to provide a brief description of what the data represents.
dataAn array of objects that contain the data to be displayed.
dataNamesOverflowdata-names-overflowAllows control of how labels on the name axis will be handled if the text length is wider than the available space. Values will ellipsize if the truncate option is used.
dataNamesWidthdata-names-widthSets width available for labels on the name axis.
It can be used in coordination with dataNamesOverflow to control where the label text breaks or truncates.
formatControls whether values on the value axis are shown as numbers or as currency.
formatModifierformat-modifierCan be used in coordination with the currency format property to control decimal handling.
Accepts Ndec where N is a number. (e.g. 2dec)
gridLinesgrid-linesControls the direction or viibility of grid lines on the chart.
gridPaddinggrid-paddingSets chart padding around the grid. Each value in the object will be interpreted as pixels.
Example:
chart.gridPadding = { left: 10, right: 10, top: 20, bottom: 20 };hideNameAxisLabelshide-name-axis-labelsControls visibility of labels on the name axis.
hideValueAxisLabelshide-value-axis-labelsControls visibility of labels on the value axis.
lineColorline-colorControls color of the data line on the chart. Accepts variables, hex codes, and CSS color names.
Examples:
element.areaColor = "#ff0000";
element.areaColor = "papayawhip";
element.areaColor = "var(--t-accent-1)";offsetDataNamesoffset-data-namesControls the position of text on the names axis by centering the text to the bar at a 45° angle. Can be used when space is limited or with longer name labels.
offsetDataValuesoffset-data-valuesControls the position of text on the values axis by centering the text to the bar at a 45° angle. Can be used when space is limited or with longer name labels.
pointerLineColorpointer-line-colorControls color of vertical pointer on a line chart. Accepts variables, hex codes, and CSS color names.
Examples:
element.areaColor = "#ff0000";
element.areaColor = "papayawhip";
element.areaColor = "var(--t-accent-1)";pointerLineStylepointer-line-styleControls the style of the vertical poiner line.
showChartNameshow-chart-nameControls the visibility of the chart name at the top of the chart.
showDatapointLabelsshow-datapoint-labelsControls the visibility of a value label when a data point is shown on the chart.
showGradientshow-gradientControls making the area fill color into a gradient.
The gradient starts at the top with the areaColor value, and fades to white.
The q2-chart-area element exposes events that can be used to send and receive data from the component based on user interaction.
Emitted when a data point is clicked.
{ index: number; data: IChartData; }The q2-chart-area element exposes methods that can be used to perform various actions on the component.
A method to fire change event on hover on a point.
hoverDataPoint(index: number) => Promise<void>Initial Release
The following CSS variables are available to override the default theme styles of the q2-chart-areacomponent.