Vue UI Components Documentation
The Vue Knob is a rotary knob with custom dials, markers and pointers. This guide adds the Vue Knob (jqxKnob) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-scriptsjqwidgets-scripts/jqwidgets-vue3/vue_jqxknob.vue 
In a Vue 3 project (to start one, see Getting started with Vue), add the package:
npm install jqwidgets-scripts
import JqxKnob from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxknob.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 Default Functionality demo as a Single-File Component:
<template>
<div id="container">
<JqxKnob
ref="myKnob"
@change="onChange($event)"
:value="60"
:min="0"
:max="100"
:startAngle="120"
:endAngle="420"
:snapToStep="true"
:rotation="'clockwise'"
:marks="marks"
:labels="labels"
:progressBar="progressBar"
:pointer="pointer"
>
</JqxKnob>
<div id="inputField">
<JqxNumberInput
ref="myNumberInput"
@mousedown="onMouseDown($event)"
@keyup="onKeyup()"
@valueChanged="onValueChanged()"
:width="60"
:height="40"
:decimal="60"
:min="0"
:max="100"
:textAlign="'center'"
:decimalDigits="1"
:inputMode="'simple'"
>
</JqxNumberInput>
</div>
</div>
</template>
<script setup>
import { onMounted, ref } from 'vue';
import JqxKnob from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxknob.vue';
import JqxNumberInput from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxnumberinput.vue';
const myNumberInput = ref(null);
const myKnob = ref(null);
const style = ref({
stroke: '#dfe3e9',
strokeWidth: 3,
fill: {
color: '#fefefe',
gradientType: 'linear',
gradientStops: [
[0, 1],
[50, 0.9],
[100, 1]
]
}
});
const marks = ref({
colorRemaining: { color: 'grey', border: 'grey' },
colorProgress: { color: '#00a4e1', border: '#00a4e1' },
type: 'line',
offset: '71%',
thickness: 3,
size: '6%',
majorSize: '9%',
majorInterval: 10,
minorInterval: 2
});
const labels = ref({ offset: '88%', step: 10, visible: true });
const progressBar = ref({
style: { fill: '#00a4e1', stroke: 'grey' },
size: '9%',
offset: '60%',
background: { fill: 'grey', stroke: 'grey' }
});
const pointer = ref({
type: 'circle',
style: {
fill: {
color: '#a4a3a3',
gradientType: 'linear',
gradientStops: [
[0, 0.5],
[50, 0.6],
[100, 1]
]
},
stroke: '#333'
},
size: '10%',
offset: '50%'
});
function onChange(event) {
if (event.args.changeSource == 'propertyChange' || event.args.changeSource == 'val') {
return;
}
myNumberInput.value.val(event.args.value);
}
function onMouseDown(event) {
event.stopPropagation();
}
function onKeyup() {
let val = myNumberInput.value.val();
myKnob.value.val(val);
}
function onValueChanged() {
let val = myNumberInput.value.val();
myKnob.value.val(val);
}
onMounted(() => {
myKnob.value.style = style.value;
});
</script>
<style>
#container {
position: relative;
}
.jqx-numberinput {
left: 170px;
top: 323px;
position: absolute;
background: transparent !important;
border: none !important;
}
text.jqx-knob-label {
font-size: 20px;
}
.jqx-numberinput > input {
background: transparent !important;
font-size: 20px !important;
color: grey !important;
}
</style>Options are attributes. Bind values from the script with :, for example :width="850".
Listen to an event with @ and its name. For example, change: This event is triggered when the value is changed.
<script setup>
function onChange(event) {
console.log(event.args);
}
</script>
<template>
<JqxKnob @change="onChange" />
</template>
Call methods through a template ref. For example, val: Sets or gets the value.
<script setup>
import { ref, onMounted } from 'vue';
const myKnob = ref(null);
onMounted(() => {
const value = myKnob.value.val();
console.log(value);
});
</script>
<template>
<JqxKnob ref="myKnob" />
</template>
Every component also has setOptions({ … }) and getOptions('name').