Skip to content

Commit

Permalink
Revert "measure x axis labels too and use the longest to determine ma…
Browse files Browse the repository at this point in the history
…rgins" (apache#2550)

This reverts commit cc640c1.
  • Loading branch information
Alanna Scott authored Apr 5, 2017
1 parent 3d2c791 commit fe68bc3
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions superset/assets/visualizations/big_number.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@ function getNumTicks(data, slice, margin) {
return numTicks;
}

function getMargin(valueExt, data, f) {
const yAxisLabelWidths = valueExt.map(value => getTextWidth(f(value), '10px Roboto'));
const xAxisLabelWidths = data.map(d => getTextWidth(formatDate(d[0]), '10px Roboto'));
const yAxisMaxWidth = Math.max(...yAxisLabelWidths);
const xAxisMaxWidth = Math.max(...xAxisLabelWidths);
let margin;
if (yAxisMaxWidth > xAxisMaxWidth) {
margin = yAxisMaxWidth + (yAxisMaxWidth / 2);
} else if (xAxisMaxWidth > yAxisMaxWidth) {
margin = xAxisMaxWidth + (xAxisMaxWidth / 2);
}
return margin;
}

function bigNumberVis(slice, payload) {
const div = d3.select(slice.selector);
// Define the percentage bounds that define color from red to green
Expand Down Expand Up @@ -62,7 +48,10 @@ function bigNumberVis(slice, payload) {
}
const dateExt = d3.extent(data, (d) => d[0]);
const valueExt = d3.extent(data, (d) => d[1]);
const margin = getMargin(valueExt, data, f);
const yAxisLabelWidths = valueExt.map(value => getTextWidth(f(value), '10px Roboto'));
const yAxisMaxWidth = Math.max(...yAxisLabelWidths);
const margin = yAxisMaxWidth + (yAxisMaxWidth / 2);

const scaleX = d3.time.scale.utc().domain(dateExt).range([margin, width - margin]);
const scaleY = d3.scale.linear().domain(valueExt).range([height - (margin), margin]);
const colorRange = [d3.hsl(0, 1, 0.3), d3.hsl(120, 1, 0.3)];
Expand Down

0 comments on commit fe68bc3

Please sign in to comment.