Api

VPlot

Explore the VPlot component API — props from Observable Plot's PlotOptions, the marks prop, responsive sizing, and usage examples.

The main chart component. Accepts plot configuration via props.

Import

App.vue
import { VPlot } from '@memotux/vue-plot'

Usage

App.vue
<template>
  <VPlot :width="680" :marks="marks" />
</template>

Or with children:

App.vue
<template>
  <VPlot :width="680">
    <PlotBarY :data="data" x="name" y="value" />
  </VPlot>
</template>

Props

VPlot accepts all properties from Observable Plot's PlotOptions, plus the marks prop.

Plot options

PropTypeDefaultDescription
widthnumberAutoWidth of the plot in pixels
heightnumberAutoHeight of the plot in pixels
marginTopnumberInherits Observable Plot's default
marginRightnumberInherits Observable Plot's default
marginBottomnumberInherits Observable Plot's default
marginLeftnumberInherits Observable Plot's default
styleobjectCSS styles applied to the SVG
classNamestringCSS class applied to the SVG
aspectRationumbernullSVG aspect ratio
clipbooleanClip marks to the frame
nicebooleanRound scales to nice values
zerobooleanInclude zero in scales
roundbooleanRound to integer pixels
axisstringDefault axis label
gridbooleanShow grid lines

Marks prop

PropTypeDescription
marksRenderableMark[]Array of mark functions from @observablehq/plot
If marks are provided as both props and children, only children are rendered.

Types

types.ts
import type { PlotProps } from '@memotux/vue-plot/types'

// VPlot accepts either PlotOptions or marks-based props
type PlotProps<M extends Marks = Marks> = PlotOptions | PlotMarksProps<M>

Examples

Basic bar chart

App.vue
<script setup lang="ts">
import { barY } from '@observablehq/plot'

const data = [
  { name: 'A', value: 10 },
  { name: 'B', value: 20 },
  { name: 'C', value: 15 },
]

// barY from @observablehq/plot — programmatic API
</script>

<template>
  <VPlot :width="680" :height="400" :marks="[
    barY(data, { x: 'name', y: 'value' })
  ]" />
</template>

Custom margins

App.vue
<template>
  <VPlot
    :width="680"
    :height="400"
    :marginTop="40"
    :marginRight="40"
    :marginBottom="60"
    :marginLeft="80"
  >
    <PlotBarY :data="data" x="name" y="value" />
  </VPlot>
</template>

Responsive width

App.vue
<script setup lang="ts">
import { ref, onMounted } from 'vue'

const data = ref([
  { name: 'A', value: 10 },
  { name: 'B', value: 20 },
  { name: 'C', value: 15 },
])
const container = ref(null)
const width = ref(680)

onMounted(() => {
  const observer = new ResizeObserver(entries => {
    width.value = entries[0].contentRect.width
  })
  observer.observe(container.value)
})
</script>

<template>
  <div ref="container">
    <VPlot :width="width">
      <PlotBarY :data="data" x="name" y="value" />
    </VPlot>
  </div>
</template>

What's next?

Copyright © 2026