Skip to content

Commit 14b8c07

Browse files
author
Martin Hansen
committed
Use react instead of newPlot to redraw. Closes #11
1 parent f67d6d3 commit 14b8c07

File tree

6 files changed

+3872
-3457
lines changed

6 files changed

+3872
-3457
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The component supports the following props:
6161

6262
* `data`
6363

64-
The traces to draw. Will trigger a call to newPlot when changed.
64+
The traces to draw. Will trigger a call to react when changed.
6565

6666
* `layout`
6767

@@ -117,6 +117,10 @@ Accepts no arguments. Uses data, layout and options from the props data.
117117

118118
Accepts no arguments. Uses data, layout and options from the props data.
119119

120+
- `react`
121+
122+
Accepts no arguments. Uses data, layout and options from the props data.
123+
120124

121125
Read more about plotlyjs function reference here:
122126
https://plot.ly/javascript/plotlyjs-function-reference/

dist/vue-plotly.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ exports = module.exports = __webpack_require__(26)(false);
651651

652652

653653
// module
654-
exports.push([module.i, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", ""]);
654+
exports.push([module.i, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", ""]);
655655

656656
// exports
657657

@@ -1103,30 +1103,38 @@ var methods = functions.reduce(function (all, funcName) {
11031103
},
11041104
data: function data() {
11051105
return {
1106-
internalLayout: this.layout
1106+
internalLayout: __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({}, this.layout, {
1107+
datarevision: 1
1108+
})
11071109
};
11081110
},
11091111
mounted: function mounted() {
1110-
this.newPlot();
1112+
var _this = this;
1113+
1114+
this.react();
11111115
this.initEvents();
11121116

1113-
this.$watch('data', this.newPlot, { deep: !this.watchShallow });
1114-
this.$watch('options', this.newPlot, { deep: !this.watchShallow });
1117+
this.$watch('data', function () {
1118+
_this.internalLayout.datarevision++;
1119+
_this.react();
1120+
}, { deep: !this.watchShallow });
1121+
1122+
this.$watch('options', this.react, { deep: !this.watchShallow });
11151123
this.$watch('layout', this.relayout, { deep: !this.watchShallow });
11161124
},
11171125
beforeDestroy: function beforeDestroy() {
1118-
var _this = this;
1126+
var _this2 = this;
11191127

11201128
window.removeEventListener('resize', this.__resizeListener);
11211129
this.__generalListeners.forEach(function (obj) {
1122-
return _this.$refs.container.removeAllListeners(obj.fullName);
1130+
return _this2.$refs.container.removeAllListeners(obj.fullName);
11231131
});
11241132
__WEBPACK_IMPORTED_MODULE_1_plotly_js___default.a.purge(this.$refs.container);
11251133
},
11261134

11271135
methods: __WEBPACK_IMPORTED_MODULE_0_babel_runtime_helpers_extends___default()({
11281136
initEvents: function initEvents() {
1129-
var _this2 = this;
1137+
var _this3 = this;
11301138

11311139
if (this.autoResize) {
11321140
this.__resizeListener = __WEBPACK_IMPORTED_MODULE_2_lodash_debounce___default()(this.newPlot, 200);
@@ -1141,13 +1149,13 @@ var methods = functions.reduce(function (all, funcName) {
11411149
args[_key2] = arguments[_key2];
11421150
}
11431151

1144-
_this2.$emit.apply(_this2, [eventName].concat(args));
1152+
_this3.$emit.apply(_this3, [eventName].concat(args));
11451153
}
11461154
};
11471155
});
11481156

11491157
this.__generalListeners.forEach(function (obj) {
1150-
_this2.$refs.container.on(obj.fullName, obj.handler);
1158+
_this3.$refs.container.on(obj.fullName, obj.handler);
11511159
});
11521160
}
11531161
}, methods, {
@@ -1177,6 +1185,9 @@ var methods = functions.reduce(function (all, funcName) {
11771185
},
11781186
newPlot: function newPlot() {
11791187
return __WEBPACK_IMPORTED_MODULE_1_plotly_js___default.a.newPlot(this.$refs.container, this.data, this.internalLayout, this.options);
1188+
},
1189+
react: function react() {
1190+
return __WEBPACK_IMPORTED_MODULE_1_plotly_js___default.a.react(this.$refs.container, this.data, this.internalLayout, this.options);
11801191
}
11811192
})
11821193
});

dist/vue-plotly.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)