Vue UI Components Documentation
The Vue Gauge displays an indicator within a range of values. This guide adds the Vue Gauge (jqxGauge) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-scriptsjqwidgets-scripts/jqwidgets-vue3/vue_jqxgauge.vue 
In a Vue 3 project (to start one, see Getting started with Vue), add the package:
npm install jqwidgets-scripts
import JqxGauge from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxgauge.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>
<div style="float: left">
<JqxGauge
ref="myGauge"
@valueChanging="onValueChanging($event)"
:ranges="ranges"
:ticksMinor="ticksMinor"
:ticksMajor="ticksMajor"
:value="0"
:colorScheme="'scheme05'"
:animationDuration="1200"
>
</JqxGauge>
<div ref="gaugeValue" class="gaugeValue"></div>
</div>
<JqxLinearGauge
ref="myLinearGauge"
style="margin-left: 60px; float: left"
:width="100"
:height="350"
:max="60"
:orientation="'vertical'"
:ticksMajor="ticksMajorLinear"
:ticksMinor="ticksMinorLinear"
:pointer="{ size: '5%' }"
:colorScheme="'scheme05'"
:labels="labels"
:ranges="rangesLinear"
:animationDuration="1500"
>
</JqxLinearGauge>
</div>
</template>
<script setup>
import { onMounted, ref } from 'vue';
import JqxGauge from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxgauge.vue';
import JqxLinearGauge from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxlineargauge.vue';
const gaugeValue = ref(null);
const myGauge = ref(null);
const myLinearGauge = ref(null);
const ticksMinor = ref({ interval: 5, size: '5%' });
const ticksMajor = ref({ interval: 10, size: '9%' });
const ranges = ref([
{
startValue: 0,
endValue: 55,
style: { fill: '#4bb648', stroke: '#4bb648' },
endWidth: 5,
startWidth: 1
},
{
startValue: 55,
endValue: 110,
style: { fill: '#fbd109', stroke: '#fbd109' },
endWidth: 10,
startWidth: 5
},
{
startValue: 110,
endValue: 165,
style: { fill: '#ff8000', stroke: '#ff8000' },
endWidth: 13,
startWidth: 10
},
{
startValue: 165,
endValue: 220,
style: { fill: '#e02629', stroke: '#e02629' },
endWidth: 16,
startWidth: 13
}
]);
const ticksMinorLinear = ref({
size: '5%',
interval: 2.5,
style: { 'stroke-width': 1, stroke: '#aaaaaa' }
});
const ticksMajorLinear = ref({ size: '10%', interval: 10 });
const labels = ref({
interval: 20,
formatValue: (value, position) => {
if (position === 'far') {
value = (9 / 5) * value + 32;
if (value === -76) {
return '°F';
}
return value + '°';
}
if (value === -60) {
return '°C';
}
return value + '°';
}
});
const rangesLinear = ref([
{ startValue: -10, endValue: 10, style: { fill: '#FFF157', stroke: '#FFF157' } },
{ startValue: 10, endValue: 35, style: { fill: '#FFA200', stroke: '#FFA200' } },
{ startValue: 35, endValue: 60, style: { fill: '#FF4800', stroke: '#FF4800' } }
]);
function onValueChanging(event) {
gaugeValue.value.innerHTML = Math.round(event.args.value) + ' kph';
}
onMounted(() => {
myGauge.value.value = 140;
myLinearGauge.value.value = 40;
});
</script>
<style>
.gaugeValue {
background-color: #f6f6f6;
background-image: -webkit-gradient(
linear,
50% 0%,
50% 100%,
color-stop(0%, #fafafa),
color-stop(100%, #f3f3f3)
);
background-image: -webkit-linear-gradient(#fafafa, #f3f3f3);
background-image: -moz-linear-gradient(#fafafa, #f3f3f3);
background-image: -o-linear-gradient(#fafafa, #f3f3f3);
background-image: linear-gradient(#fafafa, #f3f3f3);
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0 0 50px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 0 50px rgba(0, 0, 0, 0.2);
box-shadow: 0 0 50px rgba(0, 0, 0, 0.2);
padding: 10px;
position: absolute;
top: 290px;
left: 140px;
font-family: Sans-Serif;
text-align: center;
font-size: 17px;
color: #333333;
width: 70px;
}
</style>Options are attributes. Bind values from the script with :, for example :width="850".
Listen to an event with @ and its name. For example, valueChanged: The event is is triggered when the gauge's value is changed.
<script setup>
function onValueChanged(event) {
console.log(event.args);
}
</script>
<template>
<JqxGauge @valueChanged="onValueChanged" />
</template>
Call methods through a template ref. For example, val: Sets or gets the value.
<script setup>
import { ref, onMounted } from 'vue';
const myGauge = ref(null);
onMounted(() => {
const value = myGauge.value.val();
console.log(value);
});
</script>
<template>
<JqxGauge ref="myGauge" />
</template>
Every component also has setOptions({ … }) and getOptions('name').