You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/01/08 17:17:00 UTC

[GitHub] kristw closed pull request #4545: add two more number formats, add number formats to table

kristw closed pull request #4545: add two more number formats, add number formats to table
URL: https://github.com/apache/incubator-superset/pull/4545
 
 
   

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/explore/stores/controls.jsx b/superset/assets/javascripts/explore/stores/controls.jsx
index 617c717d5f..7d8f8a2ee7 100644
--- a/superset/assets/javascripts/explore/stores/controls.jsx
+++ b/superset/assets/javascripts/explore/stores/controls.jsx
@@ -16,12 +16,14 @@ const D3_FORMAT_DOCS = 'D3 format syntax: https://github.com/d3/d3-format';
 
 // input choices & options
 const D3_FORMAT_OPTIONS = [
+  ['-', '- | 123456789'],
   ['.1s', '.1s | 12k'],
   ['.3s', '.3s | 12.3k'],
   ['.3%', '.3% | 1234543.210%'],
   ['.4r', '.4r | 12350'],
   ['.3f', '.3f | 12345.432'],
   ['+,', '+, | +12,345.4321'],
+  ['-,', '-, | 12,345.4321'],
   ['$,.2f', '$,.2f | $12,345.43'],
 ];
 
diff --git a/superset/assets/javascripts/explore/stores/visTypes.js b/superset/assets/javascripts/explore/stores/visTypes.js
index 75443469f3..519b50c07a 100644
--- a/superset/assets/javascripts/explore/stores/visTypes.js
+++ b/superset/assets/javascripts/explore/stores/visTypes.js
@@ -770,6 +770,7 @@ export const visTypes = {
           ['row_limit', 'page_length'],
           ['include_search', 'table_filter'],
           ['align_pn', 'color_pn'],
+          ['number_format'],
         ],
       },
     ],
diff --git a/superset/assets/visualizations/table.js b/superset/assets/visualizations/table.js
index d00ba2af80..6aa6b625fc 100644
--- a/superset/assets/visualizations/table.js
+++ b/superset/assets/visualizations/table.js
@@ -2,7 +2,7 @@ import d3 from 'd3';
 import dt from 'datatables.net-bs';
 import 'datatables.net-bs/css/dataTables.bootstrap.css';
 
-import { fixDataTableBodyHeight, d3TimeFormatPreset } from '../javascripts/modules/utils';
+import { fixDataTableBodyHeight, d3TimeFormatPreset, d3format } from '../javascripts/modules/utils';
 import './table.css';
 
 const $ = require('jquery');
@@ -90,10 +90,11 @@ function tableVis(slice, payload) {
         html = `<span class="like-pre">${val}</span>`;
       }
       if (isMetric) {
-        html = slice.d3format(c, val);
+        const numberFormat = slice.datasource.column_formats && slice.datasource.column_formats[c] || fd.number_format || '.3s';
+        html = d3format(numberFormat, val);
       }
       if (c[0] === '%') {
-        html = d3.format('.3p')(val);
+        html = d3format('.3p', val);
       }
       return {
         col: c,
@@ -180,6 +181,8 @@ function tableVis(slice, payload) {
     scrollCollapse: true,
     scrollX: true,
   });
+
+
   fixDataTableBodyHeight(
       container.find('.dataTables_wrapper'), height);
   // Sorting table by main column


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org