-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from Mikhus/v2.0.6
Version 2.0.6
- Loading branch information
Showing
19 changed files
with
316 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Mykhailo Stadnyk | ||
Copyright (c) 2016 Mykhailo Stadnyk <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "canvas-gauges", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"homepage": "https://github.com/Mikhus/canvas-gauges", | ||
"authors": [ | ||
"Mykhailo Stadnyk <[email protected]>" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<!doctype htm> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<title>Gauge Test</title> | ||
<script src="../gauge.min.js"></script> | ||
<style>body { | ||
padding: 0; | ||
margin: 0; | ||
background: #fff | ||
}</style> | ||
</head> | ||
<body> | ||
|
||
<a href="#" onclick="gaugePS.value=570">570</a> | ||
<a href="#" onclick="gaugePS.value=583">583</a> | ||
<a href="#" onclick="gaugePS.value=830">830</a> | ||
<canvas id="gauge-ps"></canvas> | ||
|
||
<script> | ||
var gaugePS = new RadialGauge({ | ||
renderTo: 'gauge-ps', | ||
width: 400, | ||
height: 400, | ||
units: 'PS', | ||
minValue: 0, | ||
maxValue: 1000, | ||
majorTicks: [ | ||
'0', | ||
'100', | ||
'200', | ||
'300', | ||
'400', | ||
'500', | ||
'600', | ||
'700', | ||
'800', | ||
'900', | ||
'1000' | ||
], | ||
minorTicks: 2, | ||
ticksAngle: 270, | ||
startAngle: 45, | ||
strokeTicks: true, | ||
highlights : [ | ||
{ from : 457, to : 880, color : 'rgba(78, 78, 76, 0.5)' }, | ||
{ from : 880, to : 1000, color : 'rgba(225, 7, 23, 0.75)' } | ||
], | ||
valueInt: 1, | ||
valueDec: 0, | ||
colorPlate: "#fff", | ||
colorMajorTicks: "#686868", | ||
colorMinorTicks: "#686868", | ||
colorTitle: "#000", | ||
colorUnits: "#000", | ||
colorNumbers: "#686868", | ||
valueBox: true, | ||
colorValueText: "#000", | ||
colorValueBoxRect: "#fff", | ||
colorValueBoxRectEnd: "#fff", | ||
colorValueBoxBackground: "#fff", | ||
colorValueBoxShadow: false, | ||
colorValueTextShadow: false, | ||
colorNeedleShadowUp: true, | ||
colorNeedleShadowDown: false, | ||
colorNeedle: "rgba(200, 50, 50, .75)", | ||
colorNeedleEnd: "rgba(200, 50, 50, .75)", | ||
colorNeedleCircleOuter: "rgba(200, 200, 200, 1)", | ||
colorNeedleCircleOuterEnd: "rgba(200, 200, 200, 1)", | ||
borderShadowWidth: 0, | ||
borders: true, | ||
borderInnerWidth: 0, | ||
borderMiddleWidth: 0, | ||
borderOuterWidth: 5, | ||
colorBorderOuter: "#fafafa", | ||
colorBorderOuterEnd: "#cdcdcd", | ||
needleType: "arrow", | ||
needleWidth: 2, | ||
needleCircleSize: 7, | ||
needleCircleOuter: true, | ||
needleCircleInner: false, | ||
animationDuration: 1500, | ||
animationRule: "dequint", | ||
fontNumbers: "Verdana", | ||
fontTitle: "Verdana", | ||
fontUnits: "Verdana", | ||
fontValue: "Led", | ||
fontValueStyle: 'italic', | ||
fontNumbersSize: 20, | ||
fontNumbersStyle: 'italic', | ||
fontNumbersWeight: 'bold', | ||
fontTitleSize: 24, | ||
fontUnitsSize: 22, | ||
fontValueSize: 50, | ||
animatedValue: true | ||
}); | ||
gaugePS.draw(); | ||
gaugePS.value = "510"; | ||
</script> | ||
|
||
</body> | ||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
/*! | ||
* @license | ||
* Minimalistic HTML5 Canvas Gauge implementation | ||
* The MIT License (MIT) | ||
* | ||
* This code is subject to MIT license. | ||
* | ||
* Copyright (c) 2012 Mykhailo Stadnyk <[email protected]> | ||
* Copyright (c) 2016 Mykhailo Stadnyk <[email protected]> | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,26 @@ | ||
/*! | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2016 Mykhailo Stadnyk <[email protected]> | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
require('./polyfill'); | ||
|
||
const SmartCanvas = require('./SmartCanvas'); | ||
|
@@ -133,6 +156,12 @@ export default class BaseGauge { | |
* @param {number} value | ||
*/ | ||
set value(value) { | ||
value = parseFloat(value); | ||
|
||
if (isNaN(value) || !isFinite(value)) { | ||
value = this.options.minValue; | ||
} | ||
|
||
let fromValue = this.options.value; | ||
|
||
if (value === this.options.value) return; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
/*! | ||
* @license | ||
* Minimalistic HTML5 Canvas Gauge implementation | ||
* The MIT License (MIT) | ||
* | ||
* This code is subject to MIT license. | ||
* | ||
* Copyright (c) 2012 Mykhailo Stadnyk <[email protected]> | ||
* Copyright (c) 2016 Mykhailo Stadnyk <[email protected]> | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
/*! | ||
* @license | ||
* Minimalistic HTML5 Canvas Gauge implementation | ||
* The MIT License (MIT) | ||
* | ||
* This code is subject to MIT license. | ||
* | ||
* Copyright (c) 2012 Mykhailo Stadnyk <[email protected]> | ||
* Copyright (c) 2016 Mykhailo Stadnyk <[email protected]> | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
/*! | ||
* @license | ||
* Minimalistic HTML5 Canvas Gauge implementation | ||
* The MIT License (MIT) | ||
* | ||
* This code is subject to MIT license. | ||
* | ||
* Copyright (c) 2012 Mykhailo Stadnyk <[email protected]> | ||
* Copyright (c) 2016 Mykhailo Stadnyk <[email protected]> | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
|
@@ -43,7 +40,7 @@ | |
/** | ||
* Shared generic gauges options | ||
* | ||
* @type {{renderTo: RenderTarget, width: number, height: number, minValue: number, maxValue: number, value: number, units: string|boolean, majorTicks: number[]|string[], minorTicks: number, strokeTicks: boolean, animatedValue: boolean, animateOnInit: boolean, title: string|boolean, borders: boolean, valueInt: number, valueDec: number, majorTicksInt: number, majorTicksDec: number, animation: boolean, animationDuration: number, animationRule: string|AnimationRule, colorPlate: string, colorPlateEnd: string, colorMajorTicks: string, colorMinorTicks: string, colorTitle: string, colorUnits: string, colorNumbers: string, colorNeedle: string, colorNeedleEnd: string, colorValueText: string, colorValueTextShadow: string, colorBorderShadow: string, colorBorderOuter: string, colorBorderOuterEnd: string, colorBorderMiddle: string, colorBorderMiddleEnd: string, colorBorderInner: string, colorBorderInnerEnd: string, colorValueBoxRect: string, colorValueBoxRectEnd: string, colorValueBoxBackground: string, colorValueBoxShadow: string, colorNeedleShadowUp: string, colorNeedleShadowDown: string, needle: boolean, needleShadow: boolean, needleType: string, needleStart: number, needleEnd: number, needleWidth: number, borderOuterWidth: number, borderMiddleWidth: number, borderInnerWidth: number, borderShadowWidth: number, valueBox: boolean, valueBoxStroke: number, valueText: string, valueTextShadow: boolean, valueBoxBorderRadius: number, highlights: Highlight[], fontNumbers: string, fontTitle: string, fontUnits: string, fontValue: string, fontTitleSize: number, fontValueSize: number, fontUnitsSize: number, fontNumbersSize: number}} GenericOptions | ||
* @type {{renderTo: RenderTarget, width: number, height: number, minValue: number, maxValue: number, value: number, units: string|boolean, majorTicks: number[]|string[], minorTicks: number, strokeTicks: boolean, animatedValue: boolean, animateOnInit: boolean, title: string|boolean, borders: boolean, valueInt: number, valueDec: number, majorTicksInt: number, majorTicksDec: number, animation: boolean, animationDuration: number, animationRule: string|AnimationRule, colorPlate: string, colorPlateEnd: string, colorMajorTicks: string, colorMinorTicks: string, colorTitle: string, colorUnits: string, colorNumbers: string, colorNeedle: string, colorNeedleEnd: string, colorValueText: string, colorValueTextShadow: string, colorBorderShadow: string, colorBorderOuter: string, colorBorderOuterEnd: string, colorBorderMiddle: string, colorBorderMiddleEnd: string, colorBorderInner: string, colorBorderInnerEnd: string, colorValueBoxRect: string, colorValueBoxRectEnd: string, colorValueBoxBackground: string, colorValueBoxShadow: string, colorNeedleShadowUp: string, colorNeedleShadowDown: string, needle: boolean, needleShadow: boolean, needleType: string, needleStart: number, needleEnd: number, needleWidth: number, borderOuterWidth: number, borderMiddleWidth: number, borderInnerWidth: number, borderShadowWidth: number, valueBox: boolean, valueBoxStroke: number, valueText: string, valueTextShadow: boolean, valueBoxBorderRadius: number, highlights: Highlight[], fontNumbers: string, fontTitle: string, fontUnits: string, fontValue: string, fontTitleSize: number, fontValueSize: number, fontUnitsSize: number, fontNumbersSize: number, fontNumbersStyle: string, fontTitleStyle: string, fontUnitsStyle: string, fontValueStyle: string, fontNumbersWeight: string, fontTitleWeight: string, fontUnitsWeight: string, fontValueWeight: string}} GenericOptions | ||
*/ | ||
const GenericOptions = { | ||
// basic options | ||
|
@@ -109,6 +106,16 @@ const GenericOptions = { | |
fontUnitsSize: 22, | ||
fontValueSize: 40, | ||
|
||
fontNumbersStyle: 'normal', | ||
fontTitleStyle: 'normal', | ||
fontUnitsStyle: 'normal', | ||
fontValueStyle: 'normal', | ||
|
||
fontNumbersWeight: 'normal', | ||
fontTitleWeight: 'normal', | ||
fontUnitsWeight: 'normal', | ||
fontValueWeight: 'normal', | ||
|
||
// needle | ||
needle: true, | ||
needleShadow: true, | ||
|
Oops, something went wrong.