Skip to content

Commit

Permalink
fix(legacy-plugin-chart-paired-t-test): fix paired t-test table chart (
Browse files Browse the repository at this point in the history
…#961)

* fix(legacy-plugin-chart-paired-t-test): fix paired t-test table chart

* Display error message if group by wasn't defined

* Add validateNonEmpty for groupby
  • Loading branch information
kgabryje authored and zhaoyongjie committed Nov 26, 2021
1 parent eb16861 commit 4db9249
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@superset-ui/core": "0.17.9",
"distributions": "^1.0.0",
"prop-types": "^15.6.2",
"reactable-arc": "0.15.0"
"reactable": "^1.1.0"
},
"peerDependencies": {
"react": "^15 || ^16"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PairedTTest extends React.PureComponent {

return (
<div className={`superset-legacy-chart-paired-t-test ${className}`}>
<div className="paired-ttest-table scrollbar-container">
<div className="paired-ttest-table">
<div className="scrollbar-content">
{metrics.map((metric, i) => (
<TTestTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/* eslint-disable react/no-array-index-key, react/jsx-no-bind */
import dist from 'distributions';
import React from 'react';
import { Table, Tr, Td, Thead, Th } from 'reactable-arc';
import { Table, Tr, Td, Thead, Th } from 'reactable';
import PropTypes from 'prop-types';

export const dataPropType = PropTypes.arrayOf(
Expand Down Expand Up @@ -166,6 +166,11 @@ class TTestTable extends React.Component {
render() {
const { data, metric, groups } = this.props;
const { control, liftValues, pValues } = this.state;

if (!Array.isArray(groups) || groups.length === 0) {
throw Error('Group by param is required');
}

// Render column header for each group
const columns = groups.map((group, i) => (
<Th key={i} column={group}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { t } from '@superset-ui/core';
import { t, validateNonEmpty } from '@superset-ui/core';
import { ControlPanelConfig, sections } from '@superset-ui/chart-controls';

const config: ControlPanelConfig = {
Expand Down Expand Up @@ -49,6 +49,13 @@ const config: ControlPanelConfig = {
description: t('Compute the contribution to the total'),
},
},

{
name: 'groupby',
override: {
validators: [validateNonEmpty],
},
},
],
['row_limit', null],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function transformProps(chartProps) {
data: queriesData[0].data,
groups: groupby,
liftValPrec: parseInt(liftvaluePrecision, 10),
metrics,
metrics: metrics.map(metric => (typeof metric === 'string' ? metric : metric.label)),
pValPrec: parseInt(pvaluePrecision, 10),
};
}

0 comments on commit 4db9249

Please sign in to comment.