node_modules

This commit is contained in:
saeid
2019-07-15 13:07:31 +04:30
parent d3735c6d30
commit ce1a3ebf9c
35713 changed files with 3639219 additions and 1 deletions
+95
View File
@@ -0,0 +1,95 @@
import Chart from 'chart.js';
export function generateChart(chartId, chartType) {
return {
render: function render(createElement) {
return createElement('div', {
style: this.styles,
class: this.cssClasses
}, [createElement('canvas', {
attrs: {
id: this.chartId,
width: this.width,
height: this.height
},
ref: 'canvas'
})]);
},
props: {
chartId: {
default: chartId,
type: String
},
width: {
default: 400,
type: Number
},
height: {
default: 400,
type: Number
},
cssClasses: {
type: String,
default: ''
},
styles: {
type: Object
},
plugins: {
type: Array,
default: function _default() {
return [];
}
}
},
data: function data() {
return {
_chart: null,
_plugins: this.plugins
};
},
methods: {
addPlugin: function addPlugin(plugin) {
this.$data._plugins.push(plugin);
},
generateLegend: function generateLegend() {
if (this.$data._chart) {
return this.$data._chart.generateLegend();
}
},
renderChart: function renderChart(data, options) {
if (this.$data._chart) this.$data._chart.destroy();
this.$data._chart = new Chart(this.$refs.canvas.getContext('2d'), {
type: chartType,
data: data,
options: options,
plugins: this.$data._plugins
});
}
},
beforeDestroy: function beforeDestroy() {
if (this.$data._chart) {
this.$data._chart.destroy();
}
}
};
}
export var Bar = generateChart('bar-chart', 'bar');
export var HorizontalBar = generateChart('horizontalbar-chart', 'horizontalBar');
export var Doughnut = generateChart('doughnut-chart', 'doughnut');
export var Line = generateChart('line-chart', 'line');
export var Pie = generateChart('pie-chart', 'pie');
export var PolarArea = generateChart('polar-chart', 'polarArea');
export var Radar = generateChart('radar-chart', 'radar');
export var Bubble = generateChart('bubble-chart', 'bubble');
export var Scatter = generateChart('scatter-chart', 'scatter');
export default {
Bar: Bar,
HorizontalBar: HorizontalBar,
Doughnut: Doughnut,
Line: Line,
Pie: Pie,
PolarArea: PolarArea,
Radar: Radar,
Bubble: Bubble,
Scatter: Scatter
};
+17
View File
@@ -0,0 +1,17 @@
import { Bar } from '../BaseCharts';
export default {
extends: Bar,
mounted: function mounted() {
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [{
label: 'Data One',
backgroundColor: '#f87979',
data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
}]
}, {
responsive: true,
maintainAspectRatio: false
});
}
};
+44
View File
@@ -0,0 +1,44 @@
import { Bubble } from '../BaseCharts';
export default {
extends: Bubble,
mounted: function mounted() {
this.renderChart({
datasets: [{
label: 'Data One',
backgroundColor: '#f87979',
data: [{
x: 20,
y: 25,
r: 5
}, {
x: 40,
y: 10,
r: 10
}, {
x: 30,
y: 22,
r: 30
}]
}, {
label: 'Data Two',
backgroundColor: '#7C8CF8',
data: [{
x: 10,
y: 30,
r: 15
}, {
x: 20,
y: 20,
r: 10
}, {
x: 15,
y: 8,
r: 30
}]
}]
}, {
responsive: true,
maintainAspectRatio: false
});
}
};
+44
View File
@@ -0,0 +1,44 @@
import Chart from 'chart.js';
import { generateChart } from '../BaseCharts';
Chart.defaults.LineWithLine = Chart.defaults.line;
Chart.controllers.LineWithLine = Chart.controllers.line.extend({
draw: function draw(ease) {
Chart.controllers.line.prototype.draw.call(this, ease);
if (this.chart.tooltip._active && this.chart.tooltip._active.length) {
var activePoint = this.chart.tooltip._active[0];
var ctx = this.chart.ctx;
var x = activePoint.tooltipPosition().x;
var topY = this.chart.scales['y-axis-0'].top;
var bottomY = this.chart.scales['y-axis-0'].bottom;
ctx.save();
ctx.beginPath();
ctx.moveTo(x, topY);
ctx.lineTo(x, bottomY);
ctx.lineWidth = 2;
ctx.strokeStyle = '#07C';
ctx.stroke();
ctx.restore();
}
}
});
var LineWithLine = generateChart('line-with-chart', 'LineWithLine');
export default {
extends: LineWithLine,
mounted: function mounted() {
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [{
label: 'Data One',
backgroundColor: '#f87979',
data: [40, 39, 10, 40, 39, 80, 40]
}]
}, {
responsive: true,
maintainAspectRatio: false,
tooltips: {
intersect: false
}
});
}
};
+16
View File
@@ -0,0 +1,16 @@
import { Doughnut } from '../BaseCharts';
export default {
extends: Doughnut,
mounted: function mounted() {
this.renderChart({
labels: ['VueJs', 'EmberJs', 'ReactJs', 'AngularJs'],
datasets: [{
backgroundColor: ['#41B883', '#E46651', '#00D8FF', '#DD1B16'],
data: [40, 20, 80, 10]
}]
}, {
responsive: true,
maintainAspectRatio: false
});
}
};
+17
View File
@@ -0,0 +1,17 @@
import { HorizontalBar } from '../BaseCharts';
export default {
extends: HorizontalBar,
mounted: function mounted() {
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [{
label: 'Data One',
backgroundColor: '#f87979',
data: [40, 20, 12, 39, 10, 40, 39, 80, 40, 20, 12, 11]
}]
}, {
responsive: true,
maintainAspectRatio: false
});
}
};
+17
View File
@@ -0,0 +1,17 @@
import { Line } from '../BaseCharts';
export default {
extends: Line,
mounted: function mounted() {
this.renderChart({
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [{
label: 'Data One',
backgroundColor: '#f87979',
data: [40, 39, 10, 40, 39, 80, 40]
}]
}, {
responsive: true,
maintainAspectRatio: false
});
}
};
+16
View File
@@ -0,0 +1,16 @@
import { Pie } from '../BaseCharts';
export default {
extends: Pie,
mounted: function mounted() {
this.renderChart({
labels: ['VueJs', 'EmberJs', 'ReactJs', 'AngularJs'],
datasets: [{
backgroundColor: ['#41B883', '#E46651', '#00D8FF', '#DD1B16'],
data: [40, 20, 80, 10]
}]
}, {
responsive: true,
maintainAspectRatio: false
});
}
};
+29
View File
@@ -0,0 +1,29 @@
import { PolarArea } from '../BaseCharts';
export default {
extends: PolarArea,
mounted: function mounted() {
this.renderChart({
labels: ['Eating', 'Drinking', 'Sleeping', 'Designing', 'Coding', 'Cycling', 'Running'],
datasets: [{
label: 'My First dataset',
backgroundColor: 'rgba(179,181,198,0.2)',
pointBackgroundColor: 'rgba(179,181,198,1)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgba(179,181,198,1)',
data: [65, 59, 90, 81, 56, 55, 40]
}, {
label: 'My Second dataset',
backgroundColor: 'rgba(255,99,132,0.2)',
pointBackgroundColor: 'rgba(255,99,132,1)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgba(255,99,132,1)',
data: [28, 48, 40, 19, 96, 27, 100]
}]
}, {
responsive: true,
maintainAspectRatio: false
});
}
};
+31
View File
@@ -0,0 +1,31 @@
import { Radar } from '../BaseCharts';
export default {
extends: Radar,
mounted: function mounted() {
this.renderChart({
labels: ['Eating', 'Drinking', 'Sleeping', 'Designing', 'Coding', 'Cycling', 'Running'],
datasets: [{
label: 'My First dataset',
backgroundColor: 'rgba(179,181,198,0.2)',
borderColor: 'rgba(179,181,198,1)',
pointBackgroundColor: 'rgba(179,181,198,1)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgba(179,181,198,1)',
data: [65, 59, 90, 81, 56, 55, 40]
}, {
label: 'My Second dataset',
backgroundColor: 'rgba(255,99,132,0.2)',
borderColor: 'rgba(255,99,132,1)',
pointBackgroundColor: 'rgba(255,99,132,1)',
pointBorderColor: '#fff',
pointHoverBackgroundColor: '#fff',
pointHoverBorderColor: 'rgba(255,99,132,1)',
data: [28, 48, 40, 19, 96, 27, 100]
}]
}, {
responsive: true,
maintainAspectRatio: false
});
}
};
+41
View File
@@ -0,0 +1,41 @@
import { Bar } from '../BaseCharts';
import { reactiveData } from '../mixins';
export default {
extends: Bar,
mixins: [reactiveData],
data: function data() {
return {
chartData: '',
options: {
responsive: true,
maintainAspectRatio: false
}
};
},
created: function created() {
this.fillData();
},
mounted: function mounted() {
var _this = this;
this.renderChart(this.chartData, this.options);
setInterval(function () {
_this.fillData();
}, 5000);
},
methods: {
fillData: function fillData() {
this.chartData = {
labels: ['January' + this.getRandomInt(), 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
datasets: [{
label: 'Data One',
backgroundColor: '#f87979',
data: [this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt(), this.getRandomInt()]
}]
};
},
getRandomInt: function getRandomInt() {
return Math.floor(Math.random() * (50 - 5 + 1)) + 5;
}
}
};
+17
View File
@@ -0,0 +1,17 @@
import { Bar } from '../BaseCharts';
import { reactiveProp } from '../mixins';
export default {
extends: Bar,
mixins: [reactiveProp],
data: function data() {
return {
options: {
responsive: true,
maintainAspectRatio: false
}
};
},
mounted: function mounted() {
this.renderChart(this.chartData, this.options);
}
};
+54
View File
@@ -0,0 +1,54 @@
import { Scatter } from '../BaseCharts';
export default {
extends: Scatter,
mounted: function mounted() {
this.renderChart({
datasets: [{
label: 'Scatter Dataset 1',
fill: false,
borderColor: '#f87979',
backgroundColor: '#f87979',
data: [{
x: -2,
y: 4
}, {
x: -1,
y: 1
}, {
x: 0,
y: 0
}, {
x: 1,
y: 1
}, {
x: 2,
y: 4
}]
}, {
label: 'Scatter Dataset 2',
fill: false,
borderColor: '#7acbf9',
backgroundColor: '#7acbf9',
data: [{
x: -2,
y: -4
}, {
x: -1,
y: -1
}, {
x: 0,
y: 1
}, {
x: 1,
y: -1
}, {
x: 2,
y: -4
}]
}]
}, {
responsive: true,
maintainAspectRatio: false
});
}
};
+20
View File
@@ -0,0 +1,20 @@
import mixins from './mixins/index.js';
import { Bar, HorizontalBar, Doughnut, Line, Pie, PolarArea, Radar, Bubble, Scatter, generateChart } from './BaseCharts';
var VueCharts = {
Bar: Bar,
HorizontalBar: HorizontalBar,
Doughnut: Doughnut,
Line: Line,
Pie: Pie,
PolarArea: PolarArea,
Radar: Radar,
Bubble: Bubble,
Scatter: Scatter,
mixins: mixins,
generateChart: generateChart,
render: function render() {
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');
}
};
export default VueCharts;
export { VueCharts, Bar, HorizontalBar, Doughnut, Line, Pie, PolarArea, Radar, Bubble, Scatter, mixins, generateChart };
+7
View File
@@ -0,0 +1,7 @@
import Vue from 'vue';
import App from './examples/App';
new Vue({
render: function render(h) {
return h(App);
}
}).$mount('#app');
+94
View File
@@ -0,0 +1,94 @@
function dataHandler(newData, oldData) {
if (oldData) {
var chart = this.$data._chart;
var newDatasetLabels = newData.datasets.map(function (dataset) {
return dataset.label;
});
var oldDatasetLabels = oldData.datasets.map(function (dataset) {
return dataset.label;
});
var oldLabels = JSON.stringify(oldDatasetLabels);
var newLabels = JSON.stringify(newDatasetLabels);
if (newLabels === oldLabels && oldData.datasets.length === newData.datasets.length) {
newData.datasets.forEach(function (dataset, i) {
var oldDatasetKeys = Object.keys(oldData.datasets[i]);
var newDatasetKeys = Object.keys(dataset);
var deletionKeys = oldDatasetKeys.filter(function (key) {
return key !== '_meta' && newDatasetKeys.indexOf(key) === -1;
});
deletionKeys.forEach(function (deletionKey) {
delete chart.data.datasets[i][deletionKey];
});
for (var attribute in dataset) {
if (dataset.hasOwnProperty(attribute)) {
chart.data.datasets[i][attribute] = dataset[attribute];
}
}
});
if (newData.hasOwnProperty('labels')) {
chart.data.labels = newData.labels;
this.$emit('labels:update');
}
if (newData.hasOwnProperty('xLabels')) {
chart.data.xLabels = newData.xLabels;
this.$emit('xlabels:update');
}
if (newData.hasOwnProperty('yLabels')) {
chart.data.yLabels = newData.yLabels;
this.$emit('ylabels:update');
}
chart.update();
this.$emit('chart:update');
} else {
if (chart) {
chart.destroy();
this.$emit('chart:destroy');
}
this.renderChart(this.chartData, this.options);
this.$emit('chart:render');
}
} else {
if (this.$data._chart) {
this.$data._chart.destroy();
this.$emit('chart:destroy');
}
this.renderChart(this.chartData, this.options);
this.$emit('chart:render');
}
}
export var reactiveData = {
data: function data() {
return {
chartData: null
};
},
watch: {
'chartData': dataHandler
}
};
export var reactiveProp = {
props: {
chartData: {
type: Object,
required: true,
default: function _default() {}
}
},
watch: {
'chartData': dataHandler
}
};
export default {
reactiveData: reactiveData,
reactiveProp: reactiveProp
};