Skip to content

Commit c9c457f

Browse files
authored
Merge pull request #498 from plotly/partially-disable-transforms
Transforms enabled only for certain chart types
2 parents 14a8ce8 + e977307 commit c9c457f

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/components/containers/TransformAccordion.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ import PlotlyPanel from './PlotlyPanel';
33
import PropTypes from 'prop-types';
44
import React, {Component} from 'react';
55
import {connectTransformToTrace} from 'lib';
6+
import FoldEmpty from './FoldEmpty';
7+
import {PlotScatterIcon} from 'plotly-icons';
68

79
const TransformFold = connectTransformToTrace(PlotlyFold);
810

911
class TransformAccordion extends Component {
1012
render() {
1113
const {
14+
fullContainer,
1215
fullContainer: {transforms = []},
1316
localize: _,
1417
} = this.context;
@@ -20,6 +23,15 @@ class TransformAccordion extends Component {
2023
{label: _('Aggregate'), type: 'aggregate'},
2124
];
2225

26+
if (['scatter', 'bar', 'scattergl'].indexOf(fullContainer.type) === -1) {
27+
return (
28+
<FoldEmpty
29+
icon={PlotScatterIcon}
30+
messagePrimary={_('No transforms available for this trace type')}
31+
/>
32+
);
33+
}
34+
2335
const filteredTransforms = transforms.filter(({type}) => Boolean(type));
2436
const content =
2537
filteredTransforms.length &&

src/components/containers/TransformAccordionDev.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ import PlotlyPanel from './PlotlyPanel';
33
import PropTypes from 'prop-types';
44
import React, {Component} from 'react';
55
import {connectTransformToTrace} from 'lib';
6+
import FoldEmpty from './FoldEmpty';
7+
import {PlotScatterIcon} from 'plotly-icons';
68

79
const TransformFold = connectTransformToTrace(PlotlyFold);
810

911
class TransformAccordion extends Component {
1012
render() {
1113
const {
14+
fullContainer,
1215
fullContainer: {transforms = []},
1316
localize: _,
1417
container,
@@ -22,6 +25,29 @@ class TransformAccordion extends Component {
2225
{label: _('Aggregate'), type: 'aggregate'},
2326
];
2427

28+
const transformableCharts = [
29+
'scatter',
30+
'bar',
31+
'line',
32+
'area',
33+
'scattergl',
34+
'box',
35+
'histogram',
36+
'histogram2d',
37+
'histogram2dcontour',
38+
'candlestick',
39+
'ohlc',
40+
];
41+
42+
if (transformableCharts.indexOf(fullContainer.type) === -1) {
43+
return (
44+
<FoldEmpty
45+
icon={PlotScatterIcon}
46+
messagePrimary={_('No transforms available for this trace type')}
47+
/>
48+
);
49+
}
50+
2551
const transformBy =
2652
container.transforms &&
2753
container.transforms.map(tr => {

0 commit comments

Comments
 (0)