Giter Club home page Giter Club logo

svg-gauge-circle's Introduction

svg-gauge-circle

A simple SVG-based animated circular gauge.

Build

Running npm run build will build ./build/svg-gauge-circle.min.js.

Development

Running npm run dev will start up a dev server, go to http://localhost:3333/index-dev.html to see an example.

Usage

Dependencies

Example of usage

See demo for an example.

API

  • sgc = new SvgGaugeCircle(size, value, cutoffValue, maxValue, fontSize, strokeWidth):
    • size: length of a side of a square bounding box in which the element is drawn
    • value: a value to be shown on the gauge
    • cutoffValue: threshold/cutoff value shown on the gauge
    • maxValue: maximum value that can be shown on the gauge ie. number at which the gauge's external circle would be 100% filled
    • fontSize: font size of the digits shown in px
    • strokeWidth: width of the external circle
  • sgc.draw(container) - draw the gauge inside of the container element; this will return a Promise that is resolved when drawing of the gauge has been finished

Styling

The gauge will be styled using the following classes:

  • sgc-inner-circle: for internal circle properties (use stroke for circle's edge)
  • sgc-outer-circle: for external circle properties (don't use fill here)
  • sgc-stroke: for the animated stroke properties before it reaches the cutoffValue
  • sgc-stroke-cutoff: for the animated stroke properties after it reached the cutoffValue
  • sgc-text: for text properties
#container1 .sgc-text {
    color: #171d69;
    font-family: Arial;
}

#container1 .sgc-inner-circle {
    stroke: #ca4545;
    fill: #ff9595;
}

#container1 .sgc-outer-circle {
    stroke: #980e0e;
    stroke-width: 2;
}

#container1 .sgc-stroke {
    stroke: #78cd78;
}

#container1 .sgc-stroke-cutoff {
    stroke: #ffe395;
}

Todo

  • update the gauge after drawing it first time

License

See LICENSE.

svg-gauge-circle's People

Contributors

0xmjk avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.