| 1 |
(function webpackUniversalModuleDefinition(root, factory) { |
| 2 |
if(typeof exports === 'object' && typeof module === 'object') |
| 3 |
module.exports = factory(require("chart.js")); |
| 4 |
else if(typeof define === 'function' && define.amd) |
| 5 |
define("VueChartJs", ["chart.js"], factory); |
| 6 |
else if(typeof exports === 'object') |
| 7 |
exports["VueChartJs"] = factory(require("chart.js")); |
| 8 |
else |
| 9 |
root["VueChartJs"] = factory(root["Chart"]); |
| 10 |
})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_3__) { |
| 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 = 0); |
| 74 |
/******/ }) |
| 75 |
/************************************************************************/ |
| 76 |
/******/ ([ |
| 77 |
/* 0 */ |
| 78 |
/***/ (function(module, __webpack_exports__, __webpack_require__) { |
| 79 |
|
| 80 |
"use strict"; |
| 81 |
Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); |
| 82 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VueCharts", function() { return VueCharts; }); |
| 83 |
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__mixins_index_js__ = __webpack_require__(1); |
| 84 |
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__BaseCharts__ = __webpack_require__(2); |
| 85 |
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Bar", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["a"]; }); |
| 86 |
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "HorizontalBar", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["d"]; }); |
| 87 |
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Doughnut", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["c"]; }); |
| 88 |
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["e"]; }); |
| 89 |
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Pie", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["f"]; }); |
| 90 |
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "PolarArea", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["g"]; }); |
| 91 |
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Radar", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["h"]; }); |
| 92 |
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Bubble", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["b"]; }); |
| 93 |
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "Scatter", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["i"]; }); |
| 94 |
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "mixins", function() { return __WEBPACK_IMPORTED_MODULE_0__mixins_index_js__["a"]; }); |
| 95 |
/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "generateChart", function() { return __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["j"]; }); |
| 96 |
|
| 97 |
|
| 98 |
var VueCharts = { |
| 99 |
Bar: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["a" /* Bar */], |
| 100 |
HorizontalBar: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["d" /* HorizontalBar */], |
| 101 |
Doughnut: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["c" /* Doughnut */], |
| 102 |
Line: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["e" /* Line */], |
| 103 |
Pie: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["f" /* Pie */], |
| 104 |
PolarArea: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["g" /* PolarArea */], |
| 105 |
Radar: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["h" /* Radar */], |
| 106 |
Bubble: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["b" /* Bubble */], |
| 107 |
Scatter: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["i" /* Scatter */], |
| 108 |
mixins: __WEBPACK_IMPORTED_MODULE_0__mixins_index_js__["a" /* default */], |
| 109 |
generateChart: __WEBPACK_IMPORTED_MODULE_1__BaseCharts__["j" /* generateChart */], |
| 110 |
render: function render() { |
| 111 |
return console.error('[vue-chartjs]: This is not a vue component. It is the whole object containing all vue components. Please import the named export or access the components over the dot notation. For more info visit https://vue-chartjs.org/#/home?id=quick-start'); |
| 112 |
} |
| 113 |
}; |
| 114 |
/* harmony default export */ __webpack_exports__["default"] = (VueCharts); |
| 115 |
|
| 116 |
|
| 117 |
/***/ }), |
| 118 |
/* 1 */ |
| 119 |
/***/ (function(module, __webpack_exports__, __webpack_require__) { |
| 120 |
|
| 121 |
"use strict"; |
| 122 |
/* unused harmony export reactiveData */ |
| 123 |
/* unused harmony export reactiveProp */ |
| 124 |
function dataHandler(newData, oldData) { |
| 125 |
if (oldData) { |
| 126 |
var chart = this.$data._chart; |
| 127 |
var newDatasetLabels = newData.datasets.map(function (dataset) { |
| 128 |
return dataset.label; |
| 129 |
}); |
| 130 |
var oldDatasetLabels = oldData.datasets.map(function (dataset) { |
| 131 |
return dataset.label; |
| 132 |
}); |
| 133 |
var oldLabels = JSON.stringify(oldDatasetLabels); |
| 134 |
var newLabels = JSON.stringify(newDatasetLabels); |
| 135 |
|
| 136 |
if (newLabels === oldLabels && oldData.datasets.length === newData.datasets.length) { |
| 137 |
newData.datasets.forEach(function (dataset, i) { |
| 138 |
var oldDatasetKeys = Object.keys(oldData.datasets[i]); |
| 139 |
var newDatasetKeys = Object.keys(dataset); |
| 140 |
var deletionKeys = oldDatasetKeys.filter(function (key) { |
| 141 |
return key !== '_meta' && newDatasetKeys.indexOf(key) === -1; |
| 142 |
}); |
| 143 |
deletionKeys.forEach(function (deletionKey) { |
| 144 |
delete chart.data.datasets[i][deletionKey]; |
| 145 |
}); |
| 146 |
|
| 147 |
for (var attribute in dataset) { |
| 148 |
if (dataset.hasOwnProperty(attribute)) { |
| 149 |
chart.data.datasets[i][attribute] = dataset[attribute]; |
| 150 |
} |
| 151 |
} |
| 152 |
}); |
| 153 |
|
| 154 |
if (newData.hasOwnProperty('labels')) { |
| 155 |
chart.data.labels = newData.labels; |
| 156 |
this.$emit('labels:update'); |
| 157 |
} |
| 158 |
|
| 159 |
if (newData.hasOwnProperty('xLabels')) { |
| 160 |
chart.data.xLabels = newData.xLabels; |
| 161 |
this.$emit('xlabels:update'); |
| 162 |
} |
| 163 |
|
| 164 |
if (newData.hasOwnProperty('yLabels')) { |
| 165 |
chart.data.yLabels = newData.yLabels; |
| 166 |
this.$emit('ylabels:update'); |
| 167 |
} |
| 168 |
|
| 169 |
chart.update(); |
| 170 |
this.$emit('chart:update'); |
| 171 |
} else { |
| 172 |
if (chart) { |
| 173 |
chart.destroy(); |
| 174 |
this.$emit('chart:destroy'); |
| 175 |
} |
| 176 |
|
| 177 |
this.renderChart(this.chartData, this.options); |
| 178 |
this.$emit('chart:render'); |
| 179 |
} |
| 180 |
} else { |
| 181 |
if (this.$data._chart) { |
| 182 |
this.$data._chart.destroy(); |
| 183 |
|
| 184 |
this.$emit('chart:destroy'); |
| 185 |
} |
| 186 |
|
| 187 |
this.renderChart(this.chartData, this.options); |
| 188 |
this.$emit('chart:render'); |
| 189 |
} |
| 190 |
} |
| 191 |
|
| 192 |
var reactiveData = { |
| 193 |
data: function data() { |
| 194 |
return { |
| 195 |
chartData: null |
| 196 |
}; |
| 197 |
}, |
| 198 |
watch: { |
| 199 |
'chartData': dataHandler |
| 200 |
} |
| 201 |
}; |
| 202 |
var reactiveProp = { |
| 203 |
props: { |
| 204 |
chartData: { |
| 205 |
type: Object, |
| 206 |
required: true, |
| 207 |
default: function _default() {} |
| 208 |
} |
| 209 |
}, |
| 210 |
watch: { |
| 211 |
'chartData': dataHandler |
| 212 |
} |
| 213 |
}; |
| 214 |
/* harmony default export */ __webpack_exports__["a"] = ({ |
| 215 |
reactiveData: reactiveData, |
| 216 |
reactiveProp: reactiveProp |
| 217 |
}); |
| 218 |
|
| 219 |
/***/ }), |
| 220 |
/* 2 */ |
| 221 |
/***/ (function(module, __webpack_exports__, __webpack_require__) { |
| 222 |
|
| 223 |
"use strict"; |
| 224 |
/* harmony export (immutable) */ __webpack_exports__["j"] = generateChart; |
| 225 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Bar; }); |
| 226 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return HorizontalBar; }); |
| 227 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return Doughnut; }); |
| 228 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return Line; }); |
| 229 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return Pie; }); |
| 230 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return PolarArea; }); |
| 231 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return Radar; }); |
| 232 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return Bubble; }); |
| 233 |
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return Scatter; }); |
| 234 |
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_chart_js__ = __webpack_require__(3); |
| 235 |
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_chart_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_chart_js__); |
| 236 |
|
| 237 |
function generateChart(chartId, chartType) { |
| 238 |
return { |
| 239 |
render: function render(createElement) { |
| 240 |
return createElement('div', { |
| 241 |
style: this.styles, |
| 242 |
class: this.cssClasses |
| 243 |
}, [createElement('canvas', { |
| 244 |
attrs: { |
| 245 |
id: this.chartId, |
| 246 |
width: this.width, |
| 247 |
height: this.height |
| 248 |
}, |
| 249 |
ref: 'canvas' |
| 250 |
})]); |
| 251 |
}, |
| 252 |
props: { |
| 253 |
chartId: { |
| 254 |
default: chartId, |
| 255 |
type: String |
| 256 |
}, |
| 257 |
width: { |
| 258 |
default: 400, |
| 259 |
type: Number |
| 260 |
}, |
| 261 |
height: { |
| 262 |
default: 400, |
| 263 |
type: Number |
| 264 |
}, |
| 265 |
cssClasses: { |
| 266 |
type: String, |
| 267 |
default: '' |
| 268 |
}, |
| 269 |
styles: { |
| 270 |
type: Object |
| 271 |
}, |
| 272 |
plugins: { |
| 273 |
type: Array, |
| 274 |
default: function _default() { |
| 275 |
return []; |
| 276 |
} |
| 277 |
} |
| 278 |
}, |
| 279 |
data: function data() { |
| 280 |
return { |
| 281 |
_chart: null, |
| 282 |
_plugins: this.plugins |
| 283 |
}; |
| 284 |
}, |
| 285 |
methods: { |
| 286 |
addPlugin: function addPlugin(plugin) { |
| 287 |
this.$data._plugins.push(plugin); |
| 288 |
}, |
| 289 |
generateLegend: function generateLegend() { |
| 290 |
if (this.$data._chart) { |
| 291 |
return this.$data._chart.generateLegend(); |
| 292 |
} |
| 293 |
}, |
| 294 |
renderChart: function renderChart(data, options) { |
| 295 |
if (this.$data._chart) this.$data._chart.destroy(); |
| 296 |
if (!this.$refs.canvas) throw new Error('Please remove the <template></template> tags from your chart component. See https://vue-chartjs.org/guide/#vue-single-file-components'); |
| 297 |
this.$data._chart = new __WEBPACK_IMPORTED_MODULE_0_chart_js___default.a(this.$refs.canvas.getContext('2d'), { |
| 298 |
type: chartType, |
| 299 |
data: data, |
| 300 |
options: options, |
| 301 |
plugins: this.$data._plugins |
| 302 |
}); |
| 303 |
} |
| 304 |
}, |
| 305 |
beforeDestroy: function beforeDestroy() { |
| 306 |
if (this.$data._chart) { |
| 307 |
this.$data._chart.destroy(); |
| 308 |
} |
| 309 |
} |
| 310 |
}; |
| 311 |
} |
| 312 |
var Bar = generateChart('bar-chart', 'bar'); |
| 313 |
var HorizontalBar = generateChart('horizontalbar-chart', 'horizontalBar'); |
| 314 |
var Doughnut = generateChart('doughnut-chart', 'doughnut'); |
| 315 |
var Line = generateChart('line-chart', 'line'); |
| 316 |
var Pie = generateChart('pie-chart', 'pie'); |
| 317 |
var PolarArea = generateChart('polar-chart', 'polarArea'); |
| 318 |
var Radar = generateChart('radar-chart', 'radar'); |
| 319 |
var Bubble = generateChart('bubble-chart', 'bubble'); |
| 320 |
var Scatter = generateChart('scatter-chart', 'scatter'); |
| 321 |
/* unused harmony default export */ var _unused_webpack_default_export = ({ |
| 322 |
Bar: Bar, |
| 323 |
HorizontalBar: HorizontalBar, |
| 324 |
Doughnut: Doughnut, |
| 325 |
Line: Line, |
| 326 |
Pie: Pie, |
| 327 |
PolarArea: PolarArea, |
| 328 |
Radar: Radar, |
| 329 |
Bubble: Bubble, |
| 330 |
Scatter: Scatter |
| 331 |
}); |
| 332 |
|
| 333 |
/***/ }), |
| 334 |
/* 3 */ |
| 335 |
/***/ (function(module, exports) { |
| 336 |
|
| 337 |
module.exports = __WEBPACK_EXTERNAL_MODULE_3__; |
| 338 |
|
| 339 |
/***/ }) |
| 340 |
/******/ ]); |
| 341 |
}); |
| 342 |
//# sourceMappingURL=vue-chartjs.js.map |