Skip to content

Commit

Permalink
Merge pull request #65 from Mikhus/v2.0.6
Browse files Browse the repository at this point in the history
Version 2.0.6
  • Loading branch information
Mikhus authored Sep 27, 2016
2 parents 54bed9a + 5fe977d commit 807a2fc
Show file tree
Hide file tree
Showing 19 changed files with 316 additions and 112 deletions.
29 changes: 15 additions & 14 deletions LICENSE
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.
2 changes: 1 addition & 1 deletion bower.json
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]>"
Expand Down
102 changes: 102 additions & 0 deletions examples/issue-63.html
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>
27 changes: 25 additions & 2 deletions gauge.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gauge.min.js.map

Large diffs are not rendered by default.

23 changes: 19 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const replace = require('gulp-replace');
const babel = require('gulp-babel');
const fsc = require('fs-cli');
const semver = require('semver');
const inject = require('gulp-inject-string');

/**
* @typedef {{argv: object}} yargs
Expand Down Expand Up @@ -72,6 +73,16 @@ function es6concat(type = 'all') {
.pipe(replace(/export\s+(default\s+)?(GenericOptions;)?/g, ''));
}

function license() {
let src = fs.readFileSync('./LICENSE')
.toString()
.split(/\r?\n/);

src.pop();

return '/*!\n * ' + src.join('\n * ') + '\n */\n';
}

/**
* Displays this usage information.
*
Expand Down Expand Up @@ -100,7 +111,7 @@ gulp.task('build:prod', done => {
resolve();
})
.pipe(rename('gauge.min.js'))
.pipe(replace(/^/, '(function(ns) {'))
.pipe(replace(/^/, license() + '(function(ns) {'))
.pipe(replace(/$/,
';typeof module !== "undefined" && Object.assign(ns, {' +
'Collection: Collection,' +
Expand All @@ -113,7 +124,9 @@ gulp.task('build:prod', done => {
'});' +
'}(typeof module !== "undefined" ? ' +
'module.exports : window));'))
.pipe(uglify())
.pipe(uglify({
preserveComments: (node, comment) => comment.line === 1
}))
.pipe(gulp.dest('dist/' + type))
.on('end', () => {
let pkg = JSON.parse(fs.readFileSync('./package.json'));
Expand Down Expand Up @@ -253,7 +266,7 @@ gulp.task('build:es5', ['clean'], () => {
})
//.pipe(gulp.dest('.'))
.pipe(rename('gauge.min.js'))
.pipe(replace(/^/, '(function(ns) {'))
.pipe(replace(/^/, license() + '(function(ns) {'))
.pipe(replace(/$/,
';typeof module !== "undefined" && Object.assign(ns, {' +
'Collection: Collection,' +
Expand All @@ -266,7 +279,9 @@ gulp.task('build:es5', ['clean'], () => {
'});' +
'}(typeof module !== "undefined" ? module.exports : window));'))
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(uglify())
.pipe(uglify({
preserveComments: (node, comment) => comment.line === 1
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('.'))
.on('end', () => {
Expand Down
7 changes: 2 additions & 5 deletions lib/Animation.js
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
Expand Down
29 changes: 29 additions & 0 deletions lib/BaseGauge.js
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');
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions lib/Collection.js
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
Expand Down
7 changes: 2 additions & 5 deletions lib/DomObserver.js
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
Expand Down
19 changes: 13 additions & 6 deletions lib/GenericOptions.js
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 807a2fc

Please sign in to comment.