Vue UI Components Documentation
The Vue Draw is a low-level drawing API for SVG and Canvas shapes, text and paths. This guide adds the Vue Draw (jqxDraw) to an app, then shows how to set its options and call its methods.
jqwidgets-scriptsjqwidgets-scripts/jqwidgets-vue3/vue_jqxdraw.vue 
In a Vue 3 project (to start one, see Getting started with Vue), add the package:
npm install jqwidgets-scripts
import JqxDraw from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxdraw.vue';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.base.css';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.tailwind-blue-dark.css';
With <script setup>, an imported component is ready to use in the template. jqx.base.css is required; the second file is a theme, selected with the theme attribute.
The Drawing Shapes demo as a Single-File Component:
<template>
<JqxDraw style="width: 850px; height: 500px" ref="myDraw"> </JqxDraw>
</template>
<script setup>
import { onMounted, ref } from 'vue';
import JqxDraw from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxdraw.vue';
const myDraw = ref(null);
onMounted(() => {
let size = myDraw.value.getSize();
let circleElement = myDraw.value.circle(250, 150, 50, {});
myDraw.value.attr(circleElement, { fill: 'lightblue', stroke: 'darkblue' });
let borderElement = myDraw.value.rect(0, 0, size.width, size.height, {
stroke: '#777777',
fill: 'transparent'
});
let pathElement = myDraw.value.path('M 100,100 L 150, 130 C 130,130 180,190 150,150', {
stroke: '#777777',
fill: 'red'
});
let areaElement = myDraw.value.path('M 300,300 L 350, 330 C 330,330 380,390 350,350 Z', {
stroke: '#777777',
fill: 'yellow'
});
myDraw.value.line(600, 100, 600, 200, { stroke: 'blue', 'stroke-width': 6 });
myDraw.value.line(550, 50, 650, 90, { stroke: 'green', 'stroke-width': 6 });
myDraw.value.text(
'Drawing shapes',
50,
20,
undefined,
undefined,
0,
{ class: 'largeText', fill: 'yellow', stroke: 'orange' },
false,
'center',
'center',
'centermiddle'
);
myDraw.value.text(
'This is rotated text',
600,
300,
undefined,
undefined,
45,
{ class: 'smallText' },
false,
'center',
'center',
'centermiddle'
);
let circleUp = myDraw.value.circle(50, 450, 30, { fill: '#DEDEDE', stroke: '#777777' });
let pathUp = myDraw.value.path('M30 460 L 70 460 L50 430 Z', {
fill: 'transparent',
stroke: '#777777',
'stroke-width': 1
});
let circleDown = myDraw.value.circle(120, 450, 30, { fill: '#DEDEDE', stroke: '#777777' });
let pathDown = myDraw.value.path('M100 440 L 140 440 L120 470 Z', {
fill: 'transparent',
stroke: '#777777',
'stroke-width': 1
});
myDraw.value.text('Click these buttons:', 20, 390);
let moveCircle = (moveUp) => {
let circleY = parseInt(myDraw.value.getAttr(circleElement, 'cy'));
myDraw.value.attr(circleElement, { cy: circleY + (moveUp ? -10 : 10) });
};
myDraw.value.on(circleUp, 'click', () => {
moveCircle(true);
});
myDraw.value.on(pathUp, 'click', () => {
moveCircle(true);
});
myDraw.value.on(circleDown, 'click', () => {
moveCircle(false);
});
myDraw.value.on(pathDown, 'click', () => {
moveCircle(false);
});
myDraw.value.refresh();
});
</script>
<style></style>Options are attributes. Bind values from the script with :, for example :width="850".
Call methods through a template ref. For example, refresh: Refreshes / re-draws the content of the jqxDraw widget
<script setup>
import { ref, onMounted } from 'vue';
const myDraw = ref(null);
onMounted(() => {
myDraw.value.refresh();
});
</script>
<template>
<JqxDraw ref="myDraw" />
</template>
Every component also has setOptions({ … }) and getOptions('name').