Skip to content

Commit 58685fe

Browse files
committed
💄 fixed behaviour of radarchart with regression
1 parent c2588b0 commit 58685fe

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/__tests__/components/chart/RadarChartCard.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import React from 'react';
22
import {shallow} from 'enzyme';
33
import RadarChartCard from '../../../components/chart/RadarChartCard';
44
import ReactApexChart from 'react-apexcharts';
5+
import {CLASSIFICATION} from '../../../reference';
56

67
const labels = ['f1_score', 'accuracy', 'precision', 'recall', 'auc'];
78
const values = [1, 0.8, 0.1, 0.3, 0];
89

910
describe('RadarChartCard', () => {
1011
it('renders with full data', () => {
11-
const element = shallow(<RadarChartCard data={values} labels={labels}/>);
12+
const element = shallow(<RadarChartCard data={values} labels={labels} radarType={CLASSIFICATION}/>);
1213
expect(element).toBeDefined();
1314
const chartProps = element.find(ReactApexChart).props();
1415
expect(element.find(ReactApexChart).length).toBe(1);
@@ -19,7 +20,7 @@ describe('RadarChartCard', () => {
1920
});
2021

2122
it('renders without labels', () => {
22-
const element = shallow(<RadarChartCard data={values} labels={[]}/>);
23+
const element = shallow(<RadarChartCard data={values} labels={[]} radarType={CLASSIFICATION}/>);
2324
expect(element).toBeDefined();
2425
const chartProps = element.find(ReactApexChart).props();
2526
expect(element.find(ReactApexChart).length).toBe(1);
@@ -28,7 +29,7 @@ describe('RadarChartCard', () => {
2829
});
2930

3031
it('renders without data', () => {
31-
const element = shallow(<RadarChartCard data={[]} labels={[]}/>);
32+
const element = shallow(<RadarChartCard data={[]} labels={[]} radarType={CLASSIFICATION}/>);
3233
expect(element).toBeDefined();
3334
const chartProps = element.find(ReactApexChart).props();
3435
expect(element.find(ReactApexChart).length).toBe(1);

src/components/chart/ControlledRadarChartCard.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class ControlledRadarChartCard extends Component {
127127
<RadarChartCard
128128
data={radarChartData}
129129
labels={this.state.radarCharLabels}
130+
radarType={this.props.predictionMethod}
130131
/>
131132
);
132133
const style = {

src/components/chart/RadarChartCard.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import ReactApexChart from 'react-apexcharts';
4+
import {CLASSIFICATION, REGRESSION, TIME_SERIES_PREDICTION} from '../../reference';
45

56
const RadarChartCard = props => {
67
let radarstates = {
@@ -48,6 +49,11 @@ const RadarChartCard = props => {
4849
}
4950
};
5051

52+
if (props.radarType == REGRESSION) {
53+
delete radarstates.options.yaxis['min'];
54+
delete radarstates.options.yaxis['max'];
55+
}
56+
5157
return (
5258
<ReactApexChart
5359
options={radarstates.options}
@@ -60,7 +66,8 @@ const RadarChartCard = props => {
6066

6167
RadarChartCard.propTypes = {
6268
data: PropTypes.arrayOf(PropTypes.any.isRequired).isRequired,
63-
labels: PropTypes.arrayOf(PropTypes.any.isRequired).isRequired
69+
labels: PropTypes.arrayOf(PropTypes.any.isRequired).isRequired,
70+
radarType: PropTypes.oneOf([CLASSIFICATION, REGRESSION, TIME_SERIES_PREDICTION]).isRequired,
6471
};
6572

6673
export default RadarChartCard;

0 commit comments

Comments
 (0)