Skip to content

Commit

Permalink
Improvements to bubble chart
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Dec 23, 2015
1 parent c3bec3e commit b88f282
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion panoramix/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def load_world_bank_health_n_pop():
obj = db.session.query(TBL).filter_by(table_name=tbl).first()
if not obj:
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)
models.Table
db.session.add(obj)
Expand Down
19 changes: 18 additions & 1 deletion panoramix/static/widgets/viz_nvd3.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ function viz_nvd3(slice) {
var data = payload.data;
var viz = payload;
var viz_type = viz.form_data.viz_type;
var fd = viz.form_data;
var f = d3.format('.4s');
nv.addGraph(function() {
if (viz_type === 'line') {
if (viz.form_data.show_brush) {
Expand Down Expand Up @@ -106,10 +108,25 @@ function viz_nvd3(slice) {
chart.yAxis.tickFormat(d3.format('.3p'));

} else if (viz_type === 'bubble') {
var row = function(col1, col2){
return "<tr><td>" + col1 + "</td><td>" + col2 + "</td></r>"
}
chart = nv.models.scatterChart();
chart.showDistX(true);
chart.showDistY(true);
chart.xAxis.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]);

} else if (viz_type === 'area') {
Expand Down
4 changes: 2 additions & 2 deletions panoramix/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ class BubbleViz(NVD3Viz):
'fields': (
('since', 'until'),
('series', 'entity'),
('x', 'y'),
('size', 'limit'),
'x', 'y', 'size',
'limit',
('x_log_scale', 'y_log_scale'),
('show_legend', None),
)
Expand Down

0 comments on commit b88f282

Please sign in to comment.