vuetify eingebunden + erster Versuch Combobox

This commit is contained in:
gruenzingerxe68435 committed 2019-04-17 15:58:15 +02:00
1 parent 24642ca1a8
commit 56f4a3f940
1846 files changed
+219701 -53848

No files matched your search

+366
View File
@@ -0,0 +1,366 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; // Mixins
// Utilities
var _colorable = require('../../mixins/colorable');
var _colorable2 = _interopRequireDefault(_colorable);
var _mixins = require('../../util/mixins');
var _mixins2 = _interopRequireDefault(_mixins);
var _core = require('./helpers/core');
var _path = require('./helpers/path');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = (0, _mixins2.default)(_colorable2.default).extend({
name: 'VSparkline',
props: {
autoDraw: Boolean,
autoDrawDuration: {
type: Number,
default: 2000
},
autoDrawEasing: {
type: String,
default: 'ease'
},
autoLineWidth: {
type: Boolean,
default: false
},
color: {
type: String,
default: 'primary'
},
fill: {
type: Boolean,
default: false
},
gradient: {
type: Array,
default: function _default() {
return [];
}
},
gradientDirection: {
type: String,
validator: function validator(val) {
return ['top', 'bottom', 'left', 'right'].includes(val);
},
default: 'top'
},
height: {
type: [String, Number],
default: 75
},
labels: {
type: Array,
default: function _default() {
return [];
}
},
lineWidth: {
type: [String, Number],
default: 4
},
padding: {
type: [String, Number],
default: 8
},
smooth: {
type: [Boolean, Number, String],
default: false
},
showLabels: Boolean,
type: {
type: String,
default: 'trend',
validator: function validator(val) {
return ['trend', 'bar'].includes(val);
}
},
value: {
type: Array,
default: function _default() {
return [];
}
},
width: {
type: [Number, String],
default: 300
},
labelSize: {
type: [Number, String],
default: 7
}
},
data: function data() {
return {
lastLength: 0
};
},
computed: {
parsedPadding: function parsedPadding() {
return Number(this.padding);
},
parsedWidth: function parsedWidth() {
return Number(this.width);
},
totalBars: function totalBars() {
return this.value.length;
},
_lineWidth: function _lineWidth() {
if (this.autoLineWidth && this.type !== 'trend') {
var totalPadding = this.parsedPadding * (this.totalBars + 1);
return (this.parsedWidth - totalPadding) / this.totalBars;
} else {
return Number(this.lineWidth) || 4;
}
},
boundary: function boundary() {
var height = Number(this.height);
return {
minX: this.parsedPadding,
minY: this.parsedPadding,
maxX: this.parsedWidth - this.parsedPadding,
maxY: height - this.parsedPadding
};
},
hasLabels: function hasLabels() {
return Boolean(this.showLabels || this.labels.length > 0 || this.$scopedSlots.label);
},
parsedLabels: function parsedLabels() {
var labels = [];
var points = this.points;
var len = points.length;
for (var i = 0; labels.length < len; i++) {
var item = points[i];
var value = this.labels[i];
if (!value) {
value = item === Object(item) ? item.value : item;
}
labels.push(_extends({}, item, {
value: String(value)
}));
}
return labels;
},
points: function points() {
return (0, _core.genPoints)(this.value.slice(), this.boundary, this.type);
},
textY: function textY() {
return this.boundary.maxY + 6;
}
},
watch: {
value: {
immediate: true,
handler: function handler() {
var _this = this;
this.$nextTick(function () {
if (!_this.autoDraw || _this.type === 'bar') return;
var path = _this.$refs.path;
var length = path.getTotalLength();
if (!_this.fill) {
path.style.transition = 'none';
path.style.strokeDasharray = length + ' ' + length;
path.style.strokeDashoffset = Math.abs(length - (_this.lastLength || 0)).toString();
path.getBoundingClientRect();
path.style.transition = 'stroke-dashoffset ' + _this.autoDrawDuration + 'ms ' + _this.autoDrawEasing;
path.style.strokeDashoffset = '0';
} else {
path.style.transformOrigin = 'bottom center';
path.style.transition = 'none';
path.style.transform = 'scaleY(0)';
path.getBoundingClientRect();
path.style.transition = 'transform ' + _this.autoDrawDuration + 'ms ' + _this.autoDrawEasing;
path.style.transform = 'scaleY(1)';
}
_this.lastLength = length;
});
}
}
},
methods: {
genGradient: function genGradient() {
var _this2 = this;
var gradientDirection = this.gradientDirection;
var gradient = this.gradient.slice();
// Pushes empty string to force
// a fallback to currentColor
if (!gradient.length) gradient.push('');
var len = Math.max(gradient.length - 1, 1);
var stops = gradient.reverse().map(function (color, index) {
return _this2.$createElement('stop', {
attrs: {
offset: index / len,
'stop-color': color || _this2.color || 'currentColor'
}
});
});
return this.$createElement('defs', [this.$createElement('linearGradient', {
attrs: {
id: this._uid,
x1: +(gradientDirection === 'left'),
y1: +(gradientDirection === 'top'),
x2: +(gradientDirection === 'right'),
y2: +(gradientDirection === 'bottom')
}
}, stops)]);
},
genG: function genG(children) {
return this.$createElement('g', {
style: {
fontSize: '8',
textAnchor: 'middle',
dominantBaseline: 'mathematical',
fill: this.color || 'currentColor'
}
}, children);
},
genLabels: function genLabels() {
if (!this.hasLabels) return undefined;
return this.genG(this.parsedLabels.map(this.genText));
},
genPath: function genPath() {
var radius = this.smooth === true ? 8 : Number(this.smooth);
return this.$createElement('path', {
attrs: {
id: this._uid,
d: (0, _path.genPath)(this.points.slice(), radius, this.fill, Number(this.height)),
fill: this.fill ? 'url(#' + this._uid + ')' : 'none',
stroke: this.fill ? 'none' : 'url(#' + this._uid + ')'
},
ref: 'path'
});
},
genText: function genText(item, index) {
var children = this.$scopedSlots.label ? this.$scopedSlots.label({ index: index, value: item.value }) : item.value;
return this.$createElement('text', {
attrs: {
x: item.x,
y: this.textY
}
}, [children]);
},
genBar: function genBar() {
if (!this.value || this.totalBars < 2) return undefined;
var width = this.width,
height = this.height,
parsedPadding = this.parsedPadding,
_lineWidth = this._lineWidth;
var viewWidth = width || this.totalBars * parsedPadding * 2;
var viewHeight = height || 75;
var boundary = {
minX: parsedPadding,
minY: parsedPadding,
maxX: Number(viewWidth) - parsedPadding,
maxY: Number(viewHeight) - parsedPadding
};
var props = _extends({}, this.$props);
props.points = (0, _core.genPoints)(this.value, boundary, this.type);
var totalWidth = boundary.maxX / (props.points.length - 1);
props.boundary = boundary;
props.lineWidth = _lineWidth || totalWidth - Number(parsedPadding || 5);
props.offsetX = 0;
if (!this.autoLineWidth) {
props.offsetX = boundary.maxX / this.totalBars / 2 - boundary.minX;
}
return this.$createElement('svg', {
attrs: {
width: '100%',
height: '25%',
viewBox: '0 0 ' + viewWidth + ' ' + viewHeight
}
}, [this.genGradient(), this.genClipPath(props.offsetX, props.lineWidth, 'sparkline-bar-' + this._uid), this.hasLabels ? this.genBarLabels(props) : undefined, this.$createElement('g', {
attrs: {
transform: 'scale(1,-1) translate(0,-' + boundary.maxY + ')',
'clip-path': 'url(#sparkline-bar-' + this._uid + '-clip)',
fill: 'url(#' + this._uid + ')'
}
}, [this.$createElement('rect', {
attrs: {
x: 0,
y: 0,
width: viewWidth,
height: viewHeight
}
})])]);
},
genClipPath: function genClipPath(offsetX, lineWidth, id) {
var _this3 = this;
var maxY = this.boundary.maxY;
var rounding = typeof this.smooth === 'number' ? this.smooth : this.smooth ? 2 : 0;
return this.$createElement('clipPath', {
attrs: {
id: id + '-clip'
}
}, this.points.map(function (item) {
return _this3.$createElement('rect', {
attrs: {
x: item.x + offsetX,
y: 0,
width: lineWidth,
height: Math.max(maxY - item.y, 0),
rx: rounding,
ry: rounding
}
}, [_this3.autoDraw ? _this3.$createElement('animate', {
attrs: {
attributeName: 'height',
from: 0,
to: maxY - item.y,
dur: _this3.autoDrawDuration + 'ms',
fill: 'freeze'
}
}) : undefined]);
}));
},
genBarLabels: function genBarLabels(props) {
var _this4 = this;
var offsetX = props.offsetX || 0;
var children = props.points.map(function (item) {
return _this4.$createElement('text', {
attrs: {
x: item.x + offsetX + _this4._lineWidth / 2,
y: props.boundary.maxY + (Number(_this4.labelSize) || 7),
'font-size': Number(_this4.labelSize) || 7
}
}, item.value.toString());
});
return this.genG(children);
},
genTrend: function genTrend() {
return this.$createElement('svg', this.setTextColor(this.color, {
attrs: {
'stroke-width': this._lineWidth || 1,
width: '100%',
height: '25%',
viewBox: '0 0 ' + this.width + ' ' + this.height
}
}), [this.genGradient(), this.genLabels(), this.genPath()]);
}
},
render: function render(h) {
if (this.totalBars < 2) return undefined;
return this.type === 'trend' ? this.genTrend() : this.genBar();
}
});
//# sourceMappingURL=VSparkline.js.map
+1
View File
@@ -0,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,wBAAI,KAAK,IADJ;AAEL,wBAAI,EAAE,sBAAsB,MAAxB,CAFC;AAGL,wBAAI,EAAE,sBAAsB,KAAxB,CAHC;AAIL,wBAAI,EAAE,sBAAsB,OAAxB,CAJC;AAKL,wBAAI,EAAE,sBAAsB,QAAxB;AALC;AAD6B,aAAtC,EAQG,KARH,CADiC,CAA5B,CAAP;AAWD,SA9BM;AA+BP,YA/BO,gBA+BD,QA/BC,EA+BgB;AACrB,mBAAO,KAAK,cAAL,CAAoB,GAApB,EAAyB;AAC9B,uBAAO;AACL,8BAAU,GADL;AAEL,gCAAY,QAFP;AAGL,sCAAkB,cAHb;AAIL,0BAAM,KAAK,KAAL,IAAc;AAJf;AADuB,aAAzB,EAOJ,QAPI,CAAP;AAQD,SAxCM;AAyCP,iBAzCO,uBAyCE;AACP,gBAAI,CAAC,KAAK,SAAV,EAAqB,OAAO,SAAP;AAErB,mBAAO,KAAK,IAAL,CAAU,KAAK,YAAL,CAAkB,GAAlB,CAAsB,KAAK,OAA3B,CAAV,CAAP;AACD,SA7CM;AA8CP,eA9CO,qBA8CA;AACL,gBAAM,SAAS,KAAK,MAAL,KAAgB,IAAhB,GAAuB,CAAvB,GAA2B,OAAO,KAAK,MAAZ,CAA1C;AAEA,mBAAO,KAAK,cAAL,CAAoB,MAApB,EAA4B;AACjC,uBAAO;AACL,wBAAI,KAAK,IADJ;AAEL,uBAAG,mBAAQ,KAAK,MAAL,CAAY,KAAZ,EALine truncated
+34
View File
@@ -0,0 +1,34 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.genPoints = genPoints;
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function genPoints(points, boundary, type) {
var minX = boundary.minX,
minY = boundary.minY,
maxX = boundary.maxX,
maxY = boundary.maxY;
var normalisedPoints = points.map(function (item) {
return typeof item === 'number' ? item : item.value;
});
var totalPoints = normalisedPoints.length;
var maxValue = Math.max.apply(Math, _toConsumableArray(normalisedPoints)) + 1;
var minValue = Math.min.apply(Math, _toConsumableArray(normalisedPoints));
if (minValue) minValue -= 1;
var gridX = (maxX - minX) / (totalPoints - 1);
if (type === 'bar') gridX = maxX / totalPoints;
var gridY = (maxY - minY) / (maxValue - minValue);
return normalisedPoints.map(function (value, index) {
return {
x: minX + index * gridX,
y: maxY - (value - minValue) * gridY + +(index === totalPoints - 1) * 0.00001 - +(index === 0) * 0.00001,
value: value
};
});
}
//# sourceMappingURL=core.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/components/VSparkline/helpers/core.ts"],"names":[],"mappings":";;;;;QAEgB,S,GAAA,S;;;;AAAV,SAAU,SAAV,CACJ,MADI,EAEJ,QAFI,EAGJ,IAHI,EAGQ;AAAA,QAEJ,IAFI,GAEuB,QAFvB,CAEJ,IAFI;AAAA,QAEE,IAFF,GAEuB,QAFvB,CAEE,IAFF;AAAA,QAEQ,IAFR,GAEuB,QAFvB,CAEQ,IAFR;AAAA,QAEc,IAFd,GAEuB,QAFvB,CAEc,IAFd;;AAGZ,QAAM,mBAAmB,OAAO,GAAP,CACvB;AAAA,eAAS,OAAO,IAAP,KAAgB,QAAhB,GAA2B,IAA3B,GAAkC,KAAK,KAAhD;AAAA,KADuB,CAAzB;AAGA,QAAM,cAAc,iBAAiB,MAArC;AACA,QAAM,WAAW,KAAK,GAAL,gCAAY,gBAAZ,KAAgC,CAAjD;AACA,QAAI,WAAW,KAAK,GAAL,gCAAY,gBAAZ,EAAf;AAEA,QAAI,QAAJ,EAAc,YAAY,CAAZ;AACd,QAAI,QAAQ,CAAC,OAAO,IAAR,KAAiB,cAAc,CAA/B,CAAZ;AACA,QAAI,SAAS,KAAb,EAAoB,QAAQ,OAAO,WAAf;AACpB,QAAM,QAAQ,CAAC,OAAO,IAAR,KAAiB,WAAW,QAA5B,CAAd;AAEA,WAAO,iBAAiB,GAAjB,CAAqB,UAAC,KAAD,EAAQ,KAAR,EAAiB;AAC3C,eAAO;AACL,eAAG,OAAO,QAAQ,KADb;AAEL,eACE,OACA,CAAC,QAAQ,QAAT,IAAqB,KADrB,GAEA,EAAE,UAAU,cAAc,CAA1B,IAA+B,OAF/B,GAGA,EAAE,UAAU,CAAZ,IAAiB,OANd;AAOL;AAPK,SAAP;AASD,KAVM,CAAP;AAWD","sourcesContent":["import { SparklineItem, Boundary, Point } from '../VSparkline'\n\nexport function genPoints (\n points: SparklineItem[],\n boundary: Boundary,\n type: String\n): Point[] {\n const { minX, minY, maxX, maxY } = boundary\n const normalisedPoints = points.map(\n item => (typeof item === 'number' ? item : item.value)\n )\n const totalPoints = normalisedPoints.length\n const maxValue = Math.max(...normalisedPoints) + 1\n let minValue = Math.min(...normalisedPoints)\n\n if (minValue) minValue -= 1\n let gridX = (maxX - minX) / (totalPoints - 1)\n if (type === 'bar') gridX = maxX / totalPoints\n const gridY = (maxY - minY) / (maxValue - minValue)\n\n return normalisedPoints.map((value, index) => {\n return {\n x: minX + index * gridX,\n y:\n maxY -\n (value - minValue) * gridY +\n +(index === totalPoints - 1) * 0.00001 -\n +(index === 0) * 0.00001,\n value\n }\n })\n}\n"],"sourceRoot":""}
+32
View File
@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.checkCollinear = checkCollinear;
exports.getDistance = getDistance;
exports.moveTo = moveTo;
function int(value) {
return parseInt(value, 10);
}
/**
* https://en.wikipedia.org/wiki/Collinearity
* x=(x1+x2)/2
* y=(y1+y2)/2
*/
function checkCollinear(p0, p1, p2) {
return int(p0.x + p2.x) === int(2 * p1.x) && int(p0.y + p2.y) === int(2 * p1.y);
}
function getDistance(p1, p2) {
return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
}
function moveTo(to, from, radius) {
var vector = { x: to.x - from.x, y: to.y - from.y };
var length = Math.sqrt(vector.x * vector.x + vector.y * vector.y);
var unitVector = { x: vector.x / length, y: vector.y / length };
return {
x: from.x + unitVector.x * radius,
y: from.y + unitVector.y * radius
};
}
//# sourceMappingURL=math.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/components/VSparkline/helpers/math.ts"],"names":[],"mappings":";;;;;QAWgB,c,GAAA,c;QAIA,W,GAAA,W;QAMA,M,GAAA,M;AAnBhB,SAAS,GAAT,CAAc,KAAd,EAAoC;AAClC,WAAO,SAAS,KAAT,EAAgB,EAAhB,CAAP;AACD;AAED;;;;;AAKM,SAAU,cAAV,CAA0B,EAA1B,EAAqC,EAArC,EAAgD,EAAhD,EAAyD;AAC7D,WAAO,IAAI,GAAG,CAAH,GAAO,GAAG,CAAd,MAAqB,IAAI,IAAI,GAAG,CAAX,CAArB,IAAsC,IAAI,GAAG,CAAH,GAAO,GAAG,CAAd,MAAqB,IAAI,IAAI,GAAG,CAAX,CAAlE;AACD;AAEK,SAAU,WAAV,CAAuB,EAAvB,EAAkC,EAAlC,EAA2C;AAC/C,WAAO,KAAK,IAAL,CACL,KAAK,GAAL,CAAS,GAAG,CAAH,GAAO,GAAG,CAAnB,EAAsB,CAAtB,IAA2B,KAAK,GAAL,CAAS,GAAG,CAAH,GAAO,GAAG,CAAnB,EAAsB,CAAtB,CADtB,CAAP;AAGD;AAEK,SAAU,MAAV,CAAkB,EAAlB,EAA6B,IAA7B,EAA0C,MAA1C,EAAwD;AAC5D,QAAM,SAAS,EAAE,GAAG,GAAG,CAAH,GAAO,KAAK,CAAjB,EAAoB,GAAG,GAAG,CAAH,GAAO,KAAK,CAAnC,EAAf;AACA,QAAM,SAAS,KAAK,IAAL,CAAW,OAAO,CAAP,GAAW,OAAO,CAAnB,GAAyB,OAAO,CAAP,GAAW,OAAO,CAArD,CAAf;AACA,QAAM,aAAa,EAAE,GAAG,OAAO,CAAP,GAAW,MAAhB,EAAwB,GAAG,OAAO,CAAP,GAAW,MAAtC,EAAnB;AAEA,WAAO;AACL,WAAG,KAAK,CAAL,GAAS,WAAW,CAAX,GAAe,MADtB;AAEL,WAAG,KAAK,CAAL,GAAS,WAAW,CAAX,GAAe;AAFtB,KAAP;AAID","sourcesContent":["import { Point } from '../VSparkline'\n\nfunction int (value: string | number): number {\n return parseInt(value, 10)\n}\n\n/**\n * https://en.wikipedia.org/wiki/Collinearity\n * x=(x1+x2)/2\n * y=(y1+y2)/2\n */\nexport function checkCollinear (p0: Point, p1: Point, p2: Point): boolean {\n return int(p0.x + p2.x) === int(2 * p1.x) && int(p0.y + p2.y) === int(2 * p1.y)\n}\n\nexport function getDistance (p1: Point, p2: Point): number {\n return Math.sqrt(\n Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2)\n )\n}\n\nexport function moveTo (to: Point, from: Point, radius: number) {\n const vector = { x: to.x - from.x, y: to.y - from.y }\n const length = Math.sqrt((vector.x * vector.x) + (vector.y * vector.y))\n const unitVector = { x: vector.x / length, y: vector.y / length }\n\n return {\n x: from.x + unitVector.x * radius,\n y: from.y + unitVector.y * radius\n }\n}\n"],"sourceRoot":""}
+34
View File
@@ -0,0 +1,34 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.genPath = genPath;
var _math = require('./math');
/**
* From https://github.com/unsplash/react-trend/blob/master/src/helpers/DOM.helpers.js#L18
*/
function genPath(points, radius) {
var fill = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var height = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 75;
var start = points.shift();
var end = points[points.length - 1];
return (fill ? 'M' + start.x + ' ' + height + ' L' + start.x + ' ' + start.y : 'M' + start.x + ' ' + start.y) + points.map(function (point, index) {
var next = points[index + 1];
var prev = points[index - 1] || start;
var isCollinear = next && (0, _math.checkCollinear)(next, point, prev);
if (!next || isCollinear) {
return 'L' + point.x + ' ' + point.y;
}
var threshold = Math.min((0, _math.getDistance)(prev, point), (0, _math.getDistance)(next, point));
var isTooCloseForRadius = threshold / 2 < radius;
var radiusForPoint = isTooCloseForRadius ? threshold / 2 : radius;
var before = (0, _math.moveTo)(prev, point, radiusForPoint);
var after = (0, _math.moveTo)(next, point, radiusForPoint);
return 'L' + before.x + ' ' + before.y + 'S' + point.x + ' ' + point.y + ' ' + after.x + ' ' + after.y;
}).join('') + (fill ? 'L' + end.x + ' ' + height + ' Z' : '');
}
//# sourceMappingURL=path.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/components/VSparkline/helpers/path.ts"],"names":[],"mappings":";;;;;QAMgB,O,GAAA,O;;;;AAHhB;;;AAGM,SAAU,OAAV,CAAmB,MAAnB,EAAoC,MAApC,EAA6E;AAAA,QAAzB,IAAyB,uEAAlB,KAAkB;AAAA,QAAX,MAAW,uEAAF,EAAE;;AACjF,QAAM,QAAQ,OAAO,KAAP,EAAd;AACA,QAAM,MAAM,OAAO,OAAO,MAAP,GAAgB,CAAvB,CAAZ;AAEA,WACE,CAAC,aAAW,MAAM,CAAjB,SAAsB,MAAtB,UAAiC,MAAM,CAAvC,SAA4C,MAAM,CAAlD,SAA4D,MAAM,CAAlE,SAAuE,MAAM,CAA9E,IACA,OACG,GADH,CACO,UAAC,KAAD,EAAQ,KAAR,EAAiB;AACpB,YAAM,OAAO,OAAO,QAAQ,CAAf,CAAb;AACA,YAAM,OAAO,OAAO,QAAQ,CAAf,KAAqB,KAAlC;AACA,YAAM,cAAc,QAAQ,0BAAe,IAAf,EAAqB,KAArB,EAA4B,IAA5B,CAA5B;AAEA,YAAI,CAAC,IAAD,IAAS,WAAb,EAA0B;AACxB,yBAAW,MAAM,CAAjB,SAAsB,MAAM,CAA5B;AACD;AAED,YAAM,YAAY,KAAK,GAAL,CAChB,uBAAY,IAAZ,EAAkB,KAAlB,CADgB,EAEhB,uBAAY,IAAZ,EAAkB,KAAlB,CAFgB,CAAlB;AAIA,YAAM,sBAAsB,YAAY,CAAZ,GAAgB,MAA5C;AACA,YAAM,iBAAiB,sBAAsB,YAAY,CAAlC,GAAsC,MAA7D;AAEA,YAAM,SAAS,kBAAO,IAAP,EAAa,KAAb,EAAoB,cAApB,CAAf;AACA,YAAM,QAAQ,kBAAO,IAAP,EAAa,KAAb,EAAoB,cAApB,CAAd;AAEA,qBAAW,OAAO,CAAlB,SAAuB,OAAO,CAA9B,SAAmC,MAAM,CAAzC,SAA8C,MAAM,CAApD,SAAyD,MAAM,CAA/D,SAAoE,MAAM,CAA1E;AACD,KArBH,EAsBG,IAtBH,CAsBQ,EAtBR,CADA,IAwBC,aAAW,IAAI,CAAf,SAAoB,MAApB,UAAiC,EAxBlC,CADF;AA0BD","sourcesContent":["import { Point } from '../VSparkline'\nimport { checkCollinear, getDistance, moveTo } from './math'\n\n/**\n * From https://github.com/unsplash/react-trend/blob/master/src/helpers/DOM.helpers.js#L18\n */\nexport function genPath (points: Point[], radius: number, fill = false, height = 75) {\n const start = points.shift()!\n const end = points[points.length - 1]\n\n return (\n (fill ? `M${start.x} ${height} L${start.x} ${start.y}` : `M${start.x} ${start.y}`) +\n points\n .map((point, index) => {\n const next = points[index + 1]\n const prev = points[index - 1] || start\n const isCollinear = next && checkCollinear(next, point, prev)\n\n if (!next || isCollinear) {\n return `L${point.x} ${point.y}`\n }\n\n const threshold = Math.min(\n getDistance(prev, point),\n getDistance(next, point)\n )\n const isTooCloseForRadius = threshold / 2 < radius\n const radiusForPoint = isTooCloseForRadius ? threshold / 2 : radius\n\n const before = moveTo(prev, point, radiusForPoint)\n const after = moveTo(next, point, radiusForPoint)\n\n return `L${before.x} ${before.y}S${point.x} ${point.y} ${after.x} ${after.y}`\n })\n .join('') +\n (fill ? `L${end.x} ${height} Z` : ''))\n}\n"],"sourceRoot":""}
+16
View File
@@ -0,0 +1,16 @@
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.VSparkline = undefined;
var _VSparkline = require('./VSparkline');
var _VSparkline2 = _interopRequireDefault(_VSparkline);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.VSparkline = _VSparkline2.default;
exports.default = _VSparkline2.default;
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/components/VSparkline/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;QAES,U,GAAA,oB;kBAEM,oB","sourcesContent":["import VSparkline from './VSparkline'\n\nexport { VSparkline }\n\nexport default VSparkline\n"],"sourceRoot":""}