highcharts-vue.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("highcharts"));
  4. else if(typeof define === 'function' && define.amd)
  5. define(["highcharts"], factory);
  6. else if(typeof exports === 'object')
  7. exports["HighchartsVue"] = factory(require("highcharts"));
  8. else
  9. root["HighchartsVue"] = factory(root["Highcharts"]);
  10. })(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_0__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, {
  50. /******/ configurable: false,
  51. /******/ enumerable: true,
  52. /******/ get: getter
  53. /******/ });
  54. /******/ }
  55. /******/ };
  56. /******/
  57. /******/ // getDefaultExport function for compatibility with non-harmony modules
  58. /******/ __webpack_require__.n = function(module) {
  59. /******/ var getter = module && module.__esModule ?
  60. /******/ function getDefault() { return module['default']; } :
  61. /******/ function getModuleExports() { return module; };
  62. /******/ __webpack_require__.d(getter, 'a', getter);
  63. /******/ return getter;
  64. /******/ };
  65. /******/
  66. /******/ // Object.prototype.hasOwnProperty.call
  67. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  68. /******/
  69. /******/ // __webpack_public_path__
  70. /******/ __webpack_require__.p = "";
  71. /******/
  72. /******/ // Load entry module and return exports
  73. /******/ return __webpack_require__(__webpack_require__.s = 1);
  74. /******/ })
  75. /************************************************************************/
  76. /******/ ([
  77. /* 0 */
  78. /***/ (function(module, exports) {
  79. module.exports = __WEBPACK_EXTERNAL_MODULE_0__;
  80. /***/ }),
  81. /* 1 */
  82. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83. "use strict";
  84. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  85. /* harmony export (immutable) */ __webpack_exports__["default"] = install;
  86. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Chart", function() { return Chart; });
  87. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__component__ = __webpack_require__(2);
  88. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_highcharts__ = __webpack_require__(0);
  89. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_highcharts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_highcharts__);
  90. var Chart = Object(__WEBPACK_IMPORTED_MODULE_0__component__["a" /* default */])(__WEBPACK_IMPORTED_MODULE_1_highcharts___default.a);
  91. function install(Vue) {
  92. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  93. Vue.component(options.tagName || 'highcharts', Object(__WEBPACK_IMPORTED_MODULE_0__component__["a" /* default */])(options.highcharts || __WEBPACK_IMPORTED_MODULE_1_highcharts___default.a));
  94. }
  95. /***/ }),
  96. /* 2 */
  97. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98. "use strict";
  99. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__utils_tools__ = __webpack_require__(3);
  100. function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
  101. function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
  102. function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
  103. function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
  104. var generateVueComponent = function generateVueComponent(Highcharts) {
  105. return {
  106. template: '<div ref="chart"></div>',
  107. render: function render(createElement) {
  108. return createElement('div', {
  109. ref: 'chart'
  110. });
  111. },
  112. props: {
  113. constructorType: {
  114. type: String,
  115. default: 'chart'
  116. },
  117. options: {
  118. type: Object,
  119. required: true
  120. },
  121. callback: Function,
  122. updateArgs: {
  123. type: Array,
  124. default: function _default() {
  125. return [true, true];
  126. }
  127. },
  128. highcharts: {
  129. type: Object
  130. },
  131. deepCopyOnUpdate: {
  132. type: Boolean,
  133. default: true
  134. }
  135. },
  136. watch: {
  137. options: {
  138. handler: function handler(newValue) {
  139. var _this$chart;
  140. (_this$chart = this.chart).update.apply(_this$chart, [Object(__WEBPACK_IMPORTED_MODULE_0__utils_tools__["a" /* copyObject */])(newValue, this.deepCopyOnUpdate)].concat(_toConsumableArray(this.updateArgs)));
  141. },
  142. deep: true
  143. }
  144. },
  145. mounted: function mounted() {
  146. var HC = this.highcharts || Highcharts; // Check wheather the chart configuration object is passed, as well as the constructor is valid
  147. if (this.options && HC[this.constructorType]) {
  148. this.chart = HC[this.constructorType](this.$refs.chart, Object(__WEBPACK_IMPORTED_MODULE_0__utils_tools__["a" /* copyObject */])(this.options, true), // Always pass the deep copy when generating a chart. #80
  149. this.callback ? this.callback : null);
  150. } else {
  151. !this.options ? console.warn('The "options" parameter was not passed.') : console.warn("'".concat(this.constructorType, "' constructor-type is incorrect. Sometimes this error is caused by the fact, that the corresponding module wasn't imported."));
  152. }
  153. },
  154. beforeDestroy: function beforeDestroy() {
  155. // Destroy chart if exists
  156. if (this.chart) {
  157. this.chart.destroy();
  158. }
  159. }
  160. };
  161. };
  162. /* harmony default export */ __webpack_exports__["a"] = (generateVueComponent);
  163. /***/ }),
  164. /* 3 */
  165. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  166. "use strict";
  167. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return copyObject; });
  168. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_highcharts__ = __webpack_require__(0);
  169. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_highcharts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_highcharts__);
  170. function doCopy(copy, original, copyArray) {
  171. // Callback function to iterate on array or object elements
  172. function callback(value, key) {
  173. // Copy the contents of objects
  174. if (__WEBPACK_IMPORTED_MODULE_0_highcharts___default.a.isObject(value, !copyArray) && !__WEBPACK_IMPORTED_MODULE_0_highcharts___default.a.isClass(value) && !__WEBPACK_IMPORTED_MODULE_0_highcharts___default.a.isDOMElement(value)) {
  175. copy[key] = doCopy(copy[key] || __WEBPACK_IMPORTED_MODULE_0_highcharts___default.a.isArray(value) ? [] : {}, value, copyArray);
  176. } else {
  177. // Primitives are copied over directly
  178. copy[key] = original[key];
  179. }
  180. }
  181. if (__WEBPACK_IMPORTED_MODULE_0_highcharts___default.a.isArray(original)) {
  182. original.forEach(callback);
  183. } else {
  184. __WEBPACK_IMPORTED_MODULE_0_highcharts___default.a.objectEach(original, callback);
  185. }
  186. return copy;
  187. }
  188. var copyObject = function copyObject(obj, copyArray) {
  189. return doCopy({}, obj, copyArray);
  190. };
  191. /***/ })
  192. /******/ ]);
  193. });