Skip to content

Commit

Permalink
Fixing the examples's dashboard positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Jun 23, 2016
1 parent ab71ee4 commit c7dc10b
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 103 deletions.
211 changes: 109 additions & 102 deletions caravel/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,67 +383,74 @@ def load_world_bank_health_n_pop():
js = textwrap.dedent("""\
[
{
"size_y": 4,
"col": 1,
"row": 0,
"size_x": 2,
"col": 9,
"slice_id": "605",
"row": 6
"size_y": 2,
"slice_id": "1231"
},
{
"size_y": 4,
"col": 1,
"row": 2,
"size_x": 2,
"col": 11,
"slice_id": "606",
"row": 6
},
{
"size_y": 2,
"size_x": 2,
"col": 1,
"slice_id": "607",
"row": 0
"slice_id": "1232"
},
{
"size_y": 2,
"size_x": 2,
"col": 3,
"slice_id": "608",
"row": 0
"col": 10,
"row": 0,
"size_x": 3,
"size_y": 7,
"slice_id": "1233"
},
{
"col": 1,
"row": 4,
"size_x": 6,
"size_y": 3,
"size_x": 8,
"col": 5,
"slice_id": "609",
"row": 3
"slice_id": "1234"
},
{
"col": 3,
"row": 0,
"size_x": 7,
"size_y": 4,
"slice_id": "1235"
},
{
"col": 5,
"row": 7,
"size_x": 8,
"col": 1,
"slice_id": "610",
"row": 6
"size_y": 4,
"slice_id": "1236"
},
{
"col": 7,
"row": 4,
"size_x": 3,
"size_y": 3,
"size_x": 4,
"col": 9,
"slice_id": "611",
"row": 0
"slice_id": "1237"
},
{
"size_y": 3,
"col": 1,
"row": 7,
"size_x": 4,
"col": 5,
"slice_id": "612",
"row": 0
"size_y": 4,
"slice_id": "1238"
},
{
"size_y": 4,
"col": 9,
"row": 11,
"size_x": 4,
"size_y": 4,
"slice_id": "1239"
},
{
"col": 1,
"slice_id": "613",
"row": 2
"row": 11,
"size_x": 8,
"size_y": 4,
"slice_id": "1240"
}
]
""")
Expand Down Expand Up @@ -729,71 +736,71 @@ def load_birth_names():
if not dash:
dash = Dash()
js = textwrap.dedent("""\
[
{
"size_y": 4,
"size_x": 2,
"col": 8,
"slice_id": "85",
"row": 7
},
{
"size_y": 4,
"size_x": 2,
"col": 10,
"slice_id": "86",
"row": 7
},
{
"size_y": 2,
"size_x": 2,
"col": 1,
"slice_id": "87",
"row": 1
},
{
"size_y": 2,
"size_x": 2,
"col": 3,
"slice_id": "88",
"row": 1
},
{
"size_y": 3,
"size_x": 7,
"col": 5,
"slice_id": "89",
"row": 4
},
{
"size_y": 4,
"size_x": 7,
"col": 1,
"slice_id": "90",
"row": 7
},
{
"size_y": 3,
"size_x": 3,
"col": 9,
"slice_id": "91",
"row": 1
},
{
"size_y": 3,
"size_x": 4,
"col": 5,
"slice_id": "92",
"row": 1
},
{
"size_y": 4,
"size_x": 4,
"col": 1,
"slice_id": "93",
"row": 3
}
]
[
{
"col": 9,
"row": 6,
"size_x": 2,
"size_y": 4,
"slice_id": "1267"
},
{
"col": 11,
"row": 6,
"size_x": 2,
"size_y": 4,
"slice_id": "1268"
},
{
"col": 1,
"row": 0,
"size_x": 2,
"size_y": 2,
"slice_id": "1269"
},
{
"col": 3,
"row": 0,
"size_x": 2,
"size_y": 2,
"slice_id": "1270"
},
{
"col": 5,
"row": 3,
"size_x": 8,
"size_y": 3,
"slice_id": "1271"
},
{
"col": 1,
"row": 6,
"size_x": 8,
"size_y": 4,
"slice_id": "1272"
},
{
"col": 10,
"row": 0,
"size_x": 3,
"size_y": 3,
"slice_id": "1273"
},
{
"col": 5,
"row": 0,
"size_x": 5,
"size_y": 3,
"slice_id": "1274"
},
{
"col": 1,
"row": 2,
"size_x": 4,
"size_y": 4,
"slice_id": "1275"
}
]
""")
l = json.loads(js)
for i, pos in enumerate(l):
Expand Down
3 changes: 2 additions & 1 deletion caravel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,8 @@ def save_dash(self, dashboard_id):
dash = session.query(Dash).filter_by(id=dashboard_id).first()
check_ownership(dash, raise_if_false=True)
dash.slices = [o for o in dash.slices if o.id in slice_ids]
dash.position_json = json.dumps(data['positions'], indent=4)
positions = sorted(data['positions'], key=lambda x: int(x['slice_id']))
dash.position_json = json.dumps(positions, indent=4, sort_keys=True)
md = dash.metadata_dejson
if 'filter_immune_slices' not in md:
md['filter_immune_slices'] = []
Expand Down

0 comments on commit c7dc10b

Please sign in to comment.