Customizable Gauge Component with Gradients and Animations for Vuejs

Customizable Gauge Component with Gradients and Animations for Vuejs

vue-svg-gauge An easily customizable gauge for VueJS with gradients and animations

vue-svg-gauge

An easily customizable gauge for VueJS with gradients and animations

Installation

npm i vue-svg-gauge --save

yarn add -D vue-svg-gauge

Import

ES6

The following examples can also be used with CommonJS by replacing ES6-specific syntax with CommonJS equivalents.

import Vue from 'vue'
import { VueSvgGauge } from 'vue-svg-gauge'

new Vue({
  components: {
    VueSvgGauge,
  }
})

Globals as a pluggin

import Vue from 'vue'
import App from './App.vue'
import VueSvgGauge from 'vue-svg-gauge'

Vue.use(VueSvgGauge)

new Vue({
  render: h => h(App),
}).$mount('#app')

Globals (via the script tag)

Add a script tag pointing to dist/vue-svg-gauge.min.js after adding Vue.

<html>
  <head>
    ...
  </head>
  <body>
    <div id="app">
      <vue-svg-gauge></vue-svg-gauge>
    </div>

    <script src="path/to/vue.js"></script>
    <script src="path/to/dist/vue-svg-gauge.min.js"></script>
    <script>
      new Vue({
        el: '#app'
      })
    </script>
  </body>
</html>

Usage

Once installed, it can be user in any template as

<VueSvgGauge
  :start-angle="-110"
  :end-angle="110"
  :value="3"
  :separator-step="1"
  :min="0"
  :max="4"
  :gauge-color="[{ offset: 0, color: '#347AB0'}, { offset: 100, color: '#8CDFAD'}]"
  :scale-interval="0.1"
/>
<!--  or  -->
<vue-svg-gauge
  :start-angle="-110"
  :end-angle="110"
  :value="3"
  :separator-step="0"
  :min="0"
  :max="10"
  gauge-color="#8CDFAD"
  :scale-interval="0.1"
/>

Props

Props Type Value Default
value Number Value of the gauge, must be contained between min and max. If not, it will be set to min if inferior, or max if superior 70
min Number Minimum value reachable 0
max Number Maximum value reachable 100
startAngle Number Start angle of the gauge. Can go from -360° to 360° but must be smaller than endAngle -90
endAngle Number End angle of the gauge. Can go from -360° to 360° but must be greater than startAngle 90
innerRadius Number inner radius that will determine the thickness of the gauge 60
separatorStep Number Number of steps between each separator (will display a separator each min + (n * separatorStep)). Won't display any if 0 or null 10
separatorThickness Number Thickness of the separators, unit is in degree 4
gaugeColor String,Array Color of the gauge, can either be a simple color or a gradient [{ offset: 0, color: '#347AB0' }, { offset: 100, color: '#8CDFAD' }]
baseColor String Color of the empty gauge #DDDDDD
scaleInterval Number Interval between the scale line, based on min and max. Won't display any if 0 or null 5
transitionDuration Number Transition duration time in ms. If set to 0, there will be no transition 1500
easing String Animation easing option Circular.Out

Notes :

  • the reference angle is 0 on top of the gauge.
  • you can find the documentation about the different animation functions here

Slot

There is a main slot allowing you to display any kind of html you want in your gauge.

Example

<VueSvgGauge
  :start-angle="-110"
  :end-angle="110"
  :value="random"
  :separator-step="20"
  :scale-interval="10"
  :inner-radius="80"
>
  <div class="inner-text">
    <span>Let's make this <b>fun</b> !</span>
  </div>
</VueSvgGauge>
.inner-text {
  // allow the text to take all the available space in the svg on top of the gauge
  height: 100%;
  width: 100%;

  span {
    max-width: 100px;
    color: red;
    // ...
  }
}

Demo

You can find a demo here

Dependencies

You will need to install vue ~2.5.22 to use this package properly

Also vue-svg-gauge relies on the tweenJs library for animations.

Made with ❤️ at comet

Download Details:

Author: hellocomet

Demo: https://hellocomet.github.io/vue-svg-gauge/

Source Code: https://github.com/hellocomet/vue-svg-gauge

vue vuejs javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

8 Popular Websites That Use The Vue.JS Framework

In this article, we are going to list out the most popular websites using Vue JS as their frontend framework. Vue JS is one of those elite progressive JavaScript frameworks that has huge demand in the web development industry. Many popular websites are developed using Vue in their frontend development because of its imperative features.

Vue Native is a framework to build cross platform native mobile apps using JavaScript

Vue Native is a framework to build cross platform native mobile apps using JavaScript. It is a wrapper around the APIs of React Native. So, with Vue Native, you can do everything that you can do with React Native. With Vue Native, you get

How to Make a Simple Vue Custom Select Component

In this article, you’ll learn how to build a Vue custom select component that can be easily be styled using your own CSS. In fact, it’s the same component that we use in production on Qvault, and you can see it in action on the playground.

Creating a Custom Tooltip Component in Vue

There are plenty of libraries out there that will have you up and running with a good tooltip solution in minutes. However, if you are like me, you are sick and tired of giant dependency trees that have the distinct possibility of breaking at any time.

Vue ShortKey plugin for Vue.js

Vue-ShortKey - The ultimate shortcut plugin to improve the UX .Vue-ShortKey - plugin for VueJS 2.x accepts shortcuts globaly and in a single listener.