mirror of
https://github.com/apache/superset.git
synced 2024-09-12 16:49:40 -04:00
[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 compare_suffix = ' ' + json.compare_suffix;
|
||||||
var v_compare = null;
|
var v_compare = null;
|
||||||
var v = null;
|
var v = null;
|
||||||
if (data.length > 1) {
|
if (fd.viz_type === 'big_number') {
|
||||||
v = data[data.length - 1][1];
|
v = data[data.length - 1][1];
|
||||||
} else {
|
} else {
|
||||||
v = data[data.length - 1][0];
|
v = data[0][0];
|
||||||
}
|
}
|
||||||
if (json.compare_lag > 0) {
|
if (json.compare_lag > 0) {
|
||||||
var pos = data.length - (json.compare_lag + 1);
|
var pos = data.length - (json.compare_lag + 1);
|
||||||
@ -67,8 +67,23 @@ function bigNumberVis(slice) {
|
|||||||
})
|
})
|
||||||
.interpolate("basis");
|
.interpolate("basis");
|
||||||
|
|
||||||
//Drawing trend line
|
|
||||||
var g = svg.append('g');
|
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')
|
g.append('path')
|
||||||
.attr('d', function (d) {
|
.attr('d', function (d) {
|
||||||
@ -84,24 +99,10 @@ function bigNumberVis(slice) {
|
|||||||
.attr('class', 'digits')
|
.attr('class', 'digits')
|
||||||
.attr('opacity', 1);
|
.attr('opacity', 1);
|
||||||
|
|
||||||
var y = height / 2;
|
|
||||||
if (v_compare !== null) {
|
if (v_compare !== null) {
|
||||||
y = (height / 8) * 3;
|
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
|
//Printing big number subheader text
|
||||||
if (json.subheader !== null) {
|
if (json.subheader !== null) {
|
||||||
g.append('text')
|
g.append('text')
|
||||||
@ -168,6 +169,7 @@ function bigNumberVis(slice) {
|
|||||||
div.select('g.digits').transition().duration(500).attr('opacity', 1);
|
div.select('g.digits').transition().duration(500).attr('opacity', 1);
|
||||||
div.select('g.axis').transition().duration(500).attr('opacity', 0);
|
div.select('g.axis').transition().duration(500).attr('opacity', 0);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
slice.done(payload);
|
slice.done(payload);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user