Skip to content

Commit e6d9e33

Browse files
authored
Merge pull request #72 from Mikhus/v2.0.8
Merge release 2.0.8 branch into master
2 parents 7c085d7 + 5336d7c commit e6d9e33

14 files changed

+305
-186
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "canvas-gauges",
3-
"version": "2.0.7",
3+
"version": "2.0.8",
44
"homepage": "https://github.com/Mikhus/canvas-gauges",
55
"authors": [
66
"Mykhailo Stadnyk <mikhus@gmail.com>"

docs-coverage.svg

+1-1
Loading

examples/linear-component.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,21 @@
1616
data-width="160"
1717
data-height="600"
1818
data-border-radius="20"
19-
data-borders="0"
19+
data-borders="true"
2020
data-bar-stroke-width="20"
2121
data-minor-ticks="10"
2222
data-major-ticks="0,10,20,30,40,50,60,70,80,90,100"
2323
data-color-numbers="red,green,blue,transparent,#ccc,#ccc,#ccc,#ccc,#ccc,#ccc,#ccc"
2424
data-color-major-ticks="red,green,blue,transparent,#ccc,#ccc,#ccc,#ccc,#ccc,#ccc,#ccc"
25+
data-color-bar-stroke="#444"
2526
data-value="22.3"
2627
data-units="°C"
2728
data-color-value-box-shadow="false"
2829
data-tick-side="left"
2930
data-number-side="left"
3031
data-needle-side="left"
3132
data-animate-on-init="true"
33+
data-color-plate="transparent"
3234
></canvas>
3335

3436
<canvas data-type="linear-gauge"

examples/radial-component.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
{ "from": 150, "to": 200, "color": "rgba(255,0,225,.25)" },
3434
{ "from": 200, "to": 220, "color": "rgba(0,0,255,.25)" }
3535
]'
36-
data-color-plate="#222"
36+
data-color-plate="transparent"
3737
data-color-major-ticks="#f5f5f5"
3838
data-color-minor-ticks="#ddd"
3939
data-color-title="#fff"
@@ -46,6 +46,9 @@
4646
data-animation-duration="500"
4747
data-font-value="Led"
4848
data-font-numbers="Led"
49+
data-border-outer-width="3"
50+
data-border-middle-width="3"
51+
data-border-inner-width="3"
4952
></canvas>
5053

5154
<canvas data-type="radial-gauge"
@@ -85,6 +88,7 @@
8588
data-ticks-angle="250"
8689
data-start-angle="55"
8790
data-color-needle-shadow-down="#333"
91+
data-value-box-width="45"
8892
></canvas>
8993

9094
<canvas data-type="radial-gauge"

gauge.min.js

+4-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gauge.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

+52-62
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const babel = require('gulp-babel');
3030
const fsc = require('fs-cli');
3131
const semver = require('semver');
3232
const inject = require('gulp-inject-string');
33+
const version = require('./package.json').version;
3334

3435
/**
3536
* @typedef {{argv: object}} yargs
@@ -70,7 +71,50 @@ function es6concat(type = 'all') {
7071
.pipe(concat('gauge.es6.js'))
7172
.pipe(replace(/((var|const|let)\s+.*?=\s*)?require\(.*?\);?/g, ''))
7273
.pipe(replace(/(module\.)?exports(.default)?\s+=\s*.*?\r?\n/g, ''))
73-
.pipe(replace(/export\s+(default\s+)?(GenericOptions;)?/g, ''));
74+
.pipe(replace(/export\s+(default\s+)?(GenericOptions;)?/g, ''))
75+
.pipe(replace(/%VERSION%/g, version));
76+
}
77+
78+
function es5transpile(type = 'all', withSourceMaps = true, resolve = () => {}) {
79+
let stream = es6concat(type)
80+
.pipe(rename('gauge.es5.js'))
81+
.pipe(babel({
82+
presets: ['es2015'],
83+
compact: false
84+
}))
85+
.on('error', function(err) {
86+
gutil.log(err);
87+
this.emit('end');
88+
resolve();
89+
})
90+
.pipe(rename('gauge.min.js'))
91+
.pipe(replace(/^/, license() + '(function(ns) {'))
92+
.pipe(replace(/$/,
93+
';typeof module !== "undefined" && Object.assign(ns, {' +
94+
'Collection: Collection,' +
95+
'GenericOptions: GenericOptions,' +
96+
'Animation: Animation,' +
97+
'BaseGauge: BaseGauge,' +
98+
'drawings: drawings,' +
99+
'SmartCanvas: SmartCanvas,' +
100+
'vendorize: vendorize' +
101+
'});' +
102+
'}(typeof module !== "undefined" ? ' +
103+
'module.exports : window));'));
104+
105+
if (withSourceMaps) {
106+
stream = stream.pipe(sourcemaps.init({ loadMaps: true }));
107+
}
108+
109+
stream = stream.pipe(uglify({
110+
preserveComments: (node, comment) => comment.line === 1
111+
}));
112+
113+
if (withSourceMaps) {
114+
stream = stream.pipe(sourcemaps.write('.'));
115+
}
116+
117+
return stream;
74118
}
75119

76120
function license() {
@@ -80,7 +124,8 @@ function license() {
80124

81125
src.pop();
82126

83-
return '/*!\n * ' + src.join('\n * ') + '\n */\n';
127+
return '/*!\n * ' + src.join('\n * ') + '\n *\n * @version ' +
128+
version + '\n */\n';
84129
}
85130

86131
/**
@@ -99,34 +144,7 @@ gulp.task('build:prod', done => {
99144
rimraf('dist', () => {
100145
Promise.all(types.map(type => {
101146
return new Promise(resolve => {
102-
es6concat(type)
103-
.pipe(rename('gauge.es5.js'))
104-
.pipe(babel({
105-
presets: ['es2015'],
106-
compact: false
107-
}))
108-
.on('error', function(err) {
109-
gutil.log(err);
110-
this.emit('end');
111-
resolve();
112-
})
113-
.pipe(rename('gauge.min.js'))
114-
.pipe(replace(/^/, license() + '(function(ns) {'))
115-
.pipe(replace(/$/,
116-
';typeof module !== "undefined" && Object.assign(ns, {' +
117-
'Collection: Collection,' +
118-
'GenericOptions: GenericOptions,' +
119-
'Animation: Animation,' +
120-
'BaseGauge: BaseGauge,' +
121-
'drawings: drawings,' +
122-
'SmartCanvas: SmartCanvas,' +
123-
'vendorize: vendorize' +
124-
'});' +
125-
'}(typeof module !== "undefined" ? ' +
126-
'module.exports : window));'))
127-
.pipe(uglify({
128-
preserveComments: (node, comment) => comment.line === 1
129-
}))
147+
es5transpile(type, false, resolve)
130148
.pipe(gulp.dest('dist/' + type))
131149
.on('end', () => {
132150
let pkg = JSON.parse(fs.readFileSync('./package.json'));
@@ -159,7 +177,6 @@ gulp.task('build:prod', done => {
159177
});
160178
});
161179
})).then(() => {
162-
let version = require('./package.json').version;
163180
let cmd = '';
164181

165182
console.log(chalk.bold.green('Production packages are now ready!'));
@@ -253,36 +270,8 @@ gulp.task('build:es6', ['clean'], () => {
253270
* @task {build:es5}
254271
* @arg {type} build type: 'radial' - Gauge object only, 'linear' - LinearGauge object only, 'all' - everything (default)
255272
*/
256-
gulp.task('build:es5', ['clean'], () => {
257-
es6concat(yargs.argv.type || 'all')
258-
.pipe(rename('gauge.es5.js'))
259-
.pipe(babel({
260-
presets: ['es2015'],
261-
compact: false
262-
}))
263-
.on('error', function(err) {
264-
gutil.log(err);
265-
this.emit('end');
266-
})
267-
//.pipe(gulp.dest('.'))
268-
.pipe(rename('gauge.min.js'))
269-
.pipe(replace(/^/, license() + '(function(ns) {'))
270-
.pipe(replace(/$/,
271-
';typeof module !== "undefined" && Object.assign(ns, {' +
272-
'Collection: Collection,' +
273-
'GenericOptions: GenericOptions,' +
274-
'Animation: Animation,' +
275-
'BaseGauge: BaseGauge,' +
276-
'drawings: drawings,' +
277-
'SmartCanvas: SmartCanvas,' +
278-
'vendorize: vendorize' +
279-
'});' +
280-
'}(typeof module !== "undefined" ? module.exports : window));'))
281-
.pipe(sourcemaps.init({ loadMaps: true }))
282-
.pipe(uglify({
283-
preserveComments: (node, comment) => comment.line === 1
284-
}))
285-
.pipe(sourcemaps.write('.'))
273+
gulp.task('build:es5', ['clean'], done => {
274+
es5transpile(yargs.argv.type || 'all')
286275
.pipe(gulp.dest('.'))
287276
.on('end', () => {
288277
if (!process.env.TRVIS) {
@@ -297,6 +286,8 @@ gulp.task('build:es5', ['clean'], () => {
297286
fs.readFileSync('gauge.min.js.map')
298287
);
299288
}
289+
290+
done();
300291
});
301292
});
302293

@@ -366,7 +357,6 @@ gulp.task('doc', ['clean:docs'], done => {
366357

367358
//move to pages
368359

369-
let version = require('./package.json').version;
370360
let target = '../canvas-gauges-pages/docs/' + version;
371361

372362
rimraf(target, () => fs.rename('docs', target, done));

lib/BaseGauge.js

+20
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@ const Animation = require('./Animation');
2828
const Collection = require('./Collection');
2929
const DomObserver = require('./DomObserver');
3030

31+
const version = '%VERSION%';
32+
3133
const round = Math.round;
3234
const abs = Math.abs;
3335

3436
let gauges = new Collection();
3537

38+
gauges.version = version;
39+
3640
/**
3741
* Basic abstract BaseGauge class implementing common functionality
3842
* for different type of gauges.
@@ -75,6 +79,13 @@ export default class BaseGauge {
7579

7680
gauges.push(this);
7781

82+
/**
83+
* Gauges version string
84+
*
85+
* @type {string}
86+
*/
87+
this.version = version;
88+
7889
/**
7990
* Gauge type class
8091
*
@@ -239,6 +250,15 @@ export default class BaseGauge {
239250
this.animation = null;
240251
}
241252

253+
/**
254+
* Returns gauges version string
255+
*
256+
* @return {string}
257+
*/
258+
static get version() {
259+
return version;
260+
}
261+
242262
/**
243263
* Triggering gauge render on a canvas.
244264
*

lib/GenericOptions.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
/**
4141
* Shared generic gauges options
4242
*
43-
* @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
43+
* @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, valueBoxWidth: number, valueBoxStroke: number, valueText: string, valueTextShadow: boolean, valueBoxBorderRadius: number, highlights: Highlight[], highlightsWidth: number, 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
4444
*/
4545
const GenericOptions = {
4646
// basic options
@@ -133,13 +133,17 @@ const GenericOptions = {
133133
// value and highlights
134134
valueBox: true,
135135
valueBoxStroke: 5,
136+
valueBoxWidth: 0,
136137
valueText: '',
137138
valueTextShadow: true,
138139
valueBoxBorderRadius: 2.5,
140+
141+
// highlights
139142
highlights: [
140143
{ from: 20, to: 60, color: '#eee' },
141144
{ from: 60, to: 80, color: '#ccc' },
142-
{ from: 80, to: 100, color: '#999' }]
145+
{ from: 80, to: 100, color: '#999' }],
146+
highlightsWidth: 15
143147
};
144148

145149
export default GenericOptions;

0 commit comments

Comments
 (0)