Select the types of activity you want to include in your feed.
[READ-ONLY] Mirror of https://github.com/graphieros/vue-data-ui. An open source user-empowering data visualization Vue 3 components library for eloquent data storytelling
vue-data-ui.graphieros.com/
···11+# Vue Data UI
22+33+> VueDataUI is a Vue 3 data visualization library providing numerous chart components (pie/donut, bar, line, radar, etc.), as well as tables and rating components. This guide offers ready-to-use examples and best practices for integrating VueDataUI into your Vue application. The content is optimized for AI code editors (GitHub Copilot, Cursor, etc.) to suggest correct usage patterns.
44+55+Important notes:
66+- This library is *not* compatible with Vue2. It is to be used with Vue3.
77+- **Import and CSS:** Always import the required VueDataUI component and ensure you include the library's CSS.
88+- **Reactive Data:** Use Vue's reactivity (`ref` or `computed`) to manage your `dataset` and `config` objects.
99+- **Component Customization:** Use the config object to customize appearance (colors, legends, chart dimensions, etc.) based on your specific needs.
1010+- **CLI Utilization:** Leverage `vue-data-ui-cli` for quick scaffolding of new components, ensuring proper structure and reducing setup errors.
1111+- **AI Integration:** With these clear examples, AI code editors should suggest correct imports, prop bindings, and data structures, making it easier to build interactive charts with VueDataUI.
1212+1313+## Docs
1414+1515+- [README](https://github.com/graphieros/vue-data-ui/blob/master/README.md): Readme file of the vue-data-ui library
1616+- [Documentation]https://vue-data-ui.graphieros.com/: Official documentation website for the vue-data-ui library
1717+1818+## Getting Started with VueDataUI
1919+2020+To begin, install the library and include its stylesheet:
2121+2222+ npm install vue-data-ui
2323+2424+In your main entry file (e.g., main.js or main.ts), import the CSS and optionally register components globally:
2525+2626+ import { createApp } from 'vue';
2727+ import App from './App.vue';
2828+ import 'vue-data-ui/style.css'; // Include VueDataUI styles
2929+3030+ // Example: register a component globally (optional)
3131+ import { VueUiXy } from 'vue-data-ui';
3232+ const app = createApp(App);
3333+ app.component('VueUiXy', VueUiXy);
3434+3535+ app.mount('#app');
3636+3737+You can also import components locally within Vue single-file components (see examples below). VueDataUI offers a **universal component** `<VueDataUi>` that can load any chart dynamically. For example:
3838+3939+ <template>
4040+ <!-- Using the universal component to load a Donut chart -->
4141+ <VueDataUi component="VueUiDonut" :dataset="dataset" :config="config" />
4242+ </template>
4343+4444+ <script setup>
4545+ import { ref } from 'vue';
4646+ import { VueDataUi } from 'vue-data-ui'; // universal component
4747+ import 'vue-data-ui/style.css'; // ensure styles are imported
4848+4949+ const dataset = ref([ /* ... data ... */ ]);
5050+ const config = ref({ /* ... config ... */ });
5151+ </script>
5252+5353+Using `VueDataUi` will lazy-load only the specified chart component.
5454+5555+## XY Chart Example
5656+5757+For line (or area) charts, bar chart, or combined charts, use the `VueUiXy` component. The dataset is an array of data points with the following datastructure:
5858+5959+ type VueUiXyDatasetItem = {
6060+ name: string;
6161+ series: number[];
6262+ type: "bar" | "line" | "plot";
6363+ color?: string;
6464+ dashed?: boolean;
6565+ useTag?: "start" | "end" | "none";
6666+ showSerieName?: "start" | "end";
6767+ useArea?: boolean;
6868+ dataLabels?: boolean;
6969+ useProgression?: boolean; // Display a trend line
7070+ scaleSteps?: number; // The preferred number of scale segments on the y axis
7171+ scaleLabel?: string;
7272+ scaleMax?: number; // Force the max scale value
7373+ scaleMin?: number; // Force the min scale value
7474+ autoScaling?: boolean;
7575+ stackRatio?: number; // In stacked mode, sets the height ratio of the datapoint
7676+ comments?: string[]; // Provide an array of comments which will display at same index as the series item
7777+ shape?: Shape; // circle, triangle, square, pentagon, hexagon, star
7878+ smooth?: boolean; // Display as a spline
7979+ prefix?: string; // Use a prefix on data labels
8080+ suffix?: string; // Use a suffix on data labels
8181+ }
8282+8383+ <!-- LineChart.vue - example of a basic line chart -->
8484+ <template>
8585+ <VueUiXy :dataset="dataset" :config="config" />
8686+ </template>
8787+8888+ <script setup>
8989+ import { ref } from 'vue';
9090+ import { VueUiXy } from 'vue-data-ui'; // import the XY chart component
9191+9292+ // Reactive dataset: array of points with minimal required attributes
9393+ const dataset = ref([
9494+ { name: 'Serie A', series: [1, 2, 3, 5], type: 'line' },
9595+ { name: 'Serie B', series: [13, 21, 3, 2], type: 'bar' },
9696+ { name: 'Serie C', series: [8, 2, 3, 6], type: 'plot' },
9797+ ]);
9898+9999+ // Minimal config for the line chart (optional). The TS type for the config is VueUiXyConfig
100100+ const config = ref({
101101+ chart: {
102102+ fontFamily: "inherit",
103103+ backgroundColor: "#FFFFFF",
104104+ color: "#1A1A1A",
105105+ grid: {
106106+ showHorizontalLines: false,
107107+ showVerticalLines: false,
108108+ labels: {
109109+ show: true, // shows datapoint labels if the
110110+ color: "#1A1A1A",
111111+ xAxisLabels: {
112112+ values: ['01-01-2026', '02-01-2026', '03-01-2026', '04-01-2026'], // The values displayed on the x axis (time labels)
113113+ rotation: 0, // to rotate the x axis labels
114114+ }
115115+ }
116116+ },
117117+ title: {
118118+ text: 'Title',
119119+ color: '#1A1A1A'
120120+ },
121121+ bar: { // Specific config for bar types
122122+ labels: {
123123+ show: true,
124124+ }
125125+ },
126126+ line: { // Specific config for line types
127127+ labels: {
128128+ show: true
129129+ }
130130+ },
131131+ plot: { // Specific config for plot types
132132+ labels: {
133133+ show: true
134134+ }
135135+ },
136136+ tooltip: {
137137+ show: true,
138138+ customFormat: null, // Provide a custom html content with a callback, for example: ({ seriesIndex, datapoint, series, config, bars, lines, plots }) => { return `Your content` }
139139+ }
140140+ }
141141+ });
142142+ </script>
143143+144144+## Sparkline Chart Example
145145+146146+Sparkline charts are mini charts for showing trends. The `VueUiSparkline` component renders a small, minimalist line chart. The dataset is an array of data points with the following datastructure:
147147+148148+ type VueUiSparklineDatasetItem = {
149149+ period: string // For example, a date
150150+ value: number
151151+ }
152152+153153+ <!-- SparklineChart.vue - example of a sparkline chart -->
154154+ <template>
155155+ <VueUiSparkline :dataset="dataset" :config="config" />
156156+ </template>
157157+158158+ <script setup>
159159+ import { ref } from 'vue';
160160+ import { VueUiSparkline } from 'vue-data-ui'; // import the Sparkline component
161161+162162+163163+ // Reactive dataset: an array of objects of type VueUiSparklineDatasetItem
164164+ const dataset = ref([
165165+ { period: 'January', value: 1 },
166166+ { period: 'February', value: 2 },
167167+ { period: 'March', value: 3 },
168168+ ]);
169169+170170+ // Minimal config example for the sparkline chart (optional). Full config type is VueUiSparklineConfig
171171+ const config = ref({
172172+ type: 'line', // or 'bar'
173173+ style: {
174174+ area: {
175175+ show: true,
176176+ },
177177+ dataLabel: {
178178+ show: true
179179+ },
180180+ line: {
181181+ color: '#6376DD'
182182+ },
183183+ plot: {
184184+ show: true,
185185+ radius: 4
186186+ },
187187+ title: {
188188+ show: true,
189189+ text: 'Title'
190190+ },
191191+ tooltip: {
192192+ show: true
193193+ },
194194+ verticalIndicator: {
195195+ show: true,
196196+ }
197197+ }
198198+ });
199199+ </script>
200200+201201+Notes:
202202+- Ideal for embedding in dashboards or tables to indicate trends.
203203+204204+## Using the vue-data-ui-cli
205205+206206+VueDataUI offers a CLI tool, `vue-data-ui-cli`, to quickly generate chart component boilerplates.
207207+208208+### Installation:
209209+210210+ npm install -g vue-data-ui-cli
211211+212212+This installs a global command `vdui-cli` (short for VueDataUI CLI).
213213+214214+### Usage:
215215+216216+Run the CLI in your project directory:
217217+218218+ vdui-cli
219219+220220+You'll be prompted for:
221221+- **Component Type:** Select the VueDataUI chart type (e.g., Donut, Radar, etc.).
222222+- **Reactive API:** Choose how to manage reactive data (using `ref` or `computed`).
223223+- **TypeScript Usage:** Decide if the component should be in TypeScript or JavaScript.
224224+- **Component Name:** Provide a name for your component (e.g., `MyDonutChart`).
225225+- **Target Directory:** Specify where to create the new component file.
226226+227227+The CLI will generate a Vue single-file component pre-populated with:
228228+- Correct imports for VueDataUI components.
229229+- Sample reactive `dataset` and `config` objects.
230230+- A template ready to render the selected chart.
231231+232232+This tool helps maintain consistency and speeds up development by providing a reliable boilerplate.