Skip to main content

CnChartWidget

ApexCharts wrapper for dashboard and detail page widgets. Supports area, line, bar, pie, donut, and radialBar chart types with Nextcloud-themed defaults. The chart library is a peer dependency — consuming apps must install apexcharts and vue-apexcharts.

Try it

Loading CnChartWidget playground…

Usage

<!-- Area chart with categories -->
<CnChartWidget
type="area"
:series="[{ name: 'Requests', data: [10, 41, 35, 51, 49, 62] }]"
:categories="['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']"
:height="250" />

<!-- Pie chart -->
<CnChartWidget
type="pie"
:series="[44, 55, 13, 33]"
:labels="['Active', 'Pending', 'Closed', 'Draft']" />

<!-- Bar chart with custom options -->
<CnChartWidget
type="bar"
:series="barSeries"
:options="{ plotOptions: { bar: { horizontal: true } } }" />

When ApexCharts is not available a fallback slot or unavailableLabel is shown:

<CnChartWidget type="area" :series="series">
<template #fallback>
<p>Charts require the apexcharts package.</p>
</template>
</CnChartWidget>

When CnDashboardPage resolves a widget definition with type: "chart", it mounts CnChartWidget automatically. Manifest authors do NOT mount this component themselves — declare a chart widget in pages[].config.widgets[] instead:

{
"id": "sla-trend",
"title": "myapp.sla_trend",
"type": "chart",
"props": {
"chartKind": "line",
"series": [{ "name": "SLA %", "data": [82, 88, 91, 93] }],
"categories": ["Q1", "Q2", "Q3", "Q4"],
"options": { "stroke": { "width": 3 } }
}
}

The dispatcher forwards props.chartKind as the apex type and passes through series, categories, labels, options, colors, toolbar, legend, height, width, unavailableLabel. The reserved dataSource field ({ url } OR { register, schema, groupBy, aggregate }) is round-tripped through manifest validators today; the resolver lands in a follow-up cycle.

Props

PropTypeDefaultDescription
typeString'area'Chart type: 'area', 'line', 'bar', 'pie', 'donut', 'radialBar'
seriesArray[]Data series. Format: [{ name, data[] }] for cartesian charts; number[] for pie/donut
categoriesArray[]X-axis category labels (line, area, bar charts)
labelsArray[]Segment labels (pie, donut charts)
heightNumber | String250Chart height in pixels
widthNumber | String'100%'Chart width (defaults to full container width)
optionsObject{}Custom ApexCharts options deep-merged with Nextcloud defaults
colorsArray[]Color palette — defaults to Nextcloud CSS variable colors
toolbarBooleanfalseShow/hide the ApexCharts toolbar (zoom, download)
legendBooleantrueShow/hide the chart legend
unavailableLabelString'Chart library not available'Text shown when ApexCharts is not installed

Slots

SlotDescription
fallbackContent rendered when ApexCharts is not available

Reference (auto-generated)

The tables below are generated from the SFC source via vue-docgen-cli. They reflect what's actually in CnChartWidget.vue and update automatically whenever the component changes.

Props

NameTypeRequiredDefaultDescription
typestring'area'Chart type: area, line, bar, pie, donut, radialBar
seriesArray[]Chart data series. Format depends on chart type. For line/area/bar: [{ name: string, data: number[] }] For pie/donut: number[]
categoriesArray<string>[]X-axis categories (for line, area, bar charts)
labelsArray<string>[]Labels (for pie, donut charts)
heightunion250Chart height in pixels. Use 'auto' for container-based sizing.
widthunion'100%'Chart width. Defaults to '100%' (fills container).
optionsobject\{\}Custom ApexCharts options (deep-merged with defaults).
colorsArray<string>[]Chart color palette. Defaults to Nextcloud theme colors.
toolbarbooleanfalseShow or hide the toolbar (zoom, download, etc.)
legendbooleantrueShow or hide the legend
unavailableLabelstring() =&gt; t('nextcloud-vue', 'Chart library not available')Label shown when ApexCharts is not available
dataSourceobjectnullManifest dataSource block. When set, series / categories / labels are resolved from the GraphQL response via the dataSource selectors and override the static props of the same names. Static props remain the fallback while the query is loading or when no dataSource is configured.

Slots

NameBindingsDescription
fallback