Fix gauge type selection (#45783) (#46328)

* Fix gauge type selection

* Get rid of angles in config
This commit is contained in:
Daniil Suleiman 2019-10-03 15:23:52 +03:00 committed by GitHub
parent 3be6c1569a
commit 91209659d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,12 +21,21 @@ import d3 from 'd3';
import _ from 'lodash'; import _ from 'lodash';
import { getHeatmapColors } from '../../components/color/heatmap_color'; import { getHeatmapColors } from '../../components/color/heatmap_color';
const arcAngles = {
angleFactor: 0.75,
maxAngle: 2 * Math.PI * 1.3,
minAngle: 2 * Math.PI * 0.7,
};
const circleAngles = {
angleFactor: 1,
maxAngle: 2 * Math.PI,
minAngle: 0,
};
const defaultConfig = { const defaultConfig = {
showTooltip: true, showTooltip: true,
percentageMode: true, percentageMode: true,
maxAngle: 2 * Math.PI * 1.3,
minAngle: 2 * Math.PI * 0.7,
innerSpace: 5, innerSpace: 5,
extents: [0, 10000], extents: [0, 10000],
scale: { scale: {
@ -163,15 +172,11 @@ export class MeterGauge {
} }
drawGauge(svg, data, width, height) { drawGauge(svg, data, width, height) {
const self = this;
const marginFactor = 0.95; const marginFactor = 0.95;
const tooltip = this.gaugeChart.tooltip; const tooltip = this.gaugeChart.tooltip;
const isTooltip = this.gaugeChart.handler.visConfig.get('addTooltip'); const isTooltip = this.gaugeChart.handler.visConfig.get('addTooltip');
const isDisplayWarning = this.gaugeChart.handler.visConfig.get('isDisplayWarning', false); const isDisplayWarning = this.gaugeChart.handler.visConfig.get('isDisplayWarning', false);
const { maxAngle, minAngle } = this.gaugeConfig.gaugeType === 'Circle' ? const { angleFactor, maxAngle, minAngle } = this.gaugeConfig.gaugeType === 'Circle' ? circleAngles : arcAngles;
{ maxAngle: 2 * Math.PI, minAngle: 0 } :
this.gaugeConfig;
const angleFactor = this.gaugeConfig.gaugeType === 'Arc' ? 0.75 : 1;
const maxRadius = (Math.min(width, height / angleFactor) / 2) * marginFactor; const maxRadius = (Math.min(width, height / angleFactor) / 2) * marginFactor;
const extendRange = this.gaugeConfig.extendRange; const extendRange = this.gaugeConfig.extendRange;
@ -248,9 +253,7 @@ export class MeterGauge {
const series = gauges const series = gauges
.append('path') .append('path')
.attr('d', arc) .attr('d', arc)
.style('fill', function (d) { .style('fill', (d) => this.getColorBucket(Math.max(min, d.y)));
return self.getColorBucket(Math.max(min, d.y));
});
const smallContainer = svg.node().getBBox().height < 70; const smallContainer = svg.node().getBBox().height < 70;
let hiddenLabels = smallContainer; let hiddenLabels = smallContainer;