Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

fix: make pivot table handle null string #23

Merged
merged 1 commit into from
Mar 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function PivotTable(element, props) {
const metric = cols[i];
const format = columnFormats[metric] || numberFormat || '.3s';
const tdText = $(this)[0].textContent;
if (!Number.isNaN(tdText) && tdText !== '') {
if (!Number.isNaN(tdText) && tdText !== '' && tdText.trim().toLowerCase() !== 'null') {
$(this)[0].textContent = formatNumber(format, tdText);
$(this).attr('data-sort', tdText);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,34 @@ export default [
storyName: 'Basic',
storyPath: 'legacy-|plugin-chart-pivot-table|PivotTableChartPlugin',
},
{
renderStory: () => (
<SuperChart
chartType="pivot-table"
chartProps={{
datasource: {
columnFormats: {},
verboseMap: {
sum__num: 'sum__num',
},
},
formData: {
groupby: ['name'],
numberFormat: '.3s',
},
height: 400,
payload: {
data: {
columns: [['sum__num', 'other'], ['sum__num', 'All']],
html:
'<table border="1" class="dataframe dataframe table table-striped table-bordered table-condensed table-hover">\n <thead>\n <tr>\n <th></th>\n <th colspan="2" halign="left">sum__num</th>\n </tr>\n <tr>\n <th>state</th>\n <th>other</th>\n <th>All</th>\n </tr>\n <tr>\n <th>name</th>\n <th></th>\n <th></th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>Christopher</th>\n <td>null</td>\n <td>803607</td>\n </tr>\n <tr>\n <th>David</th>\n <td>null</td>\n <td>673992</td>\n </tr>\n <tr>\n <th>James</th>\n <td>749686</td>\n <td>null</td>\n </tr>\n <tr>\n <th>Jennifer</th>\n <td>587540</td>\n <td>null</td>\n </tr>\n <tr>\n <th>John</th>\n <td>638450</td>\n <td>638450</td>\n </tr>\n <tr>\n <th>Joshua</th>\n <td>null</td>\n <td>548044</td>\n </tr>\n <tr>\n <th>Matthew</th>\n <td>608212</td>\n <td>608212</td>\n </tr>\n <tr>\n <th>Michael</th>\n <td>1047996</td>\n <td>1047996</td>\n </tr>\n <tr>\n <th>Robert</th>\n <td>575592</td>\n <td>575592</td>\n </tr>\n <tr>\n <th>William</th>\n <td>574464</td>\n <td>574464</td>\n </tr>\n <tr>\n <th>All</th>\n <td>6807583</td>\n <td>6807583</td>\n </tr>\n </tbody>\n</table>',
},
},
width: 400,
}}
/>
),
storyName: 'With null',
storyPath: 'legacy-|plugin-chart-pivot-table|PivotTableChartPlugin',
},
];