diff --git a/client/app/assets/css/superflat_redash.css b/client/app/assets/css/superflat_redash.css
index b30dd11a64..b39b72bf74 100644
--- a/client/app/assets/css/superflat_redash.css
+++ b/client/app/assets/css/superflat_redash.css
@@ -1781,6 +1781,9 @@ fieldset[disabled] .form-control {
textarea.form-control {
height: auto;
}
+textarea.v-resizable {
+ resize: vertical;
+}
input[type="search"] {
-webkit-appearance: none;
}
diff --git a/client/app/visualizations/chart/chart-editor.html b/client/app/visualizations/chart/chart-editor.html
index 80b23a88d5..f29f35ac5f 100644
--- a/client/app/visualizations/chart/chart-editor.html
+++ b/client/app/visualizations/chart/chart-editor.html
@@ -134,17 +134,23 @@
diff --git a/client/app/visualizations/chart/index.js b/client/app/visualizations/chart/index.js
index b9f93b9074..ea7d519ee0 100644
--- a/client/app/visualizations/chart/index.js
+++ b/client/app/visualizations/chart/index.js
@@ -87,10 +87,12 @@ function ChartEditor(ColorPalette, clientConfig) {
scope.showSizeColumnPicker = () => some(scope.options.seriesOptions, options => options.type === 'bubble');
- scope.options.customCode = `// Available variables are x, ys, element, and Plotly
+ if (scope.options.customCode === undefined) {
+ scope.options.customCode = `// Available variables are x, ys, element, and Plotly
// Type console.log(x, ys); for more info about x and ys
// To plot your graph call Plotly.plot(element, ...)
// Plotly examples and docs: https://plot.ly/javascript/`;
+ }
function refreshColumns() {
scope.columns = scope.queryResult.getColumns();
diff --git a/client/app/visualizations/chart/plotly.js b/client/app/visualizations/chart/plotly.js
index e94e97cf4a..696c2dbb3b 100644
--- a/client/app/visualizations/chart/plotly.js
+++ b/client/app/visualizations/chart/plotly.js
@@ -499,6 +499,9 @@ const CustomPlotlyChart = (clientConfig) => {
return;
}
const refresh = () => {
+ // Clear existing data with blank data for succeeding codeCall adds data to existing plot.
+ Plotly.newPlot(element[0].children[0]);
+
// eslint-disable-next-line no-eval
const codeCall = eval(`codeCall = function(x, ys, element, Plotly){ ${scope.options.customCode} }`);
codeCall(scope.x, scope.ys, element[0].children[0], Plotly);
@@ -514,9 +517,11 @@ const CustomPlotlyChart = (clientConfig) => {
});
});
};
- scope.$watch('options.customCode', () => {
+ scope.$watch('[options.customCode, options.autoRedraw]', () => {
try {
- refresh();
+ if (scope.options.autoRedraw) {
+ refresh();
+ }
} catch (err) {
if (scope.options.enableConsoleLogs) {
// eslint-disable-next-line no-console