gauge/goal should not try to display negative values (#13638)

* gauge/goal should not try to display negative values

* it should take ranges into account when looking for minimum
This commit is contained in:
Peter Pisljar 2017-09-04 08:08:14 +02:00 committed by ppisljar
parent 7d490fd64f
commit 7fff53fcb8

View file

@ -146,6 +146,7 @@ export function MeterGaugeProvider() {
}
drawGauge(svg, data, width, height) {
const self = this;
const marginFactor = 0.95;
const tooltip = this.gaugeChart.tooltip;
const isTooltip = this.gaugeChart.handler.visConfig.get('addTooltip');
@ -171,7 +172,7 @@ export function MeterGaugeProvider() {
const arc = d3.svg.arc()
.startAngle(minAngle)
.endAngle(function (d) {
return Math.max(0, Math.min(maxAngle, angle(d.y)));
return Math.max(0, Math.min(maxAngle, angle(Math.max(min, d.y))));
})
.innerRadius(function (d, i, j) {
return Math.max(0, radius(j + 1) + gaugePadding);
@ -210,12 +211,11 @@ export function MeterGaugeProvider() {
.attr('d', bgArc)
.style('fill', this.gaugeConfig.style.bgFill);
const self = this;
const series = gauges
.append('path')
.attr('d', arc)
.style('fill', function (d) {
return self.getColorBucket(d.y);
return self.getColorBucket(Math.max(min, d.y));
});
const smallContainer = svg.node().getBBox().height < 70;