mirror of https://github.com/apache/superset.git
[big_number*] fixing a few bugs (#342)
This commit is contained in:
parent
a76ccf462d
commit
21b3a5f199
|
@ -32,10 +32,10 @@ function bigNumberVis(slice) {
|
|||
var compare_suffix = ' ' + json.compare_suffix;
|
||||
var v_compare = null;
|
||||
var v = null;
|
||||
if (data.length > 1) {
|
||||
if (fd.viz_type === 'big_number') {
|
||||
v = data[data.length - 1][1];
|
||||
} else {
|
||||
v = data[data.length - 1][0];
|
||||
v = data[0][0];
|
||||
}
|
||||
if (json.compare_lag > 0) {
|
||||
var pos = data.length - (json.compare_lag + 1);
|
||||
|
@ -67,8 +67,23 @@ function bigNumberVis(slice) {
|
|||
})
|
||||
.interpolate("basis");
|
||||
|
||||
//Drawing trend line
|
||||
var g = svg.append('g');
|
||||
var y = height / 2;
|
||||
//Printing big number
|
||||
g.append('text')
|
||||
.attr('x', width / 2)
|
||||
.attr('y', y)
|
||||
.attr('class', 'big')
|
||||
.attr('alignment-baseline', 'middle')
|
||||
.attr('id', 'bigNumber')
|
||||
.style('font-weight', 'bold')
|
||||
.style('cursor', 'pointer')
|
||||
.text(f(v))
|
||||
.style('font-size', d3.min([height, width]) / 3.5)
|
||||
.attr('fill', 'white');
|
||||
|
||||
if (fd.viz_type === 'big_number') {
|
||||
//Drawing trend line
|
||||
|
||||
g.append('path')
|
||||
.attr('d', function (d) {
|
||||
|
@ -84,24 +99,10 @@ function bigNumberVis(slice) {
|
|||
.attr('class', 'digits')
|
||||
.attr('opacity', 1);
|
||||
|
||||
var y = height / 2;
|
||||
if (v_compare !== null) {
|
||||
y = (height / 8) * 3;
|
||||
}
|
||||
|
||||
//Printing big number
|
||||
g.append('text')
|
||||
.attr('x', width / 2)
|
||||
.attr('y', y)
|
||||
.attr('class', 'big')
|
||||
.attr('alignment-baseline', 'middle')
|
||||
.attr('id', 'bigNumber')
|
||||
.style('font-weight', 'bold')
|
||||
.style('cursor', 'pointer')
|
||||
.text(f(v))
|
||||
.style('font-size', d3.min([height, width]) / 3.5)
|
||||
.attr('fill', 'white');
|
||||
|
||||
//Printing big number subheader text
|
||||
if (json.subheader !== null) {
|
||||
g.append('text')
|
||||
|
@ -168,6 +169,7 @@ function bigNumberVis(slice) {
|
|||
div.select('g.digits').transition().duration(500).attr('opacity', 1);
|
||||
div.select('g.axis').transition().duration(500).attr('opacity', 0);
|
||||
});
|
||||
}
|
||||
slice.done(payload);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue