betodealmeida commented on a change in pull request #4756: Improve xAxis ticks, 
thinner bottom margin
URL: 
https://github.com/apache/incubator-superset/pull/4756#discussion_r179226751
 
 

 ##########
 File path: superset/assets/visualizations/nvd3_vis.js
 ##########
 @@ -160,31 +145,57 @@ function nvd3Vis(slice, payload) {
       svg = d3.select(slice.selector).append('svg');
     }
     let height = slice.height();
+    const isTimeSeries = [
+      'line', 'dual_line', 'area', 'compare', 'bar', 
'time_pivot'].indexOf(vizType) >= 0;
+
+    // Handling xAxis ticks settings
+    let xLabelRotation = 0;
+    let staggerLabels = false;
+    if (fd.x_ticks_layout === 'auto') {
+      if (['column', 'dist_bar'].indexOf(vizType) >= 0) {
+        xLabelRotation = 45;
+      } else if (isTimeSeries) {
+        staggerLabels = true;
+      }
+    } else if (fd.x_ticks_layout === 'staggered') {
+      staggerLabels = true;
+    } else if (fd.x_ticks_layout === '45°') {
+      if (fd.show_brush === true || fd.show_brush === 'yes') {
 
 Review comment:
   This seems to be a common pattern when we add more options to a control 
(usually when "auto" is added to an on/off control). Maybe we should have a 
function called `isTruthy`, eg:
   
   ```javascript
   function isTruthy(obj) {
       if (typeof variable === 'boolean') {
           return obj;
       } else if (typeof variable === 'string') {
           return obj.toLowerCase() !== 'no';
       } else {
           return !!obj;
       }
   }
   ```
   
   Or maybe not. Just thinking out loud. :)

----------------------------------------------------------------
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