graceguo-supercat closed pull request #4446: for 48 columns dashboard, adjust 
default size for newly added slices
URL: https://github.com/apache/incubator-superset/pull/4446
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/assets/javascripts/dashboard/reducers.js 
b/superset/assets/javascripts/dashboard/reducers.js
index 1e37aca9fb..cbbb26348f 100644
--- a/superset/assets/javascripts/dashboard/reducers.js
+++ b/superset/assets/javascripts/dashboard/reducers.js
@@ -39,16 +39,21 @@ export function getInitialState(bootstrapData) {
       dashboard.posDict[position.slice_id] = position;
     });
   }
-  dashboard.slices.forEach((slice, index) => {
+  const lastRowId = Math.max.apply(null,
+    dashboard.position_json.map(pos => (pos.row + pos.size_y)));
+  let newSliceCounter = 0;
+  dashboard.slices.forEach((slice) => {
     const sliceId = slice.slice_id;
     let pos = dashboard.posDict[sliceId];
     if (!pos) {
+      // append new slices to dashboard bottom, 3 slices per row
       pos = {
-        col: (index * 4 + 1) % 12,
-        row: Math.floor((index) / 3) * 4,
-        size_x: 4,
-        size_y: 4,
+        col: (newSliceCounter % 3) * 16 + 1,
+        row: lastRowId + Math.floor(newSliceCounter / 3) * 16,
+        size_x: 16,
+        size_y: 16,
       };
+      newSliceCounter++;
     }
 
     dashboard.layout.push({


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to