Skip to content

<Graph> component

-5-4-3-2-1012345543210-1-2-3-4-5

The <Graph> component is the top-level component of every graph. It is responsible for drawing the axes, grid, and origin, and for providing the coordinate system for all other components.

Even when drawing a diagram without axes or a grid, you still need to wrap the other components inside a <Graph> component.

Props

NameTypeDescriptionDefault
widthnumberThe width of the graph, in pixels200
heightnumberThe height of the graph, in pixels200
paddingnumberThe padding around the graph, in pixels30
domain-xPossibleVector2The domain of the graph's x-axis[-5, 5]
domain-yPossibleVector2The domain of the graph's y-axis[-5, 5]
originPossibleVector2The origin of the axes of the graphHalfway between domain-x and domain-y
grid-sizenumberThe size of the grid squares in local units1
axisbooleanWhether to draw the axestrue
gridbooleanWhether to draw the gridtrue
unitsbooleanWhether to draw the units on the axestrue

Examples

Moving the origin

-2-1012345678543210-1-2-3-4-5
Code
vue
<template>
  <Graph :origin="[2, 5]" />
</template>

Changing the domain

-2-101243210-1-2-3-4
Code
vue
<template>
  <Graph :domain-x="[-2, 2]" :domain-y="[-4, 4]" />
</template>

Changing the grid size

-5-2.502.5552.50-2.5-5
Code
vue
<template>
  <Graph :grid-size="2.5" />
</template>

Drawing only the axes

Code
vue
<template>
  <Graph :grid="false" :units="false" />
</template>

Drawing only the grid

Code
vue
<template>
  <Graph :axis="false" :units="false" />
</template>