Giter VIP home page Giter VIP logo

react-svg-gauge's Introduction

React SVG Gauge

Simple SVG Gauge component, inspired by JustGage

Demo

Sample Gauge

https://reggino.github.io/react-svg-gauge

Sample implementation


import React, { Component } from 'react';
import Gauge from 'react-svg-gauge';

export default class App extends Component {
	render() {
		return (
			<div>
				<Gauge value={this.state.value} width={400} height={320} label="This is my Gauge" />
			</div>
		);
	}
}


Options

  • label (default: "React SVG Gauge")
  • min (default: 0)
  • max (default: 100)
  • minTxt (default: undefined)
  • maxTxt (default: undefined)
  • value (default: 40)
  • width (default: : 400)
  • height (default: 320)
  • color (default: '#fe0400')
  • backgroundColor (default: '#edebeb')
  • topLabelStyle (style object)
  • valueLabelStyle (style object)
  • minMaxLabelStyle (style object)
  • valueFormatter (function (number) => string)

Styling can be done via Style-properties, or by applying CSS to SVG Text elements.

react-svg-gauge's People

Contributors

benfen avatar bjoernkw avatar jakesidsmith avatar jedgentry avatar kingmxiii avatar reggino avatar vladnikolov86 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-svg-gauge's Issues

Change font color of formatter

Have way to change color in valueFormatter prop?

I change to pass style but only works fontSize and fontFamily.

` valueLabelStyle ={{
fontSize:100,
fontFamily:'Arial',
color:'blue'

        }}`

image

Publish/Update NPM project

Hey man, we're trying to use your NPM module in our project and it doesn't have the new Symbol code (we want to add a "%" to the text) and was wondering if you could just update the project.

Thanks!

Weird behavior when value exceeds limits

If the provided value exceeds the min and max values the gauge renders incorrectly, could possibly be improved by rendering it as completely full or empty, eg. quick fix: const value = data >= min && data <= max ? data : data < min ? min : max

Types for TypeScript.

It would be great if anyone can add these types to the project.

declare module "react-svg-gauge" { 
  import { Component, CSSProperties } from "react";
 
  export interface IGaugeProps {
    label?: string;
    max?: number;
    min?: number;
    value?: number;
    width?: number;
    height?: number;
    color?: string;
    backgroundColor?: string;
    topLabelStyle?: CSSProperties;
    valueLabelStyle?: CSSProperties;
    minMaxLabelStyle?: CSSProperties;
  }

  export class Gauge extends Component<IGaugeProps> {  
    public render(): JSX.Element;
  }
  
  export default Gauge;
}

No LICENSE for your project

Hello @Reggino could you please clarify the license of your project by adding a LICENSE file?
The lack of that information will prevent potential users from using your component.

Lib missing in v 1.0.2

Tim,

I think you would remove lib from gitignore because that is used while importing your module into the project otherwise, I would need to compile the code into lib using your package.json to use your module.

Regards,
Haider

How to remove "padding" around gauge

How would I go about removing the extra whitespace around the gauge?

I am trying to remove the space around the gauge so that the gauge (and min/max number) takes up the full width and height of the SVG.

Whitespace can be seen here:
screen shot 2017-01-11 at 5 18 04 pm

You can see that the gauge is not centered vertically/horizontally. I have different use cases making the gauge bigger, which seems to alleviate some of the problem. Which can be seen below:
screen shot 2017-01-11 at 5 23 50 pm

I have tried poking around with the Xo, Xi, Yo, Yi params to no avail. Is there some sort of width/height ratio that could solve this? Such as:

gaugeWidth - 100;
gaugeHeight = gaugeWidth * 0.6666667;

Ideally, I would like the gauge paths to start/end at the left/right/top/bottom most borders of the overall SVG.

Any help would be greatly appreciated and thanks for the hard work already!

How to build into lib

Tim,

Please see attached image of the gauge. I was able to adjust the width and also add gradiant. However, I was working directly on lib/gauge.js. I have added those changes to src but I am not able to compile into lib. Please tell what command do you use from scripts to make a new lib folder?
customgauge

Gradient Color in Gauge & Position Label

Hi,

Please tell if we can change the gauge color to gradient like in attached screenshot
gvegb

Can we know the position of value so we can position the label at that point?

How to change max label

I want to know if there is a way to change the text of max value like this. I tried to change a max value, but the gauge will disappear if the max is 0.

I would appreciate it if you have a way to do that. Thanks!

image

Support minTxt and maxTxt properties of JustGage

JustGage supports modifying labels displayed for minimum and maximum values via minTxt and maxTxt properties. But they are not supported by this library.

It requires a small change but I think it brings a good feature.

Upgrade to React v16

Since React 16 is released, this project should upgrade to match to remove any peer dependency warnings.

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.