DataV Vue3

repository·master·Indexed 20 days ago

https://github.com/vaemusic/datav-vue3

A Vue 3, TypeScript, and Vite compatible version of the DataV component library. It provides various visual decorations and data visualization components for dashboards and big data displays, including BorderBox components and the ActiveRingChart.

Tokens
38.8K
Snippets
185
Records
251
Agent score
63%

What's inside datav-vue3

  1. Use Chart components via Charts.js options

    master

    The Chart components in this library are wrappers around Charts.js. To use them, you simply need to pass the corresponding option data object into the component.

    Key Behavior:

    • Auto-resize: The chart components automatically recalculate their width and height when the window is resized to ensure they remain adaptive/responsive.

    For detailed information on available data structures and configuration, refer to the official Charts examples and Charts configuration documentation.

    // Example pattern: Pass an option object to the component
    <ChartComponent :option="yourChartOptions" />
  2. Layout and usage considerations for Border components

    master

    When using DataV border components, keep the following layout and lifecycle rules in mind to avoid rendering issues:

    1. Internal Layout: Border components default to 100% width and height. Content passed into the default slot is distributed into a container with the class border-box-content. You should apply your layout styles to this specific container to avoid conflicts.
    2. Component Encapsulation: It is highly recommended to wrap content placed inside a border into a separate Vue component. Because of the specific way slots are rendered, performing DOM-sensitive operations (like measuring element width/height or initializing ECharts) immediately upon the border component's mounted hook might result in incorrect values (e.g., width/height of 0). Encapsulating content in a child component ensures these operations happen at the correct time in the lifecycle.
    3. Handling Parent Resizing: If the parent container's dimensions change and the border component fails to adapt, do not force a re-render by changing the key attribute, as this destroys the component state and incurs performance costs. Instead, use the built-in initWH method to reset the border's dimensions.
  3. Update ScrollBoard data using updateRows

    master

    When updating data, avoid using Array.prototype.push on config.data. Because the component watches the config object, pushing new data causes the component to recalculate, which resets the scroll position back to the first row.

    To append data without resetting the scroll position, use the updateRows method. This method requires you to provide a completely new array for the data property within the config. You can also use this method to set the starting row for the next scroll cycle.

  4. Project directory structure overview

    master

    The repository is organized as a pnpm monorepo with the following primary directories:

    • build: Vite configuration files.
    • script: Scripts for generating component boilerplate and documentation.
    • packages/datav-vue3: The core component library source code.
    • packages/docs: The documentation site (built with Vitepress and UnoCSS).
  5. Quickstart with DataV - Vue3

    master

    DataV - Vue3 is a component library designed for Vue3 and Vite. It provides visually rich components that are easy to use out-of-the-box by simply configuring dimensions (width/height) or providing simple data structures. To get started, follow the official Guide.

    <!-- For more detailed instructions, refer to the /Guide/Guide section in the documentation -->
  6. Use the WaterLevelPond component

    master

    The WaterLevelPond component visualizes water levels using animated waves. It supports three different shapes: rectangular, rounded rectangular, and circular. It can handle multiple water levels, but by default, it displays the information for the highest water level.

    <template>
      <!-- Rectangular shape -->
      <WaterLevelPond shape="rect" :data="[50]" />
    
      <!-- Rounded rectangle shape -->
      <WaterLevelPond shape="roundRect" :data="[70]" />
    
      <!-- Circular shape -->
      <WaterLevelPond shape="round" :data="[30]" />
    </template>
  7. Add a new component using the generator script

    master

    The project provides a scaffolding script to generate the necessary boilerplate for new components and their corresponding documentation.

    Run the following command: pnpm run gen

    During the interactive prompt, you must provide:

    1. Component Type: Choose from Other, Border, or Decoration (this determines the documentation directory structure).
    2. English Name: Use PascalCase (e.g., BorderBox1, ScrollBoard). This name is used for component registration.
    3. Chinese Name: This will be used as the sidebar name in the documentation.
    4. Description: A brief functional description of the component.

    Generated Structure:

    • Source: packages/datav-vue3/components/[ComponentName]/src/index.vue and packages/datav-vue3/components/[ComponentName]/index.ts (for registration).
    • Docs: packages/docs/docs/[Type]/[ComponentName]/index.md and packages/docs/docs/[Type]/[ComponentName]/demo.vue.
    pnpm run gen