diff --git a/dev/App.js b/dev/App.js
index 85da19506..51260be8e 100644
--- a/dev/App.js
+++ b/dev/App.js
@@ -44,10 +44,18 @@ const config = {mapboxAccessToken: ACCESS_TOKENS.MAPBOX, editable: true};
const traceTypesConfig = {
traces: _ => [
{
- value: 'scattergl',
+ value: 'scatter',
icon: 'scatter',
label: _('Scatter'),
},
+ {
+ value: 'line',
+ label: _('Line'),
+ },
+ {
+ value: 'area',
+ label: _('Area'),
+ },
{
value: 'bar',
label: _('Bar'),
@@ -155,6 +163,7 @@ class App extends Component {
debug
advancedTraceTypeSelector
showFieldTooltips
+ // glByDefault
// traceTypesConfig={traceTypesConfig}
// makeDefaultTrace={() => ({type: 'scattergl', mode: 'markers'})}
>
diff --git a/src/EditorControls.js b/src/EditorControls.js
index 04b20aae0..3ddc20af5 100644
--- a/src/EditorControls.js
+++ b/src/EditorControls.js
@@ -49,6 +49,8 @@ class EditorControls extends Component {
plotly: this.props.plotly,
traceTypesConfig: this.props.traceTypesConfig,
showFieldTooltips: this.props.showFieldTooltips,
+ glByDefault: this.props.glByDefault,
+ mapBoxAccess: this.props.mapBoxAccess,
};
}
@@ -121,7 +123,14 @@ class EditorControls extends Component {
// can't use default prop because plotly.js mutates it:
// https://github.com/plotly/react-chart-editor/issues/509
- graphDiv.data.push(this.props.makeDefaultTrace());
+ graphDiv.data.push(
+ this.props.makeDefaultTrace
+ ? this.props.makeDefaultTrace()
+ : {
+ type: `scatter${this.props.glByDefault ? 'gl' : ''}`,
+ mode: 'markers',
+ }
+ );
if (this.props.afterAddTrace) {
this.props.afterAddTrace(payload);
@@ -308,12 +317,13 @@ EditorControls.propTypes = {
showFieldTooltips: PropTypes.bool,
traceTypesConfig: PropTypes.object,
makeDefaultTrace: PropTypes.func,
+ glByDefault: PropTypes.bool,
+ mapBoxAccess: PropTypes.bool,
};
EditorControls.defaultProps = {
showFieldTooltips: false,
locale: 'en',
- makeDefaultTrace: () => ({type: 'scatter', mode: 'markers'}),
traceTypesConfig: {
categories: _ => categoryLayout(_),
traces: _ => traceTypes(_),
@@ -346,6 +356,8 @@ EditorControls.childContextTypes = {
plotSchema: PropTypes.object,
traceTypesConfig: PropTypes.object,
showFieldTooltips: PropTypes.bool,
+ glByDefault: PropTypes.bool,
+ mapBoxAccess: PropTypes.bool,
};
export default EditorControls;
diff --git a/src/PlotlyEditor.js b/src/PlotlyEditor.js
index 0bddbf082..054d3a9fe 100644
--- a/src/PlotlyEditor.js
+++ b/src/PlotlyEditor.js
@@ -27,6 +27,10 @@ class PlotlyEditor extends Component {
showFieldTooltips={this.props.showFieldTooltips}
srcConverters={this.props.srcConverters}
makeDefaultTrace={this.props.makeDefaultTrace}
+ glByDefault={this.props.glByDefault}
+ mapBoxAccess={Boolean(
+ this.props.config && this.props.config.mapboxAccessToken
+ )}
>
{this.props.children}
@@ -77,6 +81,7 @@ PlotlyEditor.propTypes = {
fromSrc: PropTypes.func.isRequired,
}),
makeDefaultTrace: PropTypes.func,
+ glByDefault: PropTypes.bool,
};
PlotlyEditor.defaultProps = {
diff --git a/src/components/containers/Modal.js b/src/components/containers/Modal.js
index 36f9dafdd..9b0e0b862 100644
--- a/src/components/containers/Modal.js
+++ b/src/components/containers/Modal.js
@@ -21,6 +21,26 @@ const ModalContent = ({children}) => (
);
class Modal extends Component {
+ constructor(props) {
+ super(props);
+ this.escFunction = this.escFunction.bind(this);
+ }
+
+ escFunction(event) {
+ const escKeyCode = 27;
+ if (event.keyCode === escKeyCode) {
+ this.context.handleClose();
+ }
+ }
+
+ componentDidMount() {
+ document.addEventListener('keydown', this.escFunction, false);
+ }
+
+ componentWillUnmount() {
+ document.removeEventListener('keydown', this.escFunction, false);
+ }
+
render() {
const {children, title} = this.props;
let classes = 'modal';
diff --git a/src/components/fields/TraceSelector.js b/src/components/fields/TraceSelector.js
index 0021ed85f..6f97766cb 100644
--- a/src/components/fields/TraceSelector.js
+++ b/src/components/fields/TraceSelector.js
@@ -10,13 +10,24 @@ import {
import TraceTypeSelector, {
TraceTypeSelectorButton,
} from 'components/widgets/TraceTypeSelector';
+import RadioBlocks from 'components/widgets/RadioBlocks';
+
import Field from './Field';
+export const glAvailable = type => {
+ return ['scatter', 'scatterpolar', 'scattergl', 'scatterpolargl'].includes(
+ type
+ );
+};
+
class TraceSelector extends Component {
constructor(props, context) {
super(props, context);
this.updatePlot = this.updatePlot.bind(this);
+ this.setGl = this.setGl.bind(this);
+ this.glEnabled = this.glEnabled.bind(this);
+ this.setTraceDefaults = this.setTraceDefaults.bind(this);
this.setTraceDefaults(
props.container,
@@ -26,6 +37,10 @@ class TraceSelector extends Component {
this.setLocals(props, context);
}
+ glEnabled() {
+ return this.props.container.type.endsWith('gl') ? 'gl' : '';
+ }
+
setLocals(props, context) {
const _ = context.localize;
if (props.traceOptions) {
@@ -46,10 +61,11 @@ class TraceSelector extends Component {
}
}
- setTraceDefaults(container, fullContainer, updateContainer) {
+ setTraceDefaults(container, fullContainer, updateContainer, gl) {
if (container && !container.mode && fullContainer.type === 'scatter') {
updateContainer({
- type: 'scatter',
+ type:
+ 'scatter' + (gl || this.context.glByDefault ? gl : this.glEnabled()),
mode: fullContainer.mode || 'markers',
});
}
@@ -63,11 +79,28 @@ class TraceSelector extends Component {
updatePlot(value) {
const {updateContainer} = this.props;
+ const {glByDefault} = this.context;
if (updateContainer) {
- updateContainer(traceTypeToPlotlyInitFigure(value));
+ updateContainer(
+ traceTypeToPlotlyInitFigure(value, this.glEnabled() || glByDefault)
+ );
}
}
+ setGl(value) {
+ const {container, fullContainer, updateContainer} = this.props;
+ const gl = 'gl';
+
+ this.setTraceDefaults(container, fullContainer, updateContainer, value);
+
+ const traceType =
+ this.fullValue.endsWith(gl) && value === ''
+ ? this.fullValue.slice(0, -gl.length)
+ : this.fullValue;
+
+ updateContainer(traceTypeToPlotlyInitFigure(traceType, value));
+ }
+
render() {
const props = Object.assign({}, this.props, {
fullValue: this.fullValue,
@@ -75,17 +108,41 @@ class TraceSelector extends Component {
options: this.traceOptions,
clearable: false,
});
+ const {localize: _, advancedTraceTypeSelector} = this.context;
+
+ const options = [
+ {label: _('SVG'), value: ''},
+ {label: _('WebGl'), value: 'gl'},
+ ];
+
// Check and see if the advanced selector prop is true
- const {advancedTraceTypeSelector} = this.context;
if (advancedTraceTypeSelector) {
return (
-