Skip to content

Commit d5a7cb9

Browse files
committed
Added donut support
1 parent 9dc974b commit d5a7cb9

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ You can use the following props
7777
| Name | Description | Type | Default |
7878
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------: | -------------------: |
7979
| options | GaugeJS render options, check gaugejs [API](http://bernii.github.io/gauge.js/) | Object | Basic gaugejs Object |
80-
| height | height of the gauge in pixels | string | 200px |
81-
| unit | unit to show after value | string | '' |
80+
| donut | Renders a donut instead of a gauge [#3](https://github.com/amroessam/vgauge/issues/3#issue-482228167) | Boolean | false |
81+
| height | height of the gauge in pixels | String | 200px |
82+
| unit | unit to show after value | String | '' |
8283
| initialValue | Initial value to display on the Gauge | Number | 0 |
8384
| value | Value to display/watch | Number | 50 |
8485
| minValue | Min value for the gauge to display | Number | 0 |

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vgauge",
3-
"version": "1.2.5-rc.2",
3+
"version": "1.2.6",
44
"description": "",
55
"main": "dist/VGauge.umd.js",
66
"module": "dist/VGauge.esm.js",
@@ -44,6 +44,8 @@
4444
"vue",
4545
"gauge",
4646
"gauge.js",
47-
"gaugejs"
47+
"gaugejs",
48+
"donut",
49+
"chart"
4850
]
4951
}

src/VGauge.vue

+16-13
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
</template>
1414

1515
<script>
16-
import { Gauge } from "gaugeJS/dist/gauge.min";
16+
import { Gauge, Donut } from "gaugeJS/dist/gauge.min";
1717
export default {
18-
name: 'VGauge',
18+
name: "VGauge",
1919
props: {
2020
unit: {
2121
type: String,
22-
default: ''
22+
default: ""
2323
},
2424
height: {
2525
type: String,
26-
default: '200px'
26+
default: "200px"
2727
},
2828
decimalPlace: {
2929
type: Number,
@@ -78,6 +78,10 @@ export default {
7878
value: {
7979
type: Number,
8080
default: 50
81+
},
82+
donut: {
83+
type: Boolean,
84+
default: false
8185
}
8286
},
8387
data() {
@@ -95,24 +99,23 @@ export default {
9599
},
96100
methods: {
97101
initializeGauge() {
98-
this.gauge = new Gauge(this.$refs.gauge);
102+
this.gauge = this.donut
103+
? new Donut(this.$refs.gauge)
104+
: new Gauge(this.$refs.gauge);
99105
this.gauge.maxValue = this.maxValue;
100106
this.gauge.setMinValue(this.minValue);
101107
this.gauge.animationSpeed = this.animationSpeed;
102108
this.gauge.setOptions(this.options);
103-
this.gauge.setTextField(
104-
this.$refs['gauge-value'],
105-
this.decimalPlace
106-
);
109+
this.gauge.setTextField(this.$refs["gauge-value"], this.decimalPlace);
107110
this.gauge.set(this.value);
108111
}
109112
}
110113
};
111114
</script>
112115

113116
<style scoped>
114-
.gauge-title span{
115-
display: inline;
116-
text-align: center;
117-
}
117+
.gauge-title span {
118+
display: inline;
119+
text-align: center;
120+
}
118121
</style>

0 commit comments

Comments
 (0)