Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c99fdd7

Browse files
committed
angular gauge: make value band thinner as in bullet
1 parent a554ff7 commit c99fdd7

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/traces/indicator/constants.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
module.exports = {
1212
INCREASING_COLOR: '#3D9970',
1313
DECREASING_COLOR: '#FF4136',
14-
// TODO: DIRSYMBOL into attributes
14+
// TODO: make the following constants overridable via attributes
1515
DIRSYMBOL: {
1616
increasing: '▲',
1717
decreasing: '▼'
1818
},
19-
innerRadius: 0.75
19+
bulletHeight: 35,
20+
innerRadius: 0.75,
21+
valueHeight: 0.5
2022
};

src/traces/indicator/plot.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@ module.exports = function plot(gd, cdModule, transitionOpts, makeOnCompleteCallb
245245
.innerRadius(innerRadius).outerRadius(radius)
246246
.startAngle(-theta);
247247

248+
var valueArcPath = d3.svg.arc()
249+
.innerRadius((innerRadius + radius) / 2 - cn.valueHeight / 2 * (radius - innerRadius))
250+
.outerRadius((innerRadius + radius) / 2 + cn.valueHeight / 2 * (radius - innerRadius))
251+
.startAngle(-theta);
252+
248253
// TODO: DRY up the following code to draw the different arcs
249254
// Draw background
250255
var bgArc = gauge.selectAll('g.bgArc').data(cd);
@@ -278,10 +283,10 @@ module.exports = function plot(gd, cdModule, transitionOpts, makeOnCompleteCallb
278283
.ease(transitionOpts.easing)
279284
.each('end', function() { onComplete && onComplete(); })
280285
.each('interrupt', function() { onComplete && onComplete(); })
281-
.attrTween('d', arcTween(arcPath, valueToAngle(cd[0].lastY), valueToAngle(cd[0].y)));
286+
.attrTween('d', arcTween(valueArcPath, valueToAngle(cd[0].lastY), valueToAngle(cd[0].y)));
282287
} else {
283288
fgArcPath
284-
.attr('d', arcPath.endAngle(valueToAngle(cd[0].y)));
289+
.attr('d', valueArcPath.endAngle(valueToAngle(cd[0].y)));
285290
}
286291
fgArcPath
287292
.style('fill', trace.gauge.value.color)
@@ -376,8 +381,8 @@ module.exports = function plot(gd, cdModule, transitionOpts, makeOnCompleteCallb
376381
// Axes.drawOne(gd, xa);
377382
// Axes.drawOne(gd, ya);
378383
// }
379-
var bulletHeight = 35;
380-
var innerBulletHeight = 0.6 * bulletHeight;
384+
var bulletHeight = cn.bulletHeight;
385+
var innerBulletHeight = cn.valueHeight * bulletHeight;
381386
var bulletVerticalMargin = bignumberVerticalMargin - bulletHeight / 2;
382387
var bullet = d3.select(this).selectAll('g.bullet').data(data);
383388
bullet.enter().append('g').classed('bullet', true);

0 commit comments

Comments
 (0)