mirror of https://github.com/apache/superset.git
Improvements to bubble chart
This commit is contained in:
parent
c3bec3e35b
commit
b88f2825ea
|
@ -75,7 +75,7 @@ def load_world_bank_health_n_pop():
|
||||||
obj = db.session.query(TBL).filter_by(table_name=tbl).first()
|
obj = db.session.query(TBL).filter_by(table_name=tbl).first()
|
||||||
if not obj:
|
if not obj:
|
||||||
obj = TBL(table_name='wb_health_population')
|
obj = TBL(table_name='wb_health_population')
|
||||||
obj.main_dttm_col = 'ds'
|
obj.main_dttm_col = 'year'
|
||||||
obj.database = get_or_create_db(db.session)
|
obj.database = get_or_create_db(db.session)
|
||||||
models.Table
|
models.Table
|
||||||
db.session.add(obj)
|
db.session.add(obj)
|
||||||
|
|
|
@ -28,6 +28,8 @@ function viz_nvd3(slice) {
|
||||||
var data = payload.data;
|
var data = payload.data;
|
||||||
var viz = payload;
|
var viz = payload;
|
||||||
var viz_type = viz.form_data.viz_type;
|
var viz_type = viz.form_data.viz_type;
|
||||||
|
var fd = viz.form_data;
|
||||||
|
var f = d3.format('.4s');
|
||||||
nv.addGraph(function() {
|
nv.addGraph(function() {
|
||||||
if (viz_type === 'line') {
|
if (viz_type === 'line') {
|
||||||
if (viz.form_data.show_brush) {
|
if (viz.form_data.show_brush) {
|
||||||
|
@ -106,10 +108,25 @@ function viz_nvd3(slice) {
|
||||||
chart.yAxis.tickFormat(d3.format('.3p'));
|
chart.yAxis.tickFormat(d3.format('.3p'));
|
||||||
|
|
||||||
} else if (viz_type === 'bubble') {
|
} else if (viz_type === 'bubble') {
|
||||||
|
var row = function(col1, col2){
|
||||||
|
return "<tr><td>" + col1 + "</td><td>" + col2 + "</td></r>"
|
||||||
|
}
|
||||||
chart = nv.models.scatterChart();
|
chart = nv.models.scatterChart();
|
||||||
|
chart.showDistX(true);
|
||||||
|
chart.showDistY(true);
|
||||||
chart.xAxis.tickFormat(d3.format('.3s'));
|
chart.xAxis.tickFormat(d3.format('.3s'));
|
||||||
chart.yAxis.tickFormat(d3.format('.3s'));
|
chart.yAxis.tickFormat(d3.format('.3s'));
|
||||||
chart.showLegend(viz.form_data.show_legend);
|
chart.showLegend(fd.show_legend);
|
||||||
|
chart.tooltip.contentGenerator(function (obj) {
|
||||||
|
p = obj.point;
|
||||||
|
var s = "<table>"
|
||||||
|
s += '<tr><td style="color:' + p.color + ';"><strong>' + p[fd.entity] + '</strong> (' + p.group + ')</td></tr>';
|
||||||
|
s += row(fd.x, f(p.x));
|
||||||
|
s += row(fd.y, f(p.y));
|
||||||
|
s += row(fd.size, f(p.size));
|
||||||
|
s += "</table>";
|
||||||
|
return s;
|
||||||
|
});
|
||||||
chart.pointRange([5, 5000]);
|
chart.pointRange([5, 5000]);
|
||||||
|
|
||||||
} else if (viz_type === 'area') {
|
} else if (viz_type === 'area') {
|
||||||
|
|
|
@ -472,8 +472,8 @@ class BubbleViz(NVD3Viz):
|
||||||
'fields': (
|
'fields': (
|
||||||
('since', 'until'),
|
('since', 'until'),
|
||||||
('series', 'entity'),
|
('series', 'entity'),
|
||||||
('x', 'y'),
|
'x', 'y', 'size',
|
||||||
('size', 'limit'),
|
'limit',
|
||||||
('x_log_scale', 'y_log_scale'),
|
('x_log_scale', 'y_log_scale'),
|
||||||
('show_legend', None),
|
('show_legend', None),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue