UIPackage
Menu

Framework

Change language

Boilerplate repo

Raw Chart

raw-chartui

Escape-hatch wrapper that takes a full ECharts option object. Lets you build any ECharts type (sankey, sunburst, candlestick, graph, boxplot, parallel, themeRiver, custom) with full customization. Theme-aware exports available via useChartTheme.

Also available for React ->

Installation

$npx shadcn-vue@latest add https://uipkge.dev/r/vue/raw-chart.json
Named registry:npx shadcn-vue@latest add @uipkge/raw-chartInstalls to:app/components/ui/charts/raw-chart/

Examples

Loading interactive previews…

Props

NameType / ValuesDefaultRequired
optionanyrequired
heightnumber | string300optional
autoresize

Auto-resize on container width change. Default true.

booleantrueoptional
classstringoptional
ariaLabel

Accessible name announced for the chart image. Defaults to "Chart".

stringoptional

npm dependencies

Used by

Files installed (3)

  • app/components/ui/charts/raw-chart/RawChart.vue2.2 kB
    <script setup lang="ts">
    import { use } from 'echarts/core'
    import { CanvasRenderer } from 'echarts/renderers'
    import VChart from 'vue-echarts'
    import { cn } from '@/lib/utils'
    
    // Raw escape hatch. The opinionated wrappers (AreaChart, BarChart,
    // FunnelChart, ...) cover the common cases with sensible defaults +
    // a `data` prop. When you need a chart type they don't wrap
    // (Sankey, Sunburst, Graph, Candlestick, ThemeRiver, Tree, Parallel,
    // Custom) -- or when you need a level of customisation the wrappers
    // can't expose without leaking ECharts internals -- reach for this
    // component and pass a complete ECharts option object.
    //
    // You're responsible for `use()`-registering the chart types and
    // components you need before this component renders. The canvas
    // renderer is registered here so you don't have to:
    //
    //   import { use } from 'echarts/core'
    //   import { SankeyChart } from 'echarts/charts'
    //   import { TooltipComponent, LegendComponent } from 'echarts/components'
    //   import { RawChart } from '@/components/ui/charts'
    //
    //   use([SankeyChart, TooltipComponent, LegendComponent])
    //
    //   const option = { /* full ECharts option for sankey */ }
    //
    //   <RawChart :option="option" :height="400" />
    //
    // Theme tokens (chartColors, chartTextColor, chartTooltipBg, etc.)
    // are exported from `useChartTheme.ts` -- import and weave them into
    // your option for visual consistency with the rest of the registry's
    // charts.
    
    use([CanvasRenderer])
    
    withDefaults(
      defineProps<{
        option: any
        height?: number | string
        /** Auto-resize on container width change. Default true. */
        autoresize?: boolean
        class?: string
        /** Accessible name announced for the chart image. Defaults to "Chart". */
        ariaLabel?: string
      }>(),
      { height: 300, autoresize: true },
    )
    </script>
    
    <template>
      <div
        role="img"
        tabindex="0"
        :aria-label="ariaLabel || 'Chart'"
        :style="{ height: /^\d+$/.test(String(height)) ? `${height}px` : String(height) }"
        :class="cn('focus-visible:ring-ring w-full focus-visible:ring-2 focus-visible:outline-none', $props.class)"
      >
        <VChart :option="option" :autoresize="autoresize" class="size-full" />
      </div>
    </template>
    
  • app/components/ui/charts/raw-chart/index.ts0.1 kB
  • app/components/ui/charts/useChartTheme.ts8.2 kB

Raw manifest:https://uipkge.dev/r/vue/raw-chart.json