1.0.7 • Published 5 years ago

@kagronick/kgauge-vue v1.0.7

Weekly downloads
211
License
MIT
Repository
github
Last release
5 years ago

KGague - A Gauge Library for Vue

KGague is the JustGage JavaScript library remade for Vue.js. It does not use any dependencies including JustGage or Raphael. All rendering is done with the Vue rendering engine using SVGs. The gagues it produces are arc or circle shapes. The gagues animate by default with the ability to customise easing functions. As the gauges moves through different ranges you can have the color fade. e.g (Green when low, red when high) These color steps can be customised. Many other features of the Gauge can be customized as well.

KGauge is 7% of the size of Just Gage with Raphael and covers most of the features. The whole library is only 8kb minified. Compare that to JustGage which is 20kb for JustGage minified and 90kb for Raphael minified. Even if you only use Vue for KGauge your page will still be smaller.

Demo

View an interactive demo

Examples

How to use

npm i @kagronick/kgauge-vue
import KGauge from "@kagronick/kgauge-vue";
export default {
  components: {
    KGauge
  },
}
<k-gauge 
  :value="30"
  :width="500"
  :height="300"
  :max="300"
  label-text="GB" />

Or just download and add

<script src="dist/kgauge-vue.min.js"></script>

API

No properties are required but you'll probably want to set value, min, and max to get started.

Attr. NameDescriptionDefault Value
widthWidth of component200
heightHeight of component150
valueThe value to display10
minThe minimum value0
maxThe maximum value100
animationDurationHow long to animate in miliseconds. Set to 0 to disable animation.1000
doughnutEnable doughnut modefalse
formatFunctionA function to format the value for display. Use to add dollar signs, percent, or display values that are not whole numbers.Math.round
colorStepsAn array of colors to fade between["#a9d70b", "#f9c802", "#ff0000"]
valueFontStyleFont style for the value textfont-size: 35px; fill: #010101; font-weight: bold; font-family: "Arial"
labelFontStyleThe font style for the label under the valuefont: 10px Arial; fill: #b3b3b3
minMaxFontStyleThe font style for the min and max labelsfont: 11px Arial; fill: #b4b4b4
animateOnLoadAnimate to initial valuetrue
labelTextText to show under value''
showMinMaxShow the min and max labelstrue
minTextFormatFnFormat the min text value(v) => v
maxTextFormatFnFormat the max text value(v) => v
gaugeSizeScaling of the gauge. Can be made negative to draw the gauge outwards from the center.1
shadowOpacityAmount of shadow. Set to 0 to disable..2
backgroundColorColor of background#edebeb
easingFunctionEasing function for animations. Can be used to bounce the gauge into position.(t)=> t*(2-t) /* Ease out quad */
titleTitle string
titleStyleStyle for the titlefill: #999999; font-size: 24px; font-weight: bold

Changelog

06-07-2019 (1.0.7) Fixed title cut off on doughnut on small sizes

06-02-2019 (1.0.6) Fixed bug with single color step. Fixed bug with shadows disabled.

06-02-2019 (1.0.5) Allows min value to be larger than max value. Fixed issue with non-zero min value in doughnut gauges. Added min and max text format functions.

05-18-2019 (1.0.4) Fixed issue with rounding color values to show up correctly on IE.

04-15-2019 (1.0.3) Fixed spelling, allow strings for width and height, added title style, changed default sizing and positioning.

Made by Kyle Agronick with code from the original JustGage project. http://justgage.com/