Skip to content

Commit eb79dab

Browse files
Merge pull request #808 from plotly/pre143
Plotly.js 1.43.0 upgrade
2 parents b3f0d5d + e8c6f44 commit eb79dab

File tree

19 files changed

+230
-120
lines changed

19 files changed

+230
-120
lines changed

dev/dataSources.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,16 +1728,10 @@ export default {
17281728
'jagged ints': [2, 1, 3, 5, 4, 6],
17291729
'toggle ints': [1, -1, 1, -1, 1, -1],
17301730
'big ints': [1000, 10100, 10000, 20000, 100000],
1731-
dates: [
1732-
'2010-01-01',
1733-
'2010-07-01',
1734-
'2011-01-01',
1735-
'2011-07-01',
1736-
'2012-01-01',
1737-
'2012-06-01',
1738-
],
1731+
dates: ['2010-01-01', '2010-07-01', '2011-01-01', '2011-07-01', '2012-01-01', '2012-06-01'],
17391732
months: ['January', 'February', 'March', 'April', 'May', 'June'],
17401733
colors: ['red', 'orange', 'yellow', 'green', 'blue', 'indigo'],
1734+
buckets: ['A', 'A', 'A', 'B', 'B', 'B'],
17411735
'blue and red': ['blue', 'red'],
17421736
countries: [
17431737
'Angola',

examples/custom/src/CustomEditor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default class CustomEditor extends Component {
5757
/>
5858
<Flaglist
5959
label="Flaglist"
60-
attr="titlefont.family"
60+
attr="title.font.family"
6161
show
6262
options={[{label: 'Yes', value: 'y'}, {label: 'No', value: 'n'}]}
6363
/>

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"fast-isnumeric": "^1.1.1",
1616
"immutability-helper": "^2.7.1",
1717
"plotly-icons": "1.2.2",
18-
"plotly.js": "1.42.1",
18+
"plotly.js": "1.43.0",
1919
"prop-types": "^15.5.10",
2020
"raf": "^3.4.0",
2121
"react-color": "^2.13.8",
@@ -125,4 +125,4 @@
125125
"watch": "babel src --watch --out-dir lib --source-maps | node-sass -w src/styles/main.scss lib/react-chart-editor.css",
126126
"watch-test": "jest --watch"
127127
}
128-
}
128+
}

src/components/fields/ColorscalePicker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class UnconnectedColorscalePicker extends Component {
3030
const colorscale = Array.isArray(fullValue) ? fullValue.map(v => v[1]) : null;
3131

3232
return (
33-
<Field {...this.props}>
33+
<Field {...this.props} fieldContainerClassName="field__colorscale">
3434
<ColorscalePickerWidget
3535
selected={colorscale}
3636
onColorscaleChange={this.onUpdate}

src/components/fields/DataSelector.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ export class UnconnectedDataSelector extends Component {
3535
this.is2D = false;
3636
if (props.container) {
3737
this.is2D =
38+
((props.attr === 'x' || props.attr === 'y') &&
39+
[
40+
'scatter',
41+
'scattergl',
42+
'bar',
43+
'heatmap',
44+
'heatmapgl',
45+
'violin',
46+
'box',
47+
'contour',
48+
'contourgl',
49+
].includes(props.container.type)) ||
3850
(props.attr === 'z' &&
3951
[
4052
'contour',
@@ -60,14 +72,23 @@ export class UnconnectedDataSelector extends Component {
6072
const update = {};
6173
let data;
6274

63-
if (Array.isArray(value)) {
64-
data = value.filter(v => Array.isArray(this.dataSources[v])).map(v => this.dataSources[v]);
75+
const adjustedValue =
76+
Array.isArray(value) &&
77+
value.length === 1 &&
78+
(this.props.attr === 'x' || this.props.attr === 'y')
79+
? value[0]
80+
: value;
81+
82+
if (Array.isArray(adjustedValue)) {
83+
data = adjustedValue
84+
.filter(v => Array.isArray(this.dataSources[v]))
85+
.map(v => this.dataSources[v]);
6586
} else {
66-
data = this.dataSources[value] || null;
87+
data = this.dataSources[adjustedValue] || null;
6788
}
6889

6990
update[this.props.attr] = maybeTransposeData(data, this.srcAttr, this.props.container.type);
70-
update[this.srcAttr] = maybeAdjustSrc(value, this.srcAttr, this.props.container.type, {
91+
update[this.srcAttr] = maybeAdjustSrc(adjustedValue, this.srcAttr, this.props.container.type, {
7192
fromSrc: this.context.srcConverters ? this.context.srcConverters.fromSrc : null,
7293
});
7394

src/components/fields/TextEditor.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import Field from './Field';
22
import React, {Component} from 'react';
33
import PropTypes from 'prop-types';
44
import {connectToContainer} from 'lib';
5+
import nestedProperty from 'plotly.js/src/lib/nested_property';
56
import LaTeX from '../widgets/text_editors/LaTeX';
67
import RichText from '../widgets/text_editors/RichText';
78
import MultiFormat from '../widgets/text_editors/MultiFormat';
89
import HTML from '../widgets/text_editors/HTML';
910

10-
class UnconnectedTextEditor extends Component {
11+
export class UnconnectedTextEditor extends Component {
1112
render() {
1213
const {
1314
attr,
@@ -24,7 +25,7 @@ class UnconnectedTextEditor extends Component {
2425
let fullValue = this.props.fullValue;
2526

2627
let placeholder;
27-
if (multiValued || (fullValue && (!container || !container[attr]))) {
28+
if (multiValued || (fullValue && (!container || !nestedProperty(container, attr)))) {
2829
placeholder = fullValue;
2930
fullValue = '';
3031
}

src/components/fields/derived.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {UnconnectedAxisRangeValue} from './AxisRangeValue';
88
import {UnconnectedRadio} from './Radio';
99
import Info from './Info';
1010
import {UnconnectedColorPicker} from './ColorPicker';
11+
import {UnconnectedTextEditor} from './TextEditor';
1112
import {UnconnectedVisibilitySelect} from './VisibilitySelect';
1213
import {connectToContainer, getAllAxes, getAxisTitle, axisIdToAxisName} from 'lib';
1314

@@ -518,6 +519,27 @@ export const TextInfo = connectToContainer(UnconnectedFlaglist, {
518519
},
519520
});
520521

522+
export const HoverTemplateSwitch = connectToContainer(UnconnectedRadio, {
523+
modifyPlotProps: (props, context, plotProps) => {
524+
const {localize: _} = context;
525+
526+
plotProps.options = [
527+
{label: _('Values'), value: ''},
528+
{label: _('Template'), value: plotProps.fullValue || ' '},
529+
];
530+
return plotProps;
531+
},
532+
});
533+
534+
export const HoverTemplateText = connectToContainer(UnconnectedTextEditor, {
535+
modifyPlotProps: (props, context, plotProps) => {
536+
if (plotProps.isVisible && plotProps.fullValue === '') {
537+
plotProps.isVisible = false;
538+
}
539+
return plotProps;
540+
},
541+
});
542+
521543
export const HoverInfo = connectToContainer(UnconnectedFlaglist, {
522544
modifyPlotProps: (props, context, plotProps) => {
523545
const {localize: _, container} = context;

src/components/fields/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ import {
4343
ContourNumeric,
4444
FillDropdown,
4545
HoverInfo,
46+
HoverTemplateText,
47+
HoverTemplateSwitch,
4648
NumericFraction,
4749
NumericFractionDomain,
4850
PositioningNumeric,
@@ -85,6 +87,8 @@ export {
8587
Flaglist,
8688
FontSelector,
8789
HoverInfo,
90+
HoverTemplateText,
91+
HoverTemplateSwitch,
8892
Info,
8993
NumericFraction,
9094
NumericFractionDomain,

src/components/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import {
2424
Flaglist,
2525
FontSelector,
2626
HoverInfo,
27+
HoverTemplateText,
28+
HoverTemplateSwitch,
2729
Info,
2830
NumericFraction,
2931
NumericFractionDomain,
@@ -132,6 +134,8 @@ export {
132134
Fold,
133135
FontSelector,
134136
HoverInfo,
137+
HoverTemplateText,
138+
HoverTemplateSwitch,
135139
Info,
136140
NumericFraction,
137141
NumericFractionDomain,

src/components/widgets/ColorscalePicker.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ class Scale extends Component {
4141

4242
return (
4343
<div className="customPickerContainer__outer">
44-
<Colorscale colorscale={selected} onClick={this.onClick} />
45-
44+
<div className="customPickerContainer__inner">
45+
<Colorscale colorscale={selected} onClick={this.onClick} />
46+
</div>
4647
{showColorscalePicker ? (
4748
<div className="customPickerContainer">
4849
<Dropdown

0 commit comments

Comments
 (0)