diff --git a/fe/PDA/App.vue b/fe/PDA/App.vue
index 9429e4cad..9b953b817 100644
--- a/fe/PDA/App.vue
+++ b/fe/PDA/App.vue
@@ -15,13 +15,14 @@
}
-
+```
-1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
-2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
-3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
-4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
-5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
-6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
+3. `uni.scss`引入全局scss变量文件
+```css
+/* uni.scss */
+@import "uview-ui/theme.scss";
+```
+
+4. `pages.json`配置easycom规则(按需引入)
+
+```js
+// pages.json
+{
+ "easycom": {
+ // npm安装的方式不需要前面的"@/",下载安装的方式需要"@/"
+ // npm安装方式
+ "^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
+ // 下载安装方式
+ // "^u-(.*)": "@/uview-ui/components/u-$1/u-$1.vue"
+ },
+ // 此为本身已有的内容
+ "pages": [
+ // ......
+ ]
+}
+```
+
+请通过[快速上手](https://uviewui.com/components/quickstart.html)了解更详细的内容
+
+## 使用方法
+配置easycom规则后,自动按需引入,无需`import`组件,直接引用即可。
+
+```html
+
+ 按钮
+
+```
+
+请通过[快速上手](https://uviewui.com/components/quickstart.html)了解更详细的内容
+
+## 链接
+
+- [官方文档](https://uviewui.com/)
+- [更新日志](https://uviewui.com/components/changelog.html)
+- [升级指南](https://uviewui.com/components/changelog.html)
+- [关于我们](https://uviewui.com/cooperation/about.html)
+
+## 预览
+
+您可以通过**微信**扫码,查看最佳的演示效果。
+
+
+
+
+
+## 版权信息
+uView遵循[MIT](https://en.wikipedia.org/wiki/MIT_License)开源协议,意味着您无需支付任何费用,也无需授权,即可将uView应用到您的产品中。
diff --git a/fe/PDA/api/index.js b/fe/PDA/api/index.js
index ea131373a..d013fb31c 100644
--- a/fe/PDA/api/index.js
+++ b/fe/PDA/api/index.js
@@ -1563,4 +1563,12 @@ export const finshInjectIssueJob = (id, params) => request(
devUrl + "/api/pda/job/injection/finish/" + id, { //
data: params,
method: "post"
- })
\ No newline at end of file
+ })
+//注塑发料获取物料配置信息
+export const getItemCategoryList = () => request(
+ devUrl + "/api/pda/store/injection-request/list/item-category", { //
+ data: {},
+ method: "get"
+ })
+
+
\ No newline at end of file
diff --git a/fe/PDA/components/u-charts/u-charts.js b/fe/PDA/components/u-charts/u-charts.js
deleted file mode 100644
index 3b1b7989d..000000000
--- a/fe/PDA/components/u-charts/u-charts.js
+++ /dev/null
@@ -1,5046 +0,0 @@
-/*
- * uCharts v1.8.5.20190815
- * uni-app平台高性能跨全端图表,支持H5、APP、小程序(微信/支付宝/百度/头条/QQ/360)
- * Copyright (c) 2019 QIUN秋云 https://www.ucharts.cn All rights reserved.
- * Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
- *
- * uCharts官方网站
- * https://www.uCharts.cn
- *
- * 开源地址:
- * https://gitee.com/uCharts/uCharts
- *
- * uni-app插件市场地址:
- * http://ext.dcloud.net.cn/plugin?id=271
- *
- */
-
-'use strict';
-
-var config = {
- yAxisWidth: 15,
- yAxisSplit: 5,
- xAxisHeight: 15,
- xAxisLineHeight: 15,
- legendHeight: 15,
- yAxisTitleWidth: 15,
- padding: [10, 10, 10, 10],
- pixelRatio: 1,
- rotate: false,
- columePadding: 3,
- fontSize: 13,
- //dataPointShape: ['diamond', 'circle', 'triangle', 'rect'],
- dataPointShape: ['circle', 'circle', 'circle', 'circle'],
- colors: ['#1890ff', '#2fc25b', '#facc14', '#f04864', '#8543e0', '#90ed7d'],
- pieChartLinePadding: 15,
- pieChartTextPadding: 5,
- xAxisTextPadding: 3,
- titleColor: '#333333',
- titleFontSize: 20,
- subtitleColor: '#999999',
- subtitleFontSize: 15,
- toolTipPadding: 3,
- toolTipBackground: '#000000',
- toolTipOpacity: 0.7,
- toolTipLineHeight: 20,
- radarGridCount: 3,
- radarLabelTextMargin: 15,
- gaugeLabelTextMargin: 15
-};
-
-let assign;
-if (Object.assign) {
- assign = Object.assign;
-} else {
- // 使用polyfill
- assign = function(target, varArgs) {
- if (target == null) {
- throw new TypeError('Cannot convert undefined or null to object');
- }
- var to = Object(target);
- for (var index = 1; index < arguments.length; index++) {
- var nextSource = arguments[index];
- if (nextSource != null) {
- for (var nextKey in nextSource) {
- if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
- to[nextKey] = nextSource[nextKey];
- }
- }
- }
- }
- return to;
- }
-}
-
-var util = {
- toFixed: function toFixed(num, limit) {
- limit = limit || 2;
- if (this.isFloat(num)) {
- num = num.toFixed(limit);
- }
- return num;
- },
- isFloat: function isFloat(num) {
- return num % 1 !== 0;
- },
- approximatelyEqual: function approximatelyEqual(num1, num2) {
- return Math.abs(num1 - num2) < 1e-10;
- },
- isSameSign: function isSameSign(num1, num2) {
- return Math.abs(num1) === num1 && Math.abs(num2) === num2 || Math.abs(num1) !== num1 && Math.abs(num2) !== num2;
- },
- isSameXCoordinateArea: function isSameXCoordinateArea(p1, p2) {
- return this.isSameSign(p1.x, p2.x);
- },
- isCollision: function isCollision(obj1, obj2) {
- obj1.end = {};
- obj1.end.x = obj1.start.x + obj1.width;
- obj1.end.y = obj1.start.y - obj1.height;
- obj2.end = {};
- obj2.end.x = obj2.start.x + obj2.width;
- obj2.end.y = obj2.start.y - obj2.height;
- var flag = obj2.start.x > obj1.end.x || obj2.end.x < obj1.start.x || obj2.end.y > obj1.start.y || obj2.start.y < obj1.end.y;
- return !flag;
- }
-};
-
-//兼容H5点击事件
-function getH5Offset(e) {
- e.mp = {
- changedTouches: []
- };
- e.mp.changedTouches.push({
- x: e.offsetX,
- y: e.offsetY
- });
- return e;
-}
-
-// hex 转 rgba
-function hexToRgb(hexValue, opc) {
- var rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
- var hex = hexValue.replace(rgx, function(m, r, g, b) {
- return r + r + g + g + b + b;
- });
- var rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
- var r = parseInt(rgb[1], 16);
- var g = parseInt(rgb[2], 16);
- var b = parseInt(rgb[3], 16);
- return 'rgba(' + r + ',' + g + ',' + b + ',' + opc + ')';
-}
-
-function findRange(num, type, limit) {
- if (isNaN(num)) {
- throw new Error('[uCharts] unvalid series data!');
- }
- limit = limit || 10;
- type = type ? type : 'upper';
- var multiple = 1;
- while (limit < 1) {
- limit *= 10;
- multiple *= 10;
- }
- if (type === 'upper') {
- num = Math.ceil(num * multiple);
- } else {
- num = Math.floor(num * multiple);
- }
- while (num % limit !== 0) {
- if (type === 'upper') {
- num++;
- } else {
- num--;
- }
- }
- return num / multiple;
-}
-
-function calCandleMA(dayArr, nameArr, colorArr, kdata) {
- let seriesTemp = [];
- for (let k = 0; k < dayArr.length; k++) {
- let seriesItem = {
- data: [],
- name: nameArr[k],
- color: colorArr[k]
- };
- for (let i = 0, len = kdata.length; i < len; i++) {
- if (i < dayArr[k]) {
- seriesItem.data.push(null);
- continue;
- }
- let sum = 0;
- for (let j = 0; j < dayArr[k]; j++) {
- sum += kdata[i - j][1];
- }
- seriesItem.data.push(+(sum / dayArr[k]).toFixed(3));
- }
- seriesTemp.push(seriesItem);
- }
- return seriesTemp;
-}
-
-function calValidDistance(distance, chartData, config, opts) {
- var dataChartAreaWidth = opts.width - opts.area[1] - opts.area[3];
- var dataChartWidth = chartData.eachSpacing * (opts.chartData.xAxisData.xAxisPoints.length-1);
- var validDistance = distance;
- if (distance >= 0) {
- validDistance = 0;
- } else if (Math.abs(distance) >= dataChartWidth - dataChartAreaWidth) {
- validDistance = dataChartAreaWidth - dataChartWidth;
- }
- return validDistance;
-}
-
-function isInAngleRange(angle, startAngle, endAngle) {
- function adjust(angle) {
- while (angle < 0) {
- angle += 2 * Math.PI;
- }
- while (angle > 2 * Math.PI) {
- angle -= 2 * Math.PI;
- }
- return angle;
- }
- angle = adjust(angle);
- startAngle = adjust(startAngle);
- endAngle = adjust(endAngle);
- if (startAngle > endAngle) {
- endAngle += 2 * Math.PI;
- if (angle < startAngle) {
- angle += 2 * Math.PI;
- }
- }
- return angle >= startAngle && angle <= endAngle;
-}
-
-function calRotateTranslate(x, y, h) {
- var xv = x;
- var yv = h - y;
- var transX = xv + (h - yv - xv) / Math.sqrt(2);
- transX *= -1;
- var transY = (h - yv) * (Math.sqrt(2) - 1) - (h - yv - xv) / Math.sqrt(2);
- return {
- transX: transX,
- transY: transY
- };
-}
-
-function createCurveControlPoints(points, i) {
-
- function isNotMiddlePoint(points, i) {
- if (points[i - 1] && points[i + 1]) {
- return points[i].y >= Math.max(points[i - 1].y, points[i + 1].y) || points[i].y <= Math.min(points[i - 1].y,
- points[
- i + 1].y);
- } else {
- return false;
- }
- }
- var a = 0.2;
- var b = 0.2;
- var pAx = null;
- var pAy = null;
- var pBx = null;
- var pBy = null;
- if (i < 1) {
- pAx = points[0].x + (points[1].x - points[0].x) * a;
- pAy = points[0].y + (points[1].y - points[0].y) * a;
- } else {
- pAx = points[i].x + (points[i + 1].x - points[i - 1].x) * a;
- pAy = points[i].y + (points[i + 1].y - points[i - 1].y) * a;
- }
-
- if (i > points.length - 3) {
- var last = points.length - 1;
- pBx = points[last].x - (points[last].x - points[last - 1].x) * b;
- pBy = points[last].y - (points[last].y - points[last - 1].y) * b;
- } else {
- pBx = points[i + 1].x - (points[i + 2].x - points[i].x) * b;
- pBy = points[i + 1].y - (points[i + 2].y - points[i].y) * b;
- }
- if (isNotMiddlePoint(points, i + 1)) {
- pBy = points[i + 1].y;
- }
- if (isNotMiddlePoint(points, i)) {
- pAy = points[i].y;
- }
- return {
- ctrA: {
- x: pAx,
- y: pAy
- },
- ctrB: {
- x: pBx,
- y: pBy
- }
- };
-}
-
-function convertCoordinateOrigin(x, y, center) {
- return {
- x: center.x + x,
- y: center.y - y
- };
-}
-
-function avoidCollision(obj, target) {
- if (target) {
- // is collision test
- while (util.isCollision(obj, target)) {
- if (obj.start.x > 0) {
- obj.start.y--;
- } else if (obj.start.x < 0) {
- obj.start.y++;
- } else {
- if (obj.start.y > 0) {
- obj.start.y++;
- } else {
- obj.start.y--;
- }
- }
- }
- }
- return obj;
-}
-
-function fillSeries(series, opts, config) {
- var index = 0;
- return series.map(function(item) {
- if (!item.color) {
- item.color = config.colors[index];
- index = (index + 1) % config.colors.length;
- }
- if (!item.type) {
- item.type = opts.type;
- }
- if (typeof item.show == "undefined") {
- item.show = true;
- }
- if (!item.type) {
- item.type = opts.type;
- }
- if (!item.pointShape) {
- item.pointShape = "circle";
- }
- if (!item.legendShape) {
- switch (item.type) {
- case 'line':
- item.legendShape = "line";
- break;
- case 'column':
- item.legendShape = "rect";
- break;
- case 'area':
- item.legendShape = "triangle";
- break;
- default:
- item.legendShape = "circle";
- }
- }
- return item;
- });
-}
-
-function getDataRange(minData, maxData) {
- var limit = 0;
- var range = maxData - minData;
- if (range >= 10000) {
- limit = 1000;
- } else if (range >= 1000) {
- limit = 100;
- } else if (range >= 100) {
- limit = 10;
- } else if (range >= 10) {
- limit = 5;
- } else if (range >= 1) {
- limit = 1;
- } else if (range >= 0.1) {
- limit = 0.1;
- } else if (range >= 0.01) {
- limit = 0.01;
- } else if (range >= 0.001) {
- limit = 0.001;
- } else if (range >= 0.0001) {
- limit = 0.0001;
- } else if (range >= 0.00001) {
- limit = 0.00001;
- } else {
- limit = 0.000001;
- }
- return {
- minRange: findRange(minData, 'lower', limit),
- maxRange: findRange(maxData, 'upper', limit)
- };
-}
-
-function measureText(text) {
- var fontSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : config.fontSize;
- text = String(text);
- var text = text.split('');
- var width = 0;
- for (let i = 0; i < text.length; i++) {
- let item = text[i];
- if (/[a-zA-Z]/.test(item)) {
- width += 7;
- } else if (/[0-9]/.test(item)) {
- width += 5.5;
- } else if (/\./.test(item)) {
- width += 2.7;
- } else if (/-/.test(item)) {
- width += 3.25;
- } else if (/[\u4e00-\u9fa5]/.test(item)) {
- width += 10;
- } else if (/\(|\)/.test(item)) {
- width += 3.73;
- } else if (/\s/.test(item)) {
- width += 2.5;
- } else if (/%/.test(item)) {
- width += 8;
- } else {
- width += 10;
- }
- }
- return width * fontSize / 10;
-}
-
-function dataCombine(series) {
- return series.reduce(function(a, b) {
- return (a.data ? a.data : a).concat(b.data);
- }, []);
-}
-
-function dataCombineStack(series, len) {
- var sum = new Array(len);
- for (var j = 0; j < sum.length; j++) {
- sum[j] = 0;
- }
- for (var i = 0; i < series.length; i++) {
- for (var j = 0; j < sum.length; j++) {
- sum[j] += series[i].data[j];
- }
- }
- return series.reduce(function(a, b) {
- return (a.data ? a.data : a).concat(b.data).concat(sum);
- }, []);
-}
-
-function getTouches(touches, opts, e) {
- let x, y;
- if (touches.clientX) {
- if (opts.rotate) {
- y = opts.height - touches.clientX * opts.pixelRatio;
- x = (touches.pageY - e.currentTarget.offsetTop - (opts.height / opts.pixelRatio / 2) * (opts.pixelRatio - 1)) *
- opts.pixelRatio;
- } else {
- x = touches.clientX * opts.pixelRatio;
- y = (touches.pageY - e.currentTarget.offsetTop - (opts.height / opts.pixelRatio / 2) * (opts.pixelRatio - 1)) *
- opts.pixelRatio;
- }
- } else {
- if (opts.rotate) {
- y = opts.height - touches.x * opts.pixelRatio;
- x = touches.y * opts.pixelRatio;
- } else {
- x = touches.x * opts.pixelRatio;
- y = touches.y * opts.pixelRatio;
- }
- }
- return {
- x: x,
- y: y
- }
-}
-
-function getSeriesDataItem(series, index) {
- var data = [];
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- if (item.data[index] !== null && typeof item.data[index] !== 'undefined' && item.show) {
- let seriesItem = {};
- seriesItem.color = item.color;
- seriesItem.type = item.type;
- seriesItem.style = item.style;
- seriesItem.pointShape = item.pointShape;
- seriesItem.disableLegend = item.disableLegend;
- seriesItem.name = item.name;
- seriesItem.show = item.show;
- seriesItem.data = item.format ? item.format(item.data[index]) : item.data[index];
- data.push(seriesItem);
- }
- }
- return data;
-}
-
-function getMaxTextListLength(list) {
- var lengthList = list.map(function(item) {
- return measureText(item);
- });
- return Math.max.apply(null, lengthList);
-}
-
-function getRadarCoordinateSeries(length) {
- var eachAngle = 2 * Math.PI / length;
- var CoordinateSeries = [];
- for (var i = 0; i < length; i++) {
- CoordinateSeries.push(eachAngle * i);
- }
-
- return CoordinateSeries.map(function(item) {
- return -1 * item + Math.PI / 2;
- });
-}
-
-function getToolTipData(seriesData, calPoints, index, categories) {
- var option = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
-
- var textList = seriesData.map(function(item) {
- return {
- text: option.format ? option.format(item, categories[index]) : item.name + ': ' + item.data,
- color: item.color
- };
- });
- var validCalPoints = [];
- var offset = {
- x: 0,
- y: 0
- };
- for (let i = 0; i < calPoints.length; i++) {
- let points = calPoints[i];
- if (typeof points[index] !== 'undefined' && points[index] !== null) {
- validCalPoints.push(points[index]);
- }
- }
- for (let i = 0; i < validCalPoints.length; i++) {
- let item = validCalPoints[i];
- offset.x = Math.round(item.x);
- offset.y += item.y;
- }
- offset.y /= validCalPoints.length;
- return {
- textList: textList,
- offset: offset
- };
-}
-
-function getMixToolTipData(seriesData, calPoints, index, categories) {
- var option = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
- var textList = seriesData.map(function(item) {
- return {
- text: option.format ? option.format(item, categories[index]) : item.name + ': ' + item.data,
- color: item.color,
- disableLegend: item.disableLegend ? true : false
- };
- });
- textList = textList.filter(function(item) {
- if (item.disableLegend !== true) {
- return item;
- }
- });
- var validCalPoints = [];
- var offset = {
- x: 0,
- y: 0
- };
- for (let i = 0; i < calPoints.length; i++) {
- let points = calPoints[i];
- if (typeof points[index] !== 'undefined' && points[index] !== null) {
- validCalPoints.push(points[index]);
- }
- }
- for (let i = 0; i < validCalPoints.length; i++) {
- let item = validCalPoints[i];
- offset.x = Math.round(item.x);
- offset.y += item.y;
- }
- offset.y /= validCalPoints.length;
- return {
- textList: textList,
- offset: offset
- };
-}
-
-function getCandleToolTipData(series, seriesData, calPoints, index, categories, extra) {
- var option = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : {};
- let upColor = extra.color.upFill;
- let downColor = extra.color.downFill;
- //颜色顺序为开盘,收盘,最低,最高
- let color = [upColor, upColor, downColor, upColor];
- var textList = [];
- let text0 = {
- text: categories[index],
- color: null
- };
- textList.push(text0);
- seriesData.map(function(item) {
- if (index == 0 && item.data[1] - item.data[0] < 0) {
- color[1] = downColor;
- } else {
- if (item.data[0] < series[index - 1][1]) {
- color[0] = downColor;
- }
- if (item.data[1] < item.data[0]) {
- color[1] = downColor;
- }
- if (item.data[2] > series[index - 1][1]) {
- color[2] = upColor;
- }
- if (item.data[3] < series[index - 1][1]) {
- color[3] = downColor;
- }
- }
- let text1 = {
- text: '开盘:' + item.data[0],
- color: color[0]
- };
- let text2 = {
- text: '收盘:' + item.data[1],
- color: color[1]
- };
- let text3 = {
- text: '最低:' + item.data[2],
- color: color[2]
- };
- let text4 = {
- text: '最高:' + item.data[3],
- color: color[3]
- };
- textList.push(text1, text2, text3, text4);
- });
- var validCalPoints = [];
- var offset = {
- x: 0,
- y: 0
- };
- for (let i = 0; i < calPoints.length; i++) {
- let points = calPoints[i];
- if (typeof points[index] !== 'undefined' && points[index] !== null) {
- validCalPoints.push(points[index]);
- }
- }
- offset.x = Math.round(validCalPoints[0][0].x);
- return {
- textList: textList,
- offset: offset
- };
-}
-
-function filterSeries(series) {
- let tempSeries = [];
- for (let i = 0; i < series.length; i++) {
- if (series[i].show == true) {
- tempSeries.push(series[i])
- }
- }
- return tempSeries;
-}
-
-function findCurrentIndex(currentPoints, xAxisPoints, opts, config) {
- var offset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
- var currentIndex = -1;
- var spacing = 0;
- if((opts.type=='line' || opts.type=='area') && opts.xAxis.boundaryGap=='justify'){
- spacing = opts.chartData.eachSpacing/2;
- }
- if (isInExactChartArea(currentPoints, opts, config)) {
- xAxisPoints.forEach(function(item, index) {
- if (currentPoints.x + offset + spacing > item) {
- currentIndex = index;
- }
- });
- }
- return currentIndex;
-}
-
-function findLegendIndex(currentPoints, legendData, opts) {
- let currentIndex = -1;
- if (isInExactLegendArea(currentPoints, legendData.area)) {
- let points = legendData.points;
- let index = -1;
- for (let i = 0, len = points.length; i < len; i++) {
- let item = points[i];
- for (let j = 0; j < item.length; j++) {
- index += 1;
- let area = item[j]['area'];
- if (currentPoints.x > area[0] && currentPoints.x < area[2] && currentPoints.y > area[1] && currentPoints.y < area[3]) {
- currentIndex = index;
- break;
- }
- }
- }
- return currentIndex;
- }
- return currentIndex;
-}
-
-function isInExactLegendArea(currentPoints, area) {
- return currentPoints.x > area.start.x && currentPoints.x < area.end.x && currentPoints.y > area.start.y &&
- currentPoints.y < area.end.y;
-}
-
-function isInExactChartArea(currentPoints, opts, config) {
- return currentPoints.x < opts.width - opts.area[1] + 10 && currentPoints.x > opts.area[3] -10 && currentPoints.y > opts.area[0] && currentPoints.y < opts.height - opts.area[2];
-}
-
-function findRadarChartCurrentIndex(currentPoints, radarData, count) {
- var eachAngleArea = 2 * Math.PI / count;
- var currentIndex = -1;
- if (isInExactPieChartArea(currentPoints, radarData.center, radarData.radius)) {
- var fixAngle = function fixAngle(angle) {
- if (angle < 0) {
- angle += 2 * Math.PI;
- }
- if (angle > 2 * Math.PI) {
- angle -= 2 * Math.PI;
- }
- return angle;
- };
-
- var angle = Math.atan2(radarData.center.y - currentPoints.y, currentPoints.x - radarData.center.x);
- angle = -1 * angle;
- if (angle < 0) {
- angle += 2 * Math.PI;
- }
-
- var angleList = radarData.angleList.map(function(item) {
- item = fixAngle(-1 * item);
-
- return item;
- });
-
- angleList.forEach(function(item, index) {
- var rangeStart = fixAngle(item - eachAngleArea / 2);
- var rangeEnd = fixAngle(item + eachAngleArea / 2);
- if (rangeEnd < rangeStart) {
- rangeEnd += 2 * Math.PI;
- }
- if (angle >= rangeStart && angle <= rangeEnd || angle + 2 * Math.PI >= rangeStart && angle + 2 * Math.PI <=
- rangeEnd) {
- currentIndex = index;
- }
- });
- }
-
- return currentIndex;
-}
-
-function findFunnelChartCurrentIndex(currentPoints, funnelData) {
- var currentIndex = -1;
- for (var i = 0, len = funnelData.series.length; i < len; i++) {
- var item = funnelData.series[i];
- if (currentPoints.x > item.funnelArea[0] && currentPoints.x < item.funnelArea[2] && currentPoints.y > item.funnelArea[1] && currentPoints.y < item.funnelArea[3]) {
- currentIndex = i;
- break;
- }
- }
- return currentIndex;
-}
-
-function findWordChartCurrentIndex(currentPoints, wordData) {
- var currentIndex = -1;
- for (var i = 0, len = wordData.length; i < len; i++) {
- var item = wordData[i];
- if (currentPoints.x > item.area[0] && currentPoints.x < item.area[2] && currentPoints.y > item.area[1] && currentPoints.y < item.area[3]) {
- currentIndex = i;
- break;
- }
- }
- return currentIndex;
-}
-
-function findMapChartCurrentIndex(currentPoints, opts) {
- var currentIndex = -1;
- var cData=opts.chartData.mapData;
- var data=opts.series;
- var tmp=pointToCoordinate(currentPoints.y, currentPoints.x,cData.bounds,cData.scale,cData.xoffset,cData.yoffset);
- var poi=[tmp.x, tmp.y];
- for (var i = 0, len = data.length; i < len; i++) {
- var item = data[i].geometry.coordinates;
- if(isPoiWithinPoly(poi,item)){
- currentIndex = i;
- break;
- }
- }
- return currentIndex;
-}
-
-function findPieChartCurrentIndex(currentPoints, pieData) {
- var currentIndex = -1;
- if (isInExactPieChartArea(currentPoints, pieData.center, pieData.radius)) {
- var angle = Math.atan2(pieData.center.y - currentPoints.y, currentPoints.x - pieData.center.x);
- angle = -angle;
- for (var i = 0, len = pieData.series.length; i < len; i++) {
- var item = pieData.series[i];
- if (isInAngleRange(angle, item._start_, item._start_ + item._proportion_ * 2 * Math.PI)) {
- currentIndex = i;
- break;
- }
- }
- }
-
- return currentIndex;
-}
-
-function isInExactPieChartArea(currentPoints, center, radius) {
- return Math.pow(currentPoints.x - center.x, 2) + Math.pow(currentPoints.y - center.y, 2) <= Math.pow(radius, 2);
-}
-
-function splitPoints(points) {
- var newPoints = [];
- var items = [];
- points.forEach(function(item, index) {
- if (item !== null) {
- items.push(item);
- } else {
- if (items.length) {
- newPoints.push(items);
- }
- items = [];
- }
- });
- if (items.length) {
- newPoints.push(items);
- }
-
- return newPoints;
-}
-
-function calLegendData(series, opts, config, chartData) {
- let legendData = {
- area: {
- start: {
- x: 0,
- y: 0
- },
- end: {
- x: 0,
- y: 0
- },
- width: 0,
- height: 0,
- wholeWidth: 0,
- wholeHeight: 0
- },
- points: [],
- widthArr: [],
- heightArr: []
- };
- if (opts.legend.show === false) {
- chartData.legendData = legendData;
- return legendData;
- }
-
- let padding = opts.legend.padding;
- let margin = opts.legend.margin;
- let fontSize = opts.legend.fontSize;
- let shapeWidth = 15 * opts.pixelRatio;
- let shapeRight = 5 * opts.pixelRatio;
- let lineHeight = Math.max(opts.legend.lineHeight * opts.pixelRatio, fontSize);
- if (opts.legend.position == 'top' || opts.legend.position == 'bottom') {
- let legendList = [];
- let widthCount = 0;
- let widthCountArr = [];
- let currentRow = [];
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- let itemWidth = shapeWidth + shapeRight + measureText(item.name || 'undefined', fontSize) + opts.legend.itemGap;
- if (widthCount + itemWidth > opts.width - opts.padding[1] - opts.padding[3]) {
- legendList.push(currentRow);
- widthCountArr.push(widthCount - opts.legend.itemGap);
- widthCount = itemWidth;
- currentRow = [item];
- } else {
- widthCount += itemWidth;
- currentRow.push(item);
- }
- }
- if (currentRow.length) {
- legendList.push(currentRow);
- widthCountArr.push(widthCount - opts.legend.itemGap);
- legendData.widthArr = widthCountArr;
- let legendWidth = Math.max.apply(null, widthCountArr);
- switch (opts.legend.float) {
- case 'left':
- legendData.area.start.x = opts.padding[3];
- legendData.area.end.x = opts.padding[3] + 2 * padding;
- break;
- case 'right':
- legendData.area.start.x = opts.width - opts.padding[1] - legendWidth - 2 * padding;
- legendData.area.end.x = opts.width - opts.padding[1];
- break;
- default:
- legendData.area.start.x = (opts.width - legendWidth) / 2 - padding;
- legendData.area.end.x = (opts.width + legendWidth) / 2 + padding;
- }
- legendData.area.width = legendWidth + 2 * padding;
- legendData.area.wholeWidth = legendWidth + 2 * padding;
- legendData.area.height = legendList.length * lineHeight + 2 * padding;
- legendData.area.wholeHeight = legendList.length * lineHeight + 2 * padding + 2 * margin;
- legendData.points = legendList;
- }
- } else {
- let len = series.length;
- let maxHeight = opts.height - opts.padding[0] - opts.padding[2] - 2 * margin - 2 * padding;
- let maxLength = Math.min(Math.floor(maxHeight / lineHeight), len);
- legendData.area.height = maxLength * lineHeight + padding * 2;
- legendData.area.wholeHeight = maxLength * lineHeight + padding * 2;
- switch (opts.legend.float) {
- case 'top':
- legendData.area.start.y = opts.padding[0] + margin;
- legendData.area.end.y = opts.padding[0] + margin + legendData.area.height;
- break;
- case 'bottom':
- legendData.area.start.y = opts.height - opts.padding[2] - margin - legendData.area.height;
- legendData.area.end.y = opts.height - opts.padding[2] - margin;
- break;
- default:
- legendData.area.start.y = (opts.height - legendData.area.height) / 2;
- legendData.area.end.y = (opts.height + legendData.area.height) / 2;
- }
- let lineNum = len % maxLength === 0 ? len / maxLength : Math.floor((len / maxLength) + 1);
- let currentRow = [];
- for (let i = 0; i < lineNum; i++) {
- let temp = series.slice(i * maxLength, i * maxLength + maxLength);
- currentRow.push(temp);
- }
-
- legendData.points = currentRow;
-
- if (currentRow.length) {
- for (let i = 0; i < currentRow.length; i++) {
- let item = currentRow[i];
- let maxWidth = 0;
- for (let j = 0; j < item.length; j++) {
- let itemWidth = shapeWidth + shapeRight + measureText(item[j].name || 'undefined', fontSize) + opts.legend.itemGap;
- if (itemWidth > maxWidth) {
- maxWidth = itemWidth;
- }
- }
- legendData.widthArr.push(maxWidth);
- legendData.heightArr.push(item.length * lineHeight + padding * 2);
- }
- let legendWidth = 0
- for (let i = 0; i < legendData.widthArr.length; i++) {
- legendWidth += legendData.widthArr[i];
- }
- legendData.area.width = legendWidth - opts.legend.itemGap + 2 * padding;
- legendData.area.wholeWidth = legendData.area.width + padding;
- }
- }
-
- switch (opts.legend.position) {
- case 'top':
- legendData.area.start.y = opts.padding[0] + margin;
- legendData.area.end.y = opts.padding[0] + margin + legendData.area.height;
- break;
- case 'bottom':
- legendData.area.start.y = opts.height - opts.padding[2] - legendData.area.height - margin;
- legendData.area.end.y = opts.height - opts.padding[2] - margin;
- break;
- case 'left':
- legendData.area.start.x = opts.padding[3];
- legendData.area.end.x = opts.padding[3] + legendData.area.width;
- break;
- case 'right':
- legendData.area.start.x = opts.width - opts.padding[1] - legendData.area.width;
- legendData.area.end.x = opts.width - opts.padding[1];
- break;
- }
- chartData.legendData = legendData;
- return legendData;
-}
-
-function calCategoriesData(categories, opts, config, eachSpacing) {
- var result = {
- angle: 0,
- xAxisHeight: config.xAxisHeight
- };
- var categoriesTextLenth = categories.map(function(item) {
- return measureText(item);
- });
- var maxTextLength = Math.max.apply(this, categoriesTextLenth);
-
- if (opts.xAxis.rotateLabel == true && maxTextLength + 2 * config.xAxisTextPadding > eachSpacing) {
- result.angle = 45 * Math.PI / 180;
- result.xAxisHeight = 2 * config.xAxisTextPadding + maxTextLength * Math.sin(result.angle);
- }
- return result;
-}
-
-function getRadarDataPoints(angleList, center, radius, series, opts) {
- var process = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1;
-
- var radarOption = opts.extra.radar || {};
- radarOption.max = radarOption.max || 0;
- var maxData = Math.max(radarOption.max, Math.max.apply(null, dataCombine(series)));
-
- var data = [];
- for (let i = 0; i < series.length; i++) {
- let each = series[i];
- let listItem = {};
- listItem.color = each.color;
- listItem.data = [];
- each.data.forEach(function(item, index) {
- let tmp = {};
- tmp.angle = angleList[index];
-
- tmp.proportion = item / maxData;
- tmp.position = convertCoordinateOrigin(radius * tmp.proportion * process * Math.cos(tmp.angle), radius * tmp.proportion *
- process * Math.sin(tmp.angle), center);
- listItem.data.push(tmp);
- });
-
- data.push(listItem);
- }
-
- return data;
-}
-
-function getPieDataPoints(series, radius) {
- var process = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
-
- var count = 0;
- var _start_ = 0;
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- item.data = item.data === null ? 0 : item.data;
- count += item.data;
- }
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- item.data = item.data === null ? 0 : item.data;
- if (count === 0) {
- item._proportion_ = 1 / series.length * process;
- } else {
- item._proportion_ = item.data / count * process;
- }
- item._radius_ = radius;
- }
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- item._start_ = _start_;
- _start_ += 2 * item._proportion_ * Math.PI;
- }
-
- return series;
-}
-
-function getFunnelDataPoints(series, radius) {
- var process = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
- series = series.sort(function(a,b){return parseInt(b.data)-parseInt(a.data);});
- for (let i = 0; i < series.length; i++) {
- series[i].radius = series[i].data/series[0].data*radius*process;
- series[i]._proportion_ = series[i].data/series[0].data;
- }
- return series.reverse();
-}
-
-function getRoseDataPoints(series, type, minRadius, radius) {
- var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
- var count = 0;
- var _start_ = 0;
-
- var dataArr = [];
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- item.data = item.data === null ? 0 : item.data;
- count += item.data;
- dataArr.push(item.data);
- }
-
- var minData = Math.min.apply(null, dataArr);
- var maxData = Math.max.apply(null, dataArr);
- var radiusLength = radius - minRadius;
-
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- item.data = item.data === null ? 0 : item.data;
- if (count === 0 || type == 'area') {
- item._proportion_ = item.data / count * process;
- item._rose_proportion_ = 1 / series.length * process;
- } else {
- item._proportion_ = item.data / count * process;
- item._rose_proportion_ = item.data / count * process;
- }
- item._radius_ = minRadius + radiusLength * ((item.data - minData) / (maxData - minData));
- }
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- item._start_ = _start_;
- _start_ += 2 * item._rose_proportion_ * Math.PI;
- }
-
- return series;
-}
-
-function getArcbarDataPoints(series, arcbarOption) {
- var process = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
- if (process == 1) {
- process = 0.999999;
- }
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- item.data = item.data === null ? 0 : item.data;
- let totalAngle;
- if (arcbarOption.type == 'default') {
- if (arcbarOption.endAngle < arcbarOption.startAngle) {
- totalAngle = 2 + arcbarOption.endAngle - arcbarOption.startAngle;
- } else{
- totalAngle = arcbarOption.startAngle - arcbarOption.endAngle;
- }
- } else {
- totalAngle = 2;
- }
- item._proportion_ = totalAngle * item.data * process + arcbarOption.startAngle;
- if (item._proportion_ >= 2) {
- item._proportion_ = item._proportion_ % 2;
- }
- }
- return series;
-}
-
-function getGaugeAxisPoints(categories, startAngle, endAngle) {
- let totalAngle = startAngle - endAngle + 1;
- let tempStartAngle = startAngle;
- for (let i = 0; i < categories.length; i++) {
- categories[i].value = categories[i].value === null ? 0 : categories[i].value;
- categories[i]._startAngle_ = tempStartAngle;
- categories[i]._endAngle_ = totalAngle * categories[i].value + startAngle;
- if (categories[i]._endAngle_ >= 2) {
- categories[i]._endAngle_ = categories[i]._endAngle_ % 2;
- }
- tempStartAngle = categories[i]._endAngle_;
- }
- return categories;
-}
-
-function getGaugeDataPoints(series, categories, gaugeOption) {
- let process = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- item.data = item.data === null ? 0 : item.data;
- if (gaugeOption.pointer.color == 'auto') {
- for (let i = 0; i < categories.length; i++) {
- if (item.data <= categories[i].value) {
- item.color = categories[i].color;
- break;
- }
- }
- } else {
- item.color = gaugeOption.pointer.color;
- }
- let totalAngle = gaugeOption.startAngle - gaugeOption.endAngle + 1;
- item._endAngle_ = totalAngle * item.data + gaugeOption.startAngle;
- item._oldAngle_ = gaugeOption.oldAngle;
- if (gaugeOption.oldAngle < gaugeOption.endAngle) {
- item._oldAngle_ += 2;
- }
- if (item.data >= gaugeOption.oldData) {
- item._proportion_ = (item._endAngle_ - item._oldAngle_) * process + gaugeOption.oldAngle;
- } else {
- item._proportion_ = item._oldAngle_ - (item._oldAngle_ - item._endAngle_) * process;
- }
- if (item._proportion_ >= 2) {
- item._proportion_ = item._proportion_ % 2;
- }
- }
- return series;
-}
-
-function getPieTextMaxLength(series) {
- series = getPieDataPoints(series);
- let maxLength = 0;
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- let text = item.format ? item.format(+item._proportion_.toFixed(2)) : util.toFixed(item._proportion_ * 100) + '%';
- maxLength = Math.max(maxLength, measureText(text));
- }
-
- return maxLength;
-}
-
-function fixColumeData(points, eachSpacing, columnLen, index, config, opts) {
- return points.map(function(item) {
- if (item === null) {
- return null;
- }
- item.width = Math.ceil((eachSpacing - 2 * config.columePadding) / columnLen);
-
- if (opts.extra.column && opts.extra.column.width && +opts.extra.column.width > 0) {
- item.width = Math.min(item.width, +opts.extra.column.width);
- }
- if (item.width <= 0) {
- item.width = 1;
- }
- item.x += (index + 0.5 - columnLen / 2) * item.width;
- return item;
- });
-}
-
-function fixColumeMeterData(points, eachSpacing, columnLen, index, config, opts, border) {
- return points.map(function(item) {
- if (item === null) {
- return null;
- }
- item.width = Math.ceil((eachSpacing - 2 * config.columePadding) / 2);
-
- if (opts.extra.column && opts.extra.column.width && +opts.extra.column.width > 0) {
- item.width = Math.min(item.width, +opts.extra.column.width);
- }
-
- if (index > 0) {
- item.width -= 2 * border;
- }
- return item;
- });
-}
-
-function fixColumeStackData(points, eachSpacing, columnLen, index, config, opts, series) {
-
- return points.map(function(item, indexn) {
-
- if (item === null) {
- return null;
- }
- item.width = Math.ceil((eachSpacing - 2 * config.columePadding) / 2);
-
- if (opts.extra.column && opts.extra.column.width && +opts.extra.column.width > 0) {
- item.width = Math.min(item.width, +opts.extra.column.width);
- }
- return item;
- });
-}
-
-function getXAxisPoints(categories, opts, config) {
- var yAxisTotalWidth = config.yAxisWidth + config.yAxisTitleWidth;
- var spacingValid = opts.width - opts.area[1] - opts.area[3];
- var dataCount = opts.enableScroll ? Math.min(opts.xAxis.itemCount, categories.length) : categories.length;
- if((opts.type=='line' || opts.type=='area') && dataCount>1 && opts.xAxis.boundaryGap=='justify'){
- dataCount -=1;
- }
- var eachSpacing = spacingValid / dataCount;
-
- var xAxisPoints = [];
- var startX = opts.area[3];
- var endX = opts.width - opts.area[1];
- categories.forEach(function(item, index) {
- xAxisPoints.push(startX + index * eachSpacing);
- });
- if(opts.xAxis.boundaryGap !=='justify'){
- if (opts.enableScroll === true) {
- xAxisPoints.push(startX + categories.length * eachSpacing);
- } else {
- xAxisPoints.push(endX);
- }
- }
- return {
- xAxisPoints: xAxisPoints,
- startX: startX,
- endX: endX,
- eachSpacing: eachSpacing
- };
-}
-
-function getCandleDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config) {
- var process = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 1;
- var points = [];
- var validHeight = opts.height - opts.area[0] - opts.area[2];
- data.forEach(function(item, index) {
- if (item === null) {
- points.push(null);
- } else {
- var cPoints = [];
- item.forEach(function(items, indexs) {
- var point = {};
- point.x = xAxisPoints[index] + Math.round(eachSpacing / 2);
- var value = items.value || items;
- var height = validHeight * (value - minRange) / (maxRange - minRange);
- height *= process;
- point.y = opts.height - Math.round(height) - opts.area[2];
- cPoints.push(point);
- });
- points.push(cPoints);
- }
- });
-
- return points;
-}
-
-function getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config) {
- var process = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 1;
- var boundaryGap='center';
- if (opts.type == 'line'||opts.type == 'area'){
- boundaryGap=opts.xAxis.boundaryGap;
- }
- var points = [];
- var validHeight = opts.height - opts.area[0] - opts.area[2];
- data.forEach(function(item, index) {
- if (item === null) {
- points.push(null);
- } else {
- var point = {};
- point.color = item.color;
- point.x = xAxisPoints[index];
- if(boundaryGap=='center'){
- point.x += Math.round(eachSpacing / 2);
- }
- var value = item;
- if (typeof item === 'object' && item !== null) {
- value = item.value
- }
- var height = validHeight * (value - minRange) / (maxRange - minRange);
- height *= process;
- point.y = opts.height - Math.round(height) - opts.area[2];
- points.push(point);
- }
- });
-
- return points;
-}
-
-function getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, seriesIndex, stackSeries) {
- var process = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : 1;
- var points = [];
- var validHeight = opts.height - opts.area[0] - opts.area[2];
-
- data.forEach(function(item, index) {
- if (item === null) {
- points.push(null);
- } else {
- var point = {};
- point.color = item.color;
- point.x = xAxisPoints[index] + Math.round(eachSpacing / 2);
-
- if (seriesIndex > 0) {
- var value = 0;
- for (let i = 0; i <= seriesIndex; i++) {
- value += stackSeries[i].data[index];
- }
- var value0 = value - item;
- var height = validHeight * (value - minRange) / (maxRange - minRange);
- var height0 = validHeight * (value0 - minRange) / (maxRange - minRange);
- } else {
- var value = item;
- var height = validHeight * (value - minRange) / (maxRange - minRange);
- var height0 = 0;
- }
- var heightc = height0;
- height *= process;
- heightc *= process;
- point.y = opts.height - Math.round(height) - opts.area[2];
- point.y0 = opts.height - Math.round(heightc) - opts.area[2];
- points.push(point);
- }
- });
-
- return points;
-}
-
-function getYAxisTextList(series, opts, config, stack) {
- var data;
- if (stack == 'stack') {
- data = dataCombineStack(series, opts.categories.length);
- } else {
- data = dataCombine(series);
- }
- var sorted = [];
- // remove null from data
- data = data.filter(function(item) {
- //return item !== null;
- if (typeof item === 'object' && item !== null) {
- if (Array.isArray(item)) {
- return item !== null;
- } else {
- return item.value !== null;
- }
- } else {
- return item !== null;
- }
- });
- data.map(function(item) {
- if (typeof item === 'object') {
- if (Array.isArray(item)) {
- item.map(function(subitem) {
- sorted.push(subitem);
- })
- } else {
- sorted.push(item.value);
- }
- } else {
- sorted.push(item);
- }
- })
- var minData = 0;
- var maxData = 0;
- if (sorted.length > 0) {
- minData = Math.min.apply(this, sorted);
- maxData = Math.max.apply(this, sorted);
- }
- if (typeof opts.yAxis.min === 'number') {
- minData = Math.min(opts.yAxis.min, minData);
- }
- if (typeof opts.yAxis.max === 'number') {
- maxData = Math.max(opts.yAxis.max, maxData);
- }
-
- if (minData === maxData) {
- var rangeSpan = maxData || 10;
- maxData += rangeSpan;
- }
-
- var dataRange = getDataRange(minData, maxData);
- var minRange = dataRange.minRange;
- var maxRange = dataRange.maxRange;
-
- var range = [];
- var eachRange = (maxRange - minRange) / config.yAxisSplit;
-
- for (var i = 0; i <= config.yAxisSplit; i++) {
- range.push(minRange + eachRange * i);
- }
- return range.reverse();
-}
-
-function calYAxisData(series, opts, config) {
- //堆叠图重算Y轴
- var columnstyle = assign({}, {
- type: ""
- }, opts.extra.column);
- var ranges = getYAxisTextList(series, opts, config, columnstyle.type);
- var yAxisWidth = config.yAxisWidth;
- var yAxisFontSize = opts.yAxis.fontSize || config.fontSize;
- var rangesFormat = ranges.map(function(item) {
- item = util.toFixed(item, 6);
- item = opts.yAxis.format ? opts.yAxis.format(Number(item)) : item;
- yAxisWidth = Math.max(yAxisWidth, measureText(item, yAxisFontSize) + 5);
- return item;
- });
- if (opts.yAxis.disabled === true) {
- yAxisWidth = 0;
- }
-
- return {
- rangesFormat: rangesFormat,
- ranges: ranges,
- yAxisWidth: yAxisWidth
- };
-}
-
-function calTooltipYAxisData(point, series, opts, config, eachSpacing) {
- var ranges = getYAxisTextList(series, opts, config);
- var spacingValid = opts.height - opts.area[0] - opts.area[2];
- let maxVal = ranges[0];
- let minVal = ranges[ranges.length - 1];
- let minAxis = opts.padding[3];
- let maxAxis = opts.padding[1] + spacingValid;
- let item = maxVal - (maxVal - minVal) * (point - minAxis) / (maxAxis - minAxis);
- item = opts.yAxis.format ? opts.yAxis.format(Number(item)) : item;
- return item;
-}
-
-function calMarkLineData(minRange, maxRange, points, opts) {
- let spacingValid = opts.height - opts.area[0] - opts.area[2];
- for (let i = 0; i < points.length; i++) {
- let height = spacingValid * (points[i].value - minRange) / (maxRange - minRange);
- points[i].y = opts.height - Math.round(height) - opts.area[2];
- }
- return points;
-}
-
-function contextRotate(context, opts) {
- if (opts.rotateLock !== true) {
- context.translate(opts.height, 0);
- context.rotate(90 * Math.PI / 180);
- } else if (opts._rotate_ !== true) {
- context.translate(opts.height, 0);
- context.rotate(90 * Math.PI / 180);
- opts._rotate_ = true;
- }
-}
-
-function drawPointShape(points, color, shape, context, opts) {
- context.beginPath();
- context.setStrokeStyle("#ffffff");
- context.setLineWidth(1 * opts.pixelRatio);
- context.setFillStyle(color);
- if (shape === 'diamond') {
- points.forEach(function(item, index) {
- if (item !== null) {
- context.moveTo(item.x, item.y - 4.5);
- context.lineTo(item.x - 4.5, item.y);
- context.lineTo(item.x, item.y + 4.5);
- context.lineTo(item.x + 4.5, item.y);
- context.lineTo(item.x, item.y - 4.5);
- }
- });
- } else if (shape === 'circle') {
- points.forEach(function(item, index) {
- if (item !== null) {
- context.moveTo(item.x + 3.5 * opts.pixelRatio, item.y);
- context.arc(item.x, item.y, 4 * opts.pixelRatio, 0, 2 * Math.PI, false);
- }
- });
- } else if (shape === 'rect') {
- points.forEach(function(item, index) {
- if (item !== null) {
- context.moveTo(item.x - 3.5, item.y - 3.5);
- context.rect(item.x - 3.5, item.y - 3.5, 7, 7);
- }
- });
- } else if (shape === 'triangle') {
- points.forEach(function(item, index) {
- if (item !== null) {
- context.moveTo(item.x, item.y - 4.5);
- context.lineTo(item.x - 4.5, item.y + 4.5);
- context.lineTo(item.x + 4.5, item.y + 4.5);
- context.lineTo(item.x, item.y - 4.5);
- }
- });
- }
- context.closePath();
- context.fill();
- context.stroke();
-}
-
-function drawRingTitle(opts, config, context, center) {
- var titlefontSize = opts.title.fontSize || config.titleFontSize;
- var subtitlefontSize = opts.subtitle.fontSize || config.subtitleFontSize;
- var title = opts.title.name || '';
- var subtitle = opts.subtitle.name || '';
- var titleFontColor = opts.title.color || config.titleColor;
- var subtitleFontColor = opts.subtitle.color || config.subtitleColor;
- var titleHeight = title ? titlefontSize : 0;
- var subtitleHeight = subtitle ? subtitlefontSize : 0;
- var margin = 5;
-
- if (subtitle) {
- var textWidth = measureText(subtitle, subtitlefontSize);
- var startX = center.x - textWidth / 2 + (opts.subtitle.offsetX || 0);
- var startY = center.y + subtitlefontSize / 2 + (opts.subtitle.offsetY || 0);
- if (title) {
- startY += (titleHeight + margin) / 2;
- }
- context.beginPath();
- context.setFontSize(subtitlefontSize);
- context.setFillStyle(subtitleFontColor);
- context.fillText(subtitle, startX, startY);
- context.closePath();
- context.stroke();
- }
- if (title) {
- var _textWidth = measureText(title, titlefontSize);
- var _startX = center.x - _textWidth / 2 + (opts.title.offsetX || 0);
- var _startY = center.y + titlefontSize / 2 + (opts.title.offsetY || 0);
- if (subtitle) {
- _startY -= (subtitleHeight + margin) / 2;
- }
- context.beginPath();
- context.setFontSize(titlefontSize);
- context.setFillStyle(titleFontColor);
- context.fillText(title, _startX, _startY);
- context.closePath();
- context.stroke();
- }
-}
-
-function drawPointText(points, series, config, context) {
- // 绘制数据文案
- var data = series.data;
- points.forEach(function(item, index) {
- if (item !== null) {
- //var formatVal = series.format ? series.format(data[index]) : data[index];
- context.beginPath();
- context.setFontSize(series.textSize || config.fontSize);
- context.setFillStyle(series.textColor || '#666666');
- var value = data[index]
- if (typeof data[index] === 'object' && data[index] !== null) {
- value = data[index].value
- }
- var formatVal = series.format ? series.format(value) : value;
- context.fillText(String(formatVal), item.x - measureText(formatVal, series.textSize || config.fontSize) / 2, item.y -
- 2);
- context.closePath();
- context.stroke();
- }
- });
-
-}
-
-function drawGaugeLabel(gaugeOption, radius, centerPosition, opts, config, context) {
- radius -= gaugeOption.width / 2 + config.gaugeLabelTextMargin;
-
- let totalAngle = gaugeOption.startAngle - gaugeOption.endAngle + 1;
- let splitAngle = totalAngle / gaugeOption.splitLine.splitNumber;
- let totalNumber = gaugeOption.endNumber - gaugeOption.startNumber;
- let splitNumber = totalNumber / gaugeOption.splitLine.splitNumber;
- let nowAngle = gaugeOption.startAngle;
- let nowNumber = gaugeOption.startNumber;
- for (let i = 0; i < gaugeOption.splitLine.splitNumber + 1; i++) {
- var pos = {
- x: radius * Math.cos(nowAngle * Math.PI),
- y: radius * Math.sin(nowAngle * Math.PI)
- };
- var labelText = gaugeOption.labelFormat ? gaugeOption.labelFormat(nowNumber) : nowNumber;
- pos.x += centerPosition.x - measureText(labelText) / 2;
- pos.y += centerPosition.y;
- var startX = pos.x;
- var startY = pos.y;
- context.beginPath();
- context.setFontSize(config.fontSize);
- context.setFillStyle(gaugeOption.labelColor || '#666666');
- context.fillText(labelText, startX, startY + config.fontSize / 2);
- context.closePath();
- context.stroke();
-
- nowAngle += splitAngle;
- if (nowAngle >= 2) {
- nowAngle = nowAngle % 2;
- }
- nowNumber += splitNumber;
- }
-
-}
-
-function drawRadarLabel(angleList, radius, centerPosition, opts, config, context) {
- var radarOption = opts.extra.radar || {};
- radius += config.radarLabelTextMargin;
-
- angleList.forEach(function(angle, index) {
- var pos = {
- x: radius * Math.cos(angle),
- y: radius * Math.sin(angle)
- };
- var posRelativeCanvas = convertCoordinateOrigin(pos.x, pos.y, centerPosition);
- var startX = posRelativeCanvas.x;
- var startY = posRelativeCanvas.y;
- if (util.approximatelyEqual(pos.x, 0)) {
- startX -= measureText(opts.categories[index] || '') / 2;
- } else if (pos.x < 0) {
- startX -= measureText(opts.categories[index] || '');
- }
- context.beginPath();
- context.setFontSize(config.fontSize);
- context.setFillStyle(radarOption.labelColor || '#666666');
- context.fillText(opts.categories[index] || '', startX, startY + config.fontSize / 2);
- context.closePath();
- context.stroke();
- });
-
-}
-
-function drawPieText(series, opts, config, context, radius, center) {
- var lineRadius = config.pieChartLinePadding;
- var textObjectCollection = [];
- var lastTextObject = null;
-
- var seriesConvert = series.map(function(item) {
- var text = item.format ? item.format(+item._proportion_.toFixed(2)) : util.toFixed(item._proportion_.toFixed(4) * 100) +'%';
- if(item._rose_proportion_) item._proportion_=item._rose_proportion_;
- var arc = 2 * Math.PI - (item._start_ + 2 * Math.PI * item._proportion_ / 2);
- var color = item.color;
- var radius = item._radius_;
- return {
- arc: arc,
- text: text,
- color: color,
- radius: radius,
- textColor: item.textColor,
- textSize: item.textSize,
- };
- });
- for (let i = 0; i < seriesConvert.length; i++) {
- let item = seriesConvert[i];
- // line end
- let orginX1 = Math.cos(item.arc) * (item.radius + lineRadius);
- let orginY1 = Math.sin(item.arc) * (item.radius + lineRadius);
-
- // line start
- let orginX2 = Math.cos(item.arc) * item.radius;
- let orginY2 = Math.sin(item.arc) * item.radius;
-
- // text start
- let orginX3 = orginX1 >= 0 ? orginX1 + config.pieChartTextPadding : orginX1 - config.pieChartTextPadding;
- let orginY3 = orginY1;
- let textWidth = measureText(item.text);
- let startY = orginY3;
-
- if (lastTextObject && util.isSameXCoordinateArea(lastTextObject.start, {
- x: orginX3
- })) {
- if (orginX3 > 0) {
- startY = Math.min(orginY3, lastTextObject.start.y);
- } else if (orginX1 < 0) {
- startY = Math.max(orginY3, lastTextObject.start.y);
- } else {
- if (orginY3 > 0) {
- startY = Math.max(orginY3, lastTextObject.start.y);
- } else {
- startY = Math.min(orginY3, lastTextObject.start.y);
- }
- }
- }
- if (orginX3 < 0) {
- orginX3 -= textWidth;
- }
-
- let textObject = {
- lineStart: {
- x: orginX2,
- y: orginY2
- },
- lineEnd: {
- x: orginX1,
- y: orginY1
- },
- start: {
- x: orginX3,
- y: startY
- },
- width: textWidth,
- height: config.fontSize,
- text: item.text,
- color: item.color,
- textColor: item.textColor,
- textSize: item.textSize
- };
- lastTextObject = avoidCollision(textObject, lastTextObject);
- textObjectCollection.push(lastTextObject);
- }
-
- for (let i = 0; i < textObjectCollection.length; i++) {
- let item = textObjectCollection[i];
- let lineStartPoistion = convertCoordinateOrigin(item.lineStart.x, item.lineStart.y, center);
- let lineEndPoistion = convertCoordinateOrigin(item.lineEnd.x, item.lineEnd.y, center);
- let textPosition = convertCoordinateOrigin(item.start.x, item.start.y, center);
- context.setLineWidth(1 * opts.pixelRatio);
- context.setFontSize(config.fontSize);
- context.beginPath();
- context.setStrokeStyle(item.color);
- context.setFillStyle(item.color);
- context.moveTo(lineStartPoistion.x, lineStartPoistion.y);
- let curveStartX = item.start.x < 0 ? textPosition.x + item.width : textPosition.x;
- let textStartX = item.start.x < 0 ? textPosition.x - 5 : textPosition.x + 5;
- context.quadraticCurveTo(lineEndPoistion.x, lineEndPoistion.y, curveStartX, textPosition.y);
- context.moveTo(lineStartPoistion.x, lineStartPoistion.y);
- context.stroke();
- context.closePath();
- context.beginPath();
- context.moveTo(textPosition.x + item.width, textPosition.y);
- context.arc(curveStartX, textPosition.y, 2, 0, 2 * Math.PI);
- context.closePath();
- context.fill();
- context.beginPath();
- context.setFontSize(item.textSize || config.fontSize);
- context.setFillStyle(item.textColor || '#666666');
- context.fillText(item.text, textStartX, textPosition.y + 3);
- context.closePath();
- context.stroke();
- context.closePath();
- }
-}
-
-function drawToolTipSplitLine(offsetX, opts, config, context) {
- var toolTipOption = opts.extra.tooltip || {};
- toolTipOption.gridType = toolTipOption.gridType == undefined ? 'solid' : toolTipOption.gridType;
- toolTipOption.dashLength = toolTipOption.dashLength == undefined ? 4 : toolTipOption.dashLength;
- var startY = opts.area[0];
- var endY = opts.height - opts.area[2];
-
- if (toolTipOption.gridType == 'dash') {
- context.setLineDash([toolTipOption.dashLength, toolTipOption.dashLength]);
- }
- context.setStrokeStyle(toolTipOption.gridColor || '#cccccc');
- context.setLineWidth(1 * opts.pixelRatio);
- context.beginPath();
- context.moveTo(offsetX, startY);
- context.lineTo(offsetX, endY);
- context.stroke();
- context.setLineDash([]);
-
- if (toolTipOption.xAxisLabel) {
- let labelText = opts.categories[opts.tooltip.index];
- context.setFontSize(config.fontSize);
- let textWidth = measureText(labelText, config.fontSize);
-
- let textX = offsetX - 0.5 * textWidth;
- let textY = endY;
- context.beginPath();
- context.setFillStyle(hexToRgb(toolTipOption.labelBgColor || config.toolTipBackground, toolTipOption.labelBgOpacity || config.toolTipOpacity));
- context.setStrokeStyle(toolTipOption.labelBgColor || config.toolTipBackground);
- context.setLineWidth(1 * opts.pixelRatio);
- context.rect(textX - config.toolTipPadding, textY, textWidth + 2 * config.toolTipPadding, config.fontSize + 2 * config.toolTipPadding);
- context.closePath();
- context.stroke();
- context.fill();
-
- context.beginPath();
- context.setFontSize(config.fontSize);
- context.setFillStyle(toolTipOption.labelFontColor || config.fontColor);
- context.fillText(String(labelText), textX, textY + config.toolTipPadding + config.fontSize);
- context.closePath();
- context.stroke();
- }
-}
-
-function drawMarkLine(minRange, maxRange, opts, config, context) {
- let markLineOption = assign({}, {
- type: 'solid',
- dashLength: 4,
- data: []
- }, opts.extra.markLine);
- let startX = opts.area[3];
- let endX = opts.width - opts.padding[1];
- let points = calMarkLineData(minRange, maxRange, markLineOption.data, opts);
-
- for (let i = 0; i < points.length; i++) {
- let item = assign({}, {
- lineColor: '#DE4A42',
- showLabel: false,
- labelFontColor: '#666666',
- labelBgColor: '#DFE8FF',
- labelBgOpacity: 0.8,
- yAxisIndex: 0
- }, points[i]);
-
- if (markLineOption.type == 'dash') {
- context.setLineDash([markLineOption.dashLength, markLineOption.dashLength]);
- }
- context.setStrokeStyle(item.lineColor);
- context.setLineWidth(1 * opts.pixelRatio);
- context.beginPath();
- context.moveTo(startX, item.y);
- context.lineTo(endX, item.y);
- context.stroke();
- context.setLineDash([]);
- if (item.showLabel) {
- let labelText = opts.yAxis.format ? opts.yAxis.format(Number(item.value)) : item.value;
- context.setFontSize(config.fontSize);
- let textWidth = measureText(labelText, config.fontSize);
- let bgStartX = opts.padding[3] + config.yAxisTitleWidth - config.toolTipPadding;
- let bgEndX = Math.max(opts.area[3], textWidth + config.toolTipPadding * 2);
- let bgWidth = bgEndX - bgStartX;
-
- let textX = bgStartX + (bgWidth - textWidth) / 2;
- let textY = item.y;
- context.setFillStyle(hexToRgb(item.labelBgColor, item.labelBgOpacity));
- context.setStrokeStyle(item.labelBgColor);
- context.setLineWidth(1 * opts.pixelRatio);
- context.beginPath();
- context.rect(bgStartX, textY - 0.5 * config.fontSize - config.toolTipPadding, bgWidth, config.fontSize + 2 * config.toolTipPadding);
- context.closePath();
- context.stroke();
- context.fill();
-
- context.beginPath();
- context.setFontSize(config.fontSize);
- context.setFillStyle(item.labelFontColor);
- context.fillText(String(labelText), textX, textY + 0.5 * config.fontSize);
- context.stroke();
- }
- }
-}
-
-function drawToolTipHorizentalLine(opts, config, context, eachSpacing, xAxisPoints) {
- var toolTipOption = assign({}, {
- gridType: 'solid',
- dashLength: 4
- }, opts.extra.tooltip);
-
- var startX = opts.area[3];
- var endX = opts.width - opts.padding[1];
-
- if (toolTipOption.gridType == 'dash') {
- context.setLineDash([toolTipOption.dashLength, toolTipOption.dashLength]);
- }
- context.setStrokeStyle(toolTipOption.gridColor || '#cccccc');
- context.setLineWidth(1 * opts.pixelRatio);
- context.beginPath();
- context.moveTo(startX, opts.tooltip.offset.y);
- context.lineTo(endX, opts.tooltip.offset.y);
- context.stroke();
- context.setLineDash([]);
-
- if (toolTipOption.yAxisLabel) {
- let labelText = calTooltipYAxisData(opts.tooltip.offset.y, opts.series, opts, config, eachSpacing);
- context.setFontSize(config.fontSize);
- let textWidth = measureText(labelText, config.fontSize);
- let bgStartX = opts.padding[3] + config.yAxisTitleWidth - config.toolTipPadding;
- let bgEndX = Math.max(opts.area[3], textWidth + config.toolTipPadding * 2);
- let bgWidth = bgEndX - bgStartX;
-
- let textX = bgStartX + (bgWidth - textWidth) / 2;
- let textY = opts.tooltip.offset.y;
- context.beginPath();
- context.setFillStyle(hexToRgb(toolTipOption.labelBgColor || config.toolTipBackground, toolTipOption.labelBgOpacity || config.toolTipOpacity));
- context.setStrokeStyle(toolTipOption.labelBgColor || config.toolTipBackground);
- context.setLineWidth(1 * opts.pixelRatio);
- context.rect(bgStartX, textY - 0.5 * config.fontSize - config.toolTipPadding, bgWidth, config.fontSize + 2 * config.toolTipPadding);
- context.closePath();
- context.stroke();
- context.fill();
-
- context.beginPath();
- context.setFontSize(config.fontSize);
- context.setFillStyle(toolTipOption.labelFontColor || config.fontColor);
- context.fillText(labelText, textX, textY + 0.5 * config.fontSize);
- context.closePath();
- context.stroke();
- }
-}
-
-function drawToolTipSplitArea(offsetX, opts, config, context, eachSpacing) {
- var toolTipOption = assign({}, {
- activeBgColor: '#000000',
- activeBgOpacity: 0.08
- }, opts.extra.tooltip);
- var startY = opts.area[0];
- var endY = opts.height - opts.area[2];
- context.beginPath();
- context.setFillStyle(hexToRgb(toolTipOption.activeBgColor, toolTipOption.activeBgOpacity));
- context.rect(offsetX - eachSpacing / 2, startY, eachSpacing, endY - startY);
- context.closePath();
- context.fill();
-}
-
-function drawToolTip(textList, offset, opts, config, context, eachSpacing, xAxisPoints) {
- var toolTipOption = assign({}, {
- bgColor: '#000000',
- bgOpacity: 0.7,
- fontColor: '#FFFFFF'
- }, opts.extra.tooltip);
- var legendWidth = 4 * opts.pixelRatio;
- var legendMarginRight = 5 * opts.pixelRatio;
- var arrowWidth = 8 * opts.pixelRatio;
- var isOverRightBorder = false;
- if (opts.type == 'line' || opts.type == 'area' || opts.type == 'candle' || opts.type == 'mix') {
- drawToolTipSplitLine(opts.tooltip.offset.x, opts, config, context);
- }
-
- offset = assign({
- x: 0,
- y: 0
- }, offset);
- offset.y -= 8 * opts.pixelRatio;
- var textWidth = textList.map(function(item) {
- return measureText(item.text, config.fontSize);
- });
- var toolTipWidth = legendWidth + legendMarginRight + 4 * config.toolTipPadding + Math.max.apply(null, textWidth);
- var toolTipHeight = 2 * config.toolTipPadding + textList.length * config.toolTipLineHeight;
-
- // if beyond the right border
- if (offset.x - Math.abs(opts._scrollDistance_) + arrowWidth + toolTipWidth > opts.width) {
- isOverRightBorder = true;
- }
- if (toolTipHeight + offset.y > opts.height) {
- offset.y = opts.height - toolTipHeight;
- }
- // draw background rect
- context.beginPath();
- context.setFillStyle(hexToRgb(toolTipOption.bgColor || config.toolTipBackground, toolTipOption.bgOpacity || config.toolTipOpacity));
- if (isOverRightBorder) {
- context.moveTo(offset.x, offset.y + 10 * opts.pixelRatio);
- context.lineTo(offset.x - arrowWidth, offset.y + 10 * opts.pixelRatio - 5 * opts.pixelRatio);
- context.lineTo(offset.x - arrowWidth, offset.y);
- context.lineTo(offset.x - arrowWidth - Math.round(toolTipWidth), offset.y);
- context.lineTo(offset.x - arrowWidth - Math.round(toolTipWidth), offset.y + toolTipHeight);
- context.lineTo(offset.x - arrowWidth, offset.y + toolTipHeight);
- context.lineTo(offset.x - arrowWidth, offset.y + 10 * opts.pixelRatio + 5 * opts.pixelRatio);
- context.lineTo(offset.x, offset.y + 10 * opts.pixelRatio);
- } else {
- context.moveTo(offset.x, offset.y + 10 * opts.pixelRatio);
- context.lineTo(offset.x + arrowWidth, offset.y + 10 * opts.pixelRatio - 5 * opts.pixelRatio);
- context.lineTo(offset.x + arrowWidth, offset.y);
- context.lineTo(offset.x + arrowWidth + Math.round(toolTipWidth), offset.y);
- context.lineTo(offset.x + arrowWidth + Math.round(toolTipWidth), offset.y + toolTipHeight);
- context.lineTo(offset.x + arrowWidth, offset.y + toolTipHeight);
- context.lineTo(offset.x + arrowWidth, offset.y + 10 * opts.pixelRatio + 5 * opts.pixelRatio);
- context.lineTo(offset.x, offset.y + 10 * opts.pixelRatio);
- }
-
- context.closePath();
- context.fill();
-
- // draw legend
- textList.forEach(function(item, index) {
- if (item.color !== null) {
- context.beginPath();
- context.setFillStyle(item.color);
- var startX = offset.x + arrowWidth + 2 * config.toolTipPadding;
- var startY = offset.y + (config.toolTipLineHeight - config.fontSize) / 2 + config.toolTipLineHeight * index +
- config.toolTipPadding + 1;
- if (isOverRightBorder) {
- startX = offset.x - toolTipWidth - arrowWidth + 2 * config.toolTipPadding;
- }
- context.fillRect(startX, startY, legendWidth, config.fontSize);
- context.closePath();
- }
- });
-
- // draw text list
-
- textList.forEach(function(item, index) {
- var startX = offset.x + arrowWidth + 2 * config.toolTipPadding + legendWidth + legendMarginRight;
- if (isOverRightBorder) {
- startX = offset.x - toolTipWidth - arrowWidth + 2 * config.toolTipPadding + +legendWidth + legendMarginRight;
- }
- var startY = offset.y + (config.toolTipLineHeight - config.fontSize) / 2 + config.toolTipLineHeight * index +
- config.toolTipPadding;
- context.beginPath();
- context.setFontSize(config.fontSize);
- context.setFillStyle(toolTipOption.fontColor);
- context.fillText(item.text, startX, startY + config.fontSize);
- context.closePath();
- context.stroke();
- });
-}
-
-function drawYAxisTitle(title, opts, config, context) {
- var startX = config.xAxisHeight + (opts.height - config.xAxisHeight - measureText(title)) / 2;
- context.save();
- context.beginPath();
- context.setFontSize(config.fontSize);
- context.setFillStyle(opts.yAxis.titleFontColor || '#333333');
- context.translate(0, opts.height);
- context.rotate(-90 * Math.PI / 180);
- context.fillText(title, startX, opts.padding[3] + 0.5 * config.fontSize);
- context.closePath();
- context.stroke();
- context.restore();
-}
-
-function drawColumnDataPoints(series, opts, config, context) {
- let process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
- let ranges = [].concat(opts.chartData.yAxisData.ranges);
- let xAxisData = opts.chartData.xAxisData,
- xAxisPoints = xAxisData.xAxisPoints,
- eachSpacing = xAxisData.eachSpacing;
- let columnOption = assign({}, {
- type: 'group',
- width: eachSpacing / 2,
- meter: {
- border: 4,
- fillColor: '#FFFFFF'
- }
- }, opts.extra.column);
- let minRange = ranges.pop();
- let maxRange = ranges.shift();
- let calPoints = [];
-
- context.save();
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
- context.translate(opts._scrollDistance_, 0);
- }
- if (opts.tooltip && opts.tooltip.textList && opts.tooltip.textList.length && process === 1) {
- drawToolTipSplitArea(opts.tooltip.offset.x, opts, config, context, eachSpacing);
- }
-
- series.forEach(function(eachSeries, seriesIndex) {
- var data = eachSeries.data;
- switch (columnOption.type) {
- case 'group':
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
- var tooltipPoints = getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, seriesIndex, series, process);
- calPoints.push(tooltipPoints);
- points = fixColumeData(points, eachSpacing, series.length, seriesIndex, config, opts);
- points.forEach(function(item, index) {
- if (item !== null) {
- context.beginPath();
- context.setStrokeStyle(item.color || eachSeries.color);
- context.setLineWidth(1)
- context.setFillStyle(item.color || eachSeries.color);
- var startX = item.x - item.width / 2;
- var height = opts.height - item.y - opts.area[2];
- context.moveTo(startX-1, item.y);
- context.lineTo(startX+item.width-2,item.y);
- context.lineTo(startX+item.width-2,opts.height - opts.area[2]);
- context.lineTo(startX,opts.height - opts.area[2]);
- context.lineTo(startX,item.y);
- //context.rect(startX, item.y, item.width, height);
- context.closePath();
- context.stroke();
- context.fill();
- }
- });
- break;
- case 'stack':
- // 绘制堆叠数据图
- var points = getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config,
- seriesIndex,
- series, process);
- calPoints.push(points);
- points = fixColumeStackData(points, eachSpacing, series.length, seriesIndex, config, opts, series);
-
- points.forEach(function(item, index) {
- if (item !== null) {
- context.beginPath();
- context.setFillStyle(item.color || eachSeries.color);
- var startX = item.x - item.width / 2 + 1;
- var height = opts.height - item.y - opts.area[2];
- var height0 = opts.height - item.y0 - opts.area[2];
- if (seriesIndex > 0) {
- height -= height0;
- }
- context.moveTo(startX, item.y);
- context.fillRect(startX, item.y, item.width - 2, height);
- context.closePath();
- context.fill();
- }
- });
- break;
- case 'meter':
- // 绘制温度计数据图
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
- calPoints.push(points);
- points = fixColumeMeterData(points, eachSpacing, series.length, seriesIndex, config, opts, columnOption.meter
- .border);
- if (seriesIndex == 0) {
- points.forEach(function(item, index) {
- if (item !== null) {
- //画背景颜色
- context.beginPath();
- context.setFillStyle(columnOption.meter.fillColor);
- var startX = item.x - item.width / 2;
- var height = opts.height - item.y - opts.area[2];
- context.moveTo(startX, item.y);
- context.fillRect(startX, item.y, item.width, height);
- context.closePath();
- context.fill();
- //画边框线
- if (columnOption.meter.border > 0) {
- context.beginPath();
- context.setStrokeStyle(eachSeries.color);
- context.setLineWidth(columnOption.meter.border * opts.pixelRatio);
- context.moveTo(startX + columnOption.meter.border * 0.5, item.y + height);
- context.lineTo(startX + columnOption.meter.border * 0.5, item.y + columnOption.meter.border * 0.5);
- context.lineTo(startX + item.width - columnOption.meter.border * 0.5, item.y + columnOption.meter.border * 0.5);
- context.lineTo(startX + item.width - columnOption.meter.border * 0.5, item.y + height);
- context.stroke();
- }
- }
- });
- } else {
- points.forEach(function(item, index) {
- if (item !== null) {
- context.beginPath();
- context.setFillStyle(item.color || eachSeries.color);
- var startX = item.x - item.width / 2;
- var height = opts.height - item.y - opts.area[2];
- context.moveTo(startX, item.y);
- context.fillRect(startX, item.y, item.width, height);
- context.closePath();
- context.fill();
- }
- });
- }
- break;
- }
- });
-
- if (opts.dataLabel !== false && process === 1) {
- series.forEach(function(eachSeries, seriesIndex) {
- var data = eachSeries.data;
- switch (columnOption.type) {
- case 'group':
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
- points = fixColumeData(points, eachSpacing, series.length, seriesIndex, config, opts);
-
- drawPointText(points, eachSeries, config, context);
- break;
- case 'stack':
- var points = getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config,
- seriesIndex,
- series, process);
- drawPointText(points, eachSeries, config, context);
- break;
- case 'meter':
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
- drawPointText(points, eachSeries, config, context);
- break;
- }
- });
- }
-
- context.restore();
-
- return {
- xAxisPoints: xAxisPoints,
- calPoints: calPoints,
- eachSpacing: eachSpacing,
- minRange: minRange,
- maxRange: maxRange
- };
-}
-
-function drawCandleDataPoints(series, seriesMA, opts, config, context) {
- var process = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1;
- var candleOption = assign({}, {
- color: {},
- average: {}
- }, opts.extra.candle);
- candleOption.color = assign({}, {
- upLine: '#f04864',
- upFill: '#f04864',
- downLine: '#2fc25b',
- downFill: '#2fc25b'
- }, candleOption.color);
- candleOption.average = assign({}, {
- show: false,
- name: [],
- day: [],
- color: config.colors
- }, candleOption.average);
- opts.extra.candle = candleOption;
-
- let ranges = [].concat(opts.chartData.yAxisData.ranges);
- let xAxisData = opts.chartData.xAxisData,
- xAxisPoints = xAxisData.xAxisPoints,
- eachSpacing = xAxisData.eachSpacing;
-
- let minRange = ranges.pop();
- let maxRange = ranges.shift();
- let calPoints = [];
-
- context.save();
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
- context.translate(opts._scrollDistance_, 0);
- }
- //画均线
- if (candleOption.average.show) {
- seriesMA.forEach(function(eachSeries, seriesIndex) {
- var data = eachSeries.data;
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
- //calPoints.push(points);
- var splitPointList = splitPoints(points);
-
- splitPointList.forEach(function(points, index) {
- context.beginPath();
- context.setStrokeStyle(eachSeries.color);
- context.setLineWidth(1);
- if (points.length === 1) {
- context.moveTo(points[0].x, points[0].y);
- context.arc(points[0].x, points[0].y, 1, 0, 2 * Math.PI);
- } else {
- context.moveTo(points[0].x, points[0].y);
- points.forEach(function(item, index) {
- if (index > 0) {
- var ctrlPoint = createCurveControlPoints(points, index - 1);
- context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y,
- item.x, item
- .y);
- }
- });
- context.moveTo(points[0].x, points[0].y);
- }
- context.closePath();
- context.stroke();
- });
- });
- }
- //画K线
- series.forEach(function(eachSeries, seriesIndex) {
- var data = eachSeries.data;
- var points = getCandleDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
- calPoints.push(points);
- var splitPointList = splitPoints(points);
- splitPointList = splitPointList[0];
-
- splitPointList.forEach(function(points, index) {
- context.beginPath();
- //如果上涨
- if (data[index][1] - data[index][0] > 0) {
- context.setStrokeStyle(candleOption.color.upLine);
- context.setFillStyle(candleOption.color.upFill);
- context.setLineWidth(1 * opts.pixelRatio);
- context.moveTo(points[3].x, points[3].y); //顶点
- context.lineTo(points[1].x, points[1].y); //收盘中间点
- context.lineTo(points[1].x - eachSpacing / 4, points[1].y); //收盘左侧点
- context.lineTo(points[0].x - eachSpacing / 4, points[0].y); //开盘左侧点
- context.lineTo(points[0].x, points[0].y); //开盘中间点
- context.lineTo(points[2].x, points[2].y); //底点
- context.lineTo(points[0].x, points[0].y); //开盘中间点
- context.lineTo(points[0].x + eachSpacing / 4, points[0].y); //开盘右侧点
- context.lineTo(points[1].x + eachSpacing / 4, points[1].y); //收盘右侧点
- context.lineTo(points[1].x, points[1].y); //收盘中间点
- context.moveTo(points[3].x, points[3].y); //顶点
- } else {
- context.setStrokeStyle(candleOption.color.downLine);
- context.setFillStyle(candleOption.color.downFill);
- context.setLineWidth(1 * opts.pixelRatio);
- context.moveTo(points[3].x, points[3].y); //顶点
- context.lineTo(points[0].x, points[0].y); //开盘中间点
- context.lineTo(points[0].x - eachSpacing / 4, points[0].y); //开盘左侧点
- context.lineTo(points[1].x - eachSpacing / 4, points[1].y); //收盘左侧点
- context.lineTo(points[1].x, points[1].y); //收盘中间点
- context.lineTo(points[2].x, points[2].y); //底点
- context.lineTo(points[1].x, points[1].y); //收盘中间点
- context.lineTo(points[1].x + eachSpacing / 4, points[1].y); //收盘右侧点
- context.lineTo(points[0].x + eachSpacing / 4, points[0].y); //开盘右侧点
- context.lineTo(points[0].x, points[0].y); //开盘中间点
- context.moveTo(points[3].x, points[3].y); //顶点
- }
- context.closePath();
- context.fill();
- context.stroke();
- });
- });
-
- context.restore();
-
- return {
- xAxisPoints: xAxisPoints,
- calPoints: calPoints,
- eachSpacing: eachSpacing,
- minRange: minRange,
- maxRange: maxRange
- };
-}
-
-function drawAreaDataPoints(series, opts, config, context) {
- var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
- var areaOption = assign({},{
- type: 'straight',
- opacity: 0.2,
- addLine: false,
- width: 2
- },opts.extra.area);
-
- let ranges = [].concat(opts.chartData.yAxisData.ranges);
- let xAxisData = opts.chartData.xAxisData,
- xAxisPoints = xAxisData.xAxisPoints,
- eachSpacing = xAxisData.eachSpacing;
-
- let minRange = ranges.pop();
- let maxRange = ranges.shift();
- let endY = opts.height - opts.area[2];
- let calPoints = [];
-
- context.save();
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
- context.translate(opts._scrollDistance_, 0);
- }
-
- series.forEach(function(eachSeries, seriesIndex) {
- let data = eachSeries.data;
- let points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
- calPoints.push(points);
-
- let splitPointList = splitPoints(points);
-
- for (let i = 0; i < splitPointList.length; i++) {
- let points = splitPointList[i];
- // 绘制区域数
- context.beginPath();
- context.setStrokeStyle(hexToRgb(eachSeries.color, areaOption.opacity));
- context.setFillStyle(hexToRgb(eachSeries.color, areaOption.opacity));
- context.setLineWidth(areaOption.width * opts.pixelRatio);
- if (points.length > 1) {
- let firstPoint = points[0];
- let lastPoint = points[points.length - 1];
-
- context.moveTo(firstPoint.x, firstPoint.y);
- if (areaOption.type === 'curve') {
- points.forEach(function(item, index) {
- if (index > 0) {
- let ctrlPoint = createCurveControlPoints(points, index - 1);
- context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y,item.x, item.y);
- }
- });
- } else {
- points.forEach(function(item, index) {
- if (index > 0) {
- context.lineTo(item.x, item.y);
- }
- });
- }
-
- context.lineTo(lastPoint.x, endY);
- context.lineTo(firstPoint.x, endY);
- context.lineTo(firstPoint.x, firstPoint.y);
- } else {
- let item = points[0];
- context.moveTo(item.x - eachSpacing / 2, item.y);
- context.lineTo(item.x + eachSpacing / 2, item.y);
- context.lineTo(item.x + eachSpacing / 2, endY);
- context.lineTo(item.x - eachSpacing / 2, endY);
- context.moveTo(item.x - eachSpacing / 2, item.y);
- }
- context.closePath();
- context.fill();
-
- //画连线
- if (areaOption.addLine) {
- context.beginPath();
- context.setStrokeStyle(eachSeries.color);
- context.setLineWidth(areaOption.width * opts.pixelRatio);
- if (points.length === 1) {
- context.moveTo(points[0].x, points[0].y);
- context.arc(points[0].x, points[0].y, 1, 0, 2 * Math.PI);
- } else {
- context.moveTo(points[0].x, points[0].y);
- if (areaOption.type === 'curve') {
- points.forEach(function(item, index) {
- if (index > 0) {
- let ctrlPoint = createCurveControlPoints(points, index - 1);
- context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y,item.x,item.y);
- }
- });
- } else {
- points.forEach(function(item, index) {
- if (index > 0) {
- context.lineTo(item.x, item.y);
- }
- });
- }
- context.moveTo(points[0].x, points[0].y);
- }
- context.closePath();
- context.stroke();
- }
- }
-
- //画点
- if (opts.dataPointShape !== false) {
- var shape = config.dataPointShape[seriesIndex % config.dataPointShape.length];
- drawPointShape(points, eachSeries.color, shape, context, opts);
- }
-
- });
-
- if (opts.dataLabel !== false && process === 1) {
- series.forEach(function(eachSeries, seriesIndex) {
- var data = eachSeries.data;
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
- drawPointText(points, eachSeries, config, context);
- });
- }
-
- context.restore();
-
- return {
- xAxisPoints: xAxisPoints,
- calPoints: calPoints,
- eachSpacing: eachSpacing,
- minRange: minRange,
- maxRange: maxRange
- };
-}
-
-function drawLineDataPoints(series, opts, config, context) {
- var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
- var lineOption = opts.extra.line || {
- type: 'straight',
- width: 2
- };
- lineOption.type = lineOption.type ? lineOption.type : 'straight';
- lineOption.width = lineOption.width ? lineOption.width : 2;
-
- let ranges = [].concat(opts.chartData.yAxisData.ranges);
- let xAxisData = opts.chartData.xAxisData,
- xAxisPoints = xAxisData.xAxisPoints,
- eachSpacing = xAxisData.eachSpacing;
-
- var minRange = ranges.pop();
- var maxRange = ranges.shift();
- var calPoints = [];
-
- context.save();
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
- context.translate(opts._scrollDistance_, 0);
- }
-
- series.forEach(function(eachSeries, seriesIndex) {
- var data = eachSeries.data;
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
- calPoints.push(points);
- var splitPointList = splitPoints(points);
-
- splitPointList.forEach(function(points, index) {
- context.beginPath();
- context.setStrokeStyle(eachSeries.color);
- context.setLineWidth(lineOption.width * opts.pixelRatio);
- if (points.length === 1) {
- context.moveTo(points[0].x, points[0].y);
- context.arc(points[0].x, points[0].y, 1, 0, 2 * Math.PI);
- } else {
- context.moveTo(points[0].x, points[0].y);
- if (lineOption.type === 'curve') {
- points.forEach(function(item, index) {
- if (index > 0) {
- var ctrlPoint = createCurveControlPoints(points, index - 1);
- context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y,
- item.x, item
- .y);
- }
- });
- } else {
- points.forEach(function(item, index) {
- if (index > 0) {
- context.lineTo(item.x, item.y);
- }
- });
- }
- context.moveTo(points[0].x, points[0].y);
- }
- context.closePath();
- context.stroke();
- });
-
- if (opts.dataPointShape !== false) {
- var shape = config.dataPointShape[seriesIndex % config.dataPointShape.length];
- drawPointShape(points, eachSeries.color, shape, context, opts);
- }
- });
-
- if (opts.dataLabel !== false && process === 1) {
- series.forEach(function(eachSeries, seriesIndex) {
- var data = eachSeries.data;
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
- drawPointText(points, eachSeries, config, context);
- });
- }
-
- context.restore();
-
- return {
- xAxisPoints: xAxisPoints,
- calPoints: calPoints,
- eachSpacing: eachSpacing,
- minRange: minRange,
- maxRange: maxRange
- };
-}
-
-function drawMixDataPoints(series, opts, config, context) {
- let process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
- let ranges = [].concat(opts.chartData.yAxisData.ranges);
- let xAxisData = opts.chartData.xAxisData,
- xAxisPoints = xAxisData.xAxisPoints,
- eachSpacing = xAxisData.eachSpacing;
-
- let minRange = ranges.pop();
- let maxRange = ranges.shift();
- let endY = opts.height - opts.area[2];
- let calPoints = [];
-
- var columnIndex = 0;
- var columnLength = 0;
- series.forEach(function(eachSeries, seriesIndex) {
- if (eachSeries.type == 'column') {
- columnLength += 1;
- }
- });
- context.save();
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
- context.translate(opts._scrollDistance_, 0);
- }
-
- series.forEach(function(eachSeries, seriesIndex) {
- var data = eachSeries.data;
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
- calPoints.push(points);
-
- // 绘制柱状数据图
- if (eachSeries.type == 'column') {
- points = fixColumeData(points, eachSpacing, columnLength, columnIndex, config, opts);
- points.forEach(function(item, index) {
- if (item !== null) {
- context.beginPath();
- context.setStrokeStyle(item.color || eachSeries.color);
- context.setLineWidth(1)
- context.setFillStyle(item.color || eachSeries.color);
- var startX = item.x - item.width / 2;
- var height = opts.height - item.y - opts.area[2];
- context.moveTo(startX, item.y);
- context.moveTo(startX-1, item.y);
- context.lineTo(startX+item.width-2,item.y);
- context.lineTo(startX+item.width-2,opts.height - opts.area[2]);
- context.lineTo(startX,opts.height - opts.area[2]);
- context.lineTo(startX,item.y);
- //context.rect(startX, item.y, item.width, height);
- context.closePath();
- context.stroke();
- context.fill();
- context.closePath();
- context.fill();
- }
- });
- columnIndex += 1;
- }
-
- //绘制区域图数据
-
- if (eachSeries.type == 'area') {
- let splitPointList = splitPoints(points);
- for (let i = 0; i < splitPointList.length; i++) {
- let points = splitPointList[i];
- // 绘制区域数据
- context.beginPath();
- context.setStrokeStyle(eachSeries.color);
- context.setFillStyle(hexToRgb(eachSeries.color, 0.2));
- context.setLineWidth(2 * opts.pixelRatio);
- if (points.length > 1) {
- var firstPoint = points[0];
- let lastPoint = points[points.length - 1];
- context.moveTo(firstPoint.x, firstPoint.y);
- if (eachSeries.style === 'curve') {
- points.forEach(function(item, index) {
- if (index > 0) {
- var ctrlPoint = createCurveControlPoints(points, index - 1);
- context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y, item.x, item.y);
- }
- });
- } else {
- points.forEach(function(item, index) {
- if (index > 0) {
- context.lineTo(item.x, item.y);
- }
- });
- }
- context.lineTo(lastPoint.x, endY);
- context.lineTo(firstPoint.x, endY);
- context.lineTo(firstPoint.x, firstPoint.y);
- } else {
- let item = points[0];
- context.moveTo(item.x - eachSpacing / 2, item.y);
- context.lineTo(item.x + eachSpacing / 2, item.y);
- context.lineTo(item.x + eachSpacing / 2, endY);
- context.lineTo(item.x - eachSpacing / 2, endY);
- context.moveTo(item.x - eachSpacing / 2, item.y);
- }
- context.closePath();
- context.fill();
- }
- }
-
- // 绘制折线数据图
- if (eachSeries.type == 'line') {
- var splitPointList = splitPoints(points);
- splitPointList.forEach(function(points, index) {
- context.beginPath();
- context.setStrokeStyle(eachSeries.color);
- context.setLineWidth(2 * opts.pixelRatio);
- if (points.length === 1) {
- context.moveTo(points[0].x, points[0].y);
- context.arc(points[0].x, points[0].y, 1, 0, 2 * Math.PI);
- } else {
- context.moveTo(points[0].x, points[0].y);
- if (eachSeries.style == 'curve') {
- points.forEach(function(item, index) {
- if (index > 0) {
- var ctrlPoint = createCurveControlPoints(points, index - 1);
- context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y,
- item.x,
- item.y);
- }
- });
- } else {
- points.forEach(function(item, index) {
- if (index > 0) {
- context.lineTo(item.x, item.y);
- }
- });
- }
- context.moveTo(points[0].x, points[0].y);
- }
- context.closePath();
- context.stroke();
- });
- }
-
- // 绘制点数据图
- if (eachSeries.type == 'point') {
- points.forEach(function(pointsa, index) {
- if (pointsa) {
- context.beginPath();
- context.setFillStyle(eachSeries.color);
- context.setStrokeStyle('#FFFFFF');
- context.setLineWidth(1 * opts.pixelRatio);
- context.moveTo(pointsa.x + 3.5 * opts.pixelRatio, pointsa.y);
- context.arc(pointsa.x, pointsa.y, 4 * opts.pixelRatio, 0, 2 * Math.PI);
- context.closePath();
- context.fill();
- context.stroke();
- }
- });
- }
-
- if (eachSeries.addPoint == true && eachSeries.type !== 'column') {
- var shape = config.dataPointShape[seriesIndex % config.dataPointShape.length];
- drawPointShape(points, eachSeries.color, shape, context, opts);
- }
- });
- if (opts.dataLabel !== false && process === 1) {
- var columnIndex = 0;
- series.forEach(function(eachSeries, seriesIndex) {
- var data = eachSeries.data;
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config, process);
- if (eachSeries.type !== 'column') {
- drawPointText(points, eachSeries, config, context);
- } else {
- points = fixColumeData(points, eachSpacing, columnLength, columnIndex, config, opts);
- drawPointText(points, eachSeries, config, context);
- columnIndex += 1;
- }
-
- });
- }
-
- context.restore();
-
- return {
- xAxisPoints: xAxisPoints,
- calPoints: calPoints,
- eachSpacing: eachSpacing,
- minRange: minRange,
- maxRange: maxRange
- };
-}
-
-function drawToolTipBridge(opts, config, context, process, eachSpacing, xAxisPoints) {
- var toolTipOption = opts.extra.tooltip || {};
- if (toolTipOption.horizentalLine && opts.tooltip && process === 1 && (opts.type == 'line' || opts.type == 'area' || opts.type == 'column' || opts.type == 'candle' || opts.type == 'mix')) {
- drawToolTipHorizentalLine(opts, config, context, eachSpacing, xAxisPoints)
- }
- context.save();
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
- context.translate(opts._scrollDistance_, 0);
- }
- if (opts.tooltip && opts.tooltip.textList && opts.tooltip.textList.length && process === 1) {
- drawToolTip(opts.tooltip.textList, opts.tooltip.offset, opts, config, context, eachSpacing, xAxisPoints);
- }
- context.restore();
-
-}
-
-function drawXAxis(categories, opts, config, context) {
-
- let xAxisData = opts.chartData.xAxisData,
- xAxisPoints = xAxisData.xAxisPoints,
- startX = xAxisData.startX,
- endX = xAxisData.endX,
- eachSpacing = xAxisData.eachSpacing;
- var boundaryGap='center';
- if (opts.type == 'line'||opts.type == 'area'){
- boundaryGap=opts.xAxis.boundaryGap;
- }
- var startY = opts.height - opts.area[2];
- var endY = opts.area[0];
-
- //绘制滚动条
- if (opts.enableScroll && opts.xAxis.scrollShow) {
- var scrollY = opts.height - opts.area[2] + config.xAxisHeight;
- var scrollScreenWidth = endX - startX;
- var scrollTotalWidth = eachSpacing * (xAxisPoints.length - 1);
- var scrollWidth = scrollScreenWidth * scrollScreenWidth / scrollTotalWidth;
- var scrollLeft = 0;
- if (opts._scrollDistance_) {
- scrollLeft = -opts._scrollDistance_ * (scrollScreenWidth) / scrollTotalWidth;
- }
- context.beginPath();
- context.setLineCap('round');
- context.setLineWidth(6 * opts.pixelRatio);
- context.setStrokeStyle(opts.xAxis.scrollBackgroundColor || "#EFEBEF");
- context.moveTo(startX, scrollY);
- context.lineTo(endX, scrollY);
- context.stroke();
- context.closePath();
- context.beginPath();
- context.setLineCap('round');
- context.setLineWidth(6 * opts.pixelRatio);
- context.setStrokeStyle(opts.xAxis.scrollColor || "#A6A6A6");
- context.moveTo(startX + scrollLeft, scrollY);
- context.lineTo(startX + scrollLeft + scrollWidth, scrollY);
- context.stroke();
- context.closePath();
- context.setLineCap('butt');
- }
-
- context.save();
-
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0) {
- context.translate(opts._scrollDistance_, 0);
- }
-
-
- if (opts.xAxis.disableGrid !== true) {
- context.setStrokeStyle(opts.xAxis.gridColor || "#cccccc");
- context.setLineCap('butt');
- context.setLineWidth(1 * opts.pixelRatio);
- if (opts.xAxis.gridType == 'dash') {
- context.setLineDash([opts.xAxis.dashLength, opts.xAxis.dashLength]);
- }
- if (opts.xAxis.type === 'calibration') {
- xAxisPoints.forEach(function(item, index) {
- if (index > 0) {
- context.beginPath();
- context.moveTo(item - eachSpacing / 2, startY);
- context.lineTo(item - eachSpacing / 2, startY + 4 * opts.pixelRatio);
- context.closePath();
- context.stroke();
- }
- });
- } else {
- opts.xAxis.gridEval = opts.xAxis.gridEval || 1;
- xAxisPoints.forEach(function(item, index) {
- if (index % opts.xAxis.gridEval == 0) {
- context.beginPath();
- context.moveTo(item, startY);
- context.lineTo(item, endY);
- context.stroke();
- }
- });
- }
- context.setLineDash([]);
- }
-
-
- //不绘制X轴
- if (opts.xAxis.disabled !== true) {
- // 对X轴列表做抽稀处理
- let validWidth = opts.width - opts.padding[1] - opts.padding[3] - config.yAxisWidth - config.yAxisTitleWidth;
- //默认全部显示X轴标签
- let maxXAxisListLength = categories.length;
- //如果设置了X轴单屏数量
- if (opts.xAxis.labelCount) {
- //如果设置X轴密度
- if (opts.xAxis.itemCount) {
- maxXAxisListLength = Math.ceil(categories.length / opts.xAxis.itemCount * opts.xAxis.labelCount);
- } else {
- maxXAxisListLength = opts.xAxis.labelCount;
- }
- maxXAxisListLength -= 1;
- }
-
- let ratio = Math.ceil(categories.length / maxXAxisListLength);
-
- let newCategories = [];
- let cgLength = categories.length;
- for (let i = 0; i < cgLength; i++) {
- if (i % ratio !== 0) {
- newCategories.push("");
- } else {
- newCategories.push(categories[i]);
- }
- }
- newCategories[cgLength - 1] = categories[cgLength - 1];
-
- var xAxisFontSize = opts.xAxis.fontSize || config.fontSize;
- if (config._xAxisTextAngle_ === 0) {
- newCategories.forEach(function(item, index) {
- var offset = - measureText(item, xAxisFontSize) / 2;
- if(boundaryGap == 'center'){
- offset+=eachSpacing / 2;
- }
- context.beginPath();
- context.setFontSize(xAxisFontSize);
- context.setFillStyle(opts.xAxis.fontColor || '#666666');
- context.fillText(item, xAxisPoints[index] + offset, startY + xAxisFontSize + (config.xAxisHeight - xAxisFontSize) / 2);
- context.closePath();
- context.stroke();
- });
-
- } else {
- newCategories.forEach(function(item, index) {
- context.save();
- context.beginPath();
- context.setFontSize(xAxisFontSize);
- context.setFillStyle(opts.xAxis.fontColor || '#666666');
- var textWidth = measureText(item);
- var offset = - textWidth;
- if(boundaryGap == 'center'){
- offset+=eachSpacing / 2;
- }
- var _calRotateTranslate = calRotateTranslate(xAxisPoints[index] + eachSpacing / 2, startY + xAxisFontSize / 2 + 5, opts.height),
- transX = _calRotateTranslate.transX,
- transY = _calRotateTranslate.transY;
-
- context.rotate(-1 * config._xAxisTextAngle_);
- context.translate(transX, transY);
- context.fillText(item, xAxisPoints[index] + offset, startY + xAxisFontSize + 5);
- context.closePath();
- context.stroke();
- context.restore();
- });
- }
- }
- context.restore();
-
-}
-
-function drawYAxisGrid(categories, opts, config, context) {
- if (opts.yAxis.disableGrid === true) {
- return;
- }
- let spacingValid = opts.height - opts.area[0] - opts.area[2];
- let eachSpacing = spacingValid / config.yAxisSplit;
- let startX = opts.area[3];
- let xAxisPoints = opts.chartData.xAxisData.xAxisPoints,
- xAxiseachSpacing = opts.chartData.xAxisData.eachSpacing;
- let TotalWidth = xAxiseachSpacing * (xAxisPoints.length - 1);
- let endX = startX + TotalWidth;
-
- let points = [];
- for (let i = 0; i < config.yAxisSplit + 1; i++) {
- points.push(opts.height - opts.area[2] - eachSpacing * i);
- }
-
- context.save();
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0) {
- context.translate(opts._scrollDistance_, 0);
- }
-
- if (opts.yAxis.gridType == 'dash') {
- context.setLineDash([opts.yAxis.dashLength, opts.yAxis.dashLength]);
- }
- context.setStrokeStyle(opts.yAxis.gridColor || "#cccccc");
- context.setLineWidth(1 * opts.pixelRatio);
- points.forEach(function(item, index) {
- context.beginPath();
- context.moveTo(startX, item);
- context.lineTo(endX, item);
- context.stroke();
- });
- context.setLineDash([]);
-
- context.restore();
-}
-
-function drawYAxis(series, opts, config, context) {
- if (opts.yAxis.disabled === true) {
- return;
- }
- let rangesFormat = opts.chartData.yAxisData.rangesFormat;
- var spacingValid = opts.height - opts.area[0] - opts.area[2];
- var eachSpacing = Math.floor(spacingValid / config.yAxisSplit);
- var startX = opts.area[3];
- var endX = opts.width - opts.area[1];
- var endY = opts.height - opts.area[2];
- var fillEndY = endY + config.xAxisHeight;
- if (opts.xAxis.scrollShow) {
- fillEndY -= 3 * opts.pixelRatio;
- }
- // set YAxis background
- context.beginPath();
- context.setFillStyle(opts.background || '#ffffff');
- if (opts._scrollDistance_ < 0) {
- context.fillRect(0, 0, startX, fillEndY);
- }
- if(opts.enableScroll == true){
- context.fillRect(endX, 0, opts.width, fillEndY);
- }
- context.closePath();
- context.stroke();
-
- var points = [];
- for (var i = 0; i <= config.yAxisSplit; i++) {
- points.push(opts.area[0] + eachSpacing * i);
- }
-
- var yAxisFontSize = opts.yAxis.fontSize || config.fontSize;
- rangesFormat.forEach(function(item, index) {
- var pos = points[index] ? points[index] : endY;
- context.beginPath();
- context.setFontSize(yAxisFontSize);
- context.setFillStyle(opts.yAxis.fontColor || '#666666');
- context.fillText(String(item), opts.area[3] - config.yAxisWidth, pos + yAxisFontSize / 2);
- context.closePath();
- context.stroke();
- });
-
- if (opts.yAxis.title) {
- drawYAxisTitle(opts.yAxis.title, opts, config, context);
- }
-}
-
-function drawLegend(series, opts, config, context, chartData) {
- if (opts.legend.show === false) {
- return;
- }
- let legendData = chartData.legendData;
- let legendList = legendData.points;
- let legendArea = legendData.area;
- let padding = opts.legend.padding;
- let fontSize = opts.legend.fontSize;
- let shapeWidth = 15 * opts.pixelRatio;
- let shapeRight = 5 * opts.pixelRatio;
- let itemGap = opts.legend.itemGap;
- let lineHeight = Math.max(opts.legend.lineHeight * opts.pixelRatio, fontSize);
-
- //画背景及边框
- context.beginPath();
- context.setLineWidth(opts.legend.borderWidth);
- context.setStrokeStyle(opts.legend.borderColor);
- context.setFillStyle(opts.legend.backgroundColor);
- context.moveTo(legendArea.start.x, legendArea.start.y);
- context.rect(legendArea.start.x, legendArea.start.y, legendArea.width, legendArea.height);
- context.closePath();
- context.fill();
- context.stroke();
-
- legendList.forEach(function(itemList, listIndex) {
- let width = 0;
- let height = 0;
- width = legendData.widthArr[listIndex];
- height = legendData.heightArr[listIndex];
- let startX = 0;
- let startY = 0;
- if (opts.legend.position == 'top' || opts.legend.position == 'bottom') {
- startX = legendArea.start.x + (legendArea.width - width) / 2;
- startY = legendArea.start.y + padding + listIndex * lineHeight;
- } else {
- if (listIndex == 0) {
- width = 0;
- } else {
- width = legendData.widthArr[listIndex - 1];
- }
- startX = legendArea.start.x + padding + width;
- startY = legendArea.start.y + padding + (legendArea.height - height) / 2;
- }
-
- context.setFontSize(config.fontSize);
- for (let i = 0; i < itemList.length; i++) {
- let item = itemList[i];
- item.area = [0, 0, 0, 0];
- item.area[0] = startX;
- item.area[1] = startY;
- item.area[3] = startY + lineHeight;
- context.beginPath();
- context.setLineWidth(1 * opts.pixelRatio);
- context.setStrokeStyle(item.show ? item.color : opts.legend.hiddenColor);
- context.setFillStyle(item.show ? item.color : opts.legend.hiddenColor);
- switch (item.legendShape) {
- case 'line':
- context.moveTo(startX, startY + 0.5 * lineHeight - 2 * opts.pixelRatio);
- context.fillRect(startX, startY + 0.5 * lineHeight - 2 * opts.pixelRatio, 15 * opts.pixelRatio, 4 * opts.pixelRatio);
- break;
- case 'triangle':
- context.moveTo(startX + 7.5 * opts.pixelRatio, startY + 0.5 * lineHeight - 5 * opts.pixelRatio);
- context.lineTo(startX + 2.5 * opts.pixelRatio, startY + 0.5 * lineHeight + 5 * opts.pixelRatio);
- context.lineTo(startX + 12.5 * opts.pixelRatio, startY + 0.5 * lineHeight + 5 * opts.pixelRatio);
- context.lineTo(startX + 7.5 * opts.pixelRatio, startY + 0.5 * lineHeight - 5 * opts.pixelRatio);
- break;
- case 'diamond':
- context.moveTo(startX + 7.5 * opts.pixelRatio, startY + 0.5 * lineHeight - 5 * opts.pixelRatio);
- context.lineTo(startX + 2.5 * opts.pixelRatio, startY + 0.5 * lineHeight);
- context.lineTo(startX + 7.5 * opts.pixelRatio, startY + 0.5 * lineHeight + 5 * opts.pixelRatio);
- context.lineTo(startX + 12.5 * opts.pixelRatio, startY + 0.5 * lineHeight);
- context.lineTo(startX + 7.5 * opts.pixelRatio, startY + 0.5 * lineHeight - 5 * opts.pixelRatio);
- break;
- case 'circle':
- context.moveTo(startX + 7.5 * opts.pixelRatio, startY + 0.5 * lineHeight);
- context.arc(startX + 7.5 * opts.pixelRatio, startY + 0.5 * lineHeight, 5 * opts.pixelRatio, 0, 2 * Math.PI);
- break;
- case 'rect':
- context.moveTo(startX, startY + 0.5 * lineHeight - 5 * opts.pixelRatio);
- context.fillRect(startX, startY + 0.5 * lineHeight - 5 * opts.pixelRatio, 15 * opts.pixelRatio, 10 * opts.pixelRatio);
- break;
- default:
- context.moveTo(startX, startY + 0.5 * lineHeight - 5 * opts.pixelRatio);
- context.fillRect(startX, startY + 0.5 * lineHeight - 5 * opts.pixelRatio, 15 * opts.pixelRatio, 10 * opts.pixelRatio);
- }
- context.closePath();
- context.fill();
- context.stroke();
-
- startX += shapeWidth + shapeRight;
- let fontTrans = 0.5 * lineHeight + 0.5 * fontSize - 2;
- context.beginPath();
- context.setFontSize(fontSize);
- context.setFillStyle(item.show ? opts.legend.fontColor : opts.legend.hiddenColor);
- context.fillText(item.name, startX, startY + fontTrans);
- context.closePath();
- context.stroke();
- if (opts.legend.position == 'top' || opts.legend.position == 'bottom') {
- startX += measureText(item.name, fontSize) + itemGap;
- item.area[2] = startX;
- } else {
- item.area[2] = startX + measureText(item.name, fontSize) + itemGap;;
- startX -= shapeWidth + shapeRight;
- startY += lineHeight;
- }
- }
- });
-}
-
-function drawPieDataPoints(series, opts, config, context) {
- var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
- var pieOption = assign({}, {
- activeOpacity: 0.5,
- activeRadius: 10 * opts.pixelRatio,
- offsetAngle: 0,
- labelWidth: 15 * opts.pixelRatio,
- ringWidth: 0,
- border:false,
- borderWidth:2,
- borderColor:'#FFFFFF'
- }, opts.extra.pie);
- var centerPosition = {
- x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2,
- y: opts.area[0] + (opts.height - opts.area[0] - opts.area[2]) / 2
- };
- if (config.pieChartLinePadding == 0) {
- config.pieChartLinePadding = pieOption.activeRadius;
- }
-
- var radius = Math.min((opts.width - opts.area[1] - opts.area[3]) / 2 - config.pieChartLinePadding - config.pieChartTextPadding - config._pieTextMaxLength_, (opts.height - opts.area[0] - opts.area[2]) / 2 - config.pieChartLinePadding - config.pieChartTextPadding);
-
- series = getPieDataPoints(series, radius, process);
-
- var activeRadius = pieOption.activeRadius;
-
- series = series.map(function(eachSeries) {
- eachSeries._start_ += (pieOption.offsetAngle) * Math.PI / 180;
- return eachSeries;
- });
- series.forEach(function(eachSeries, seriesIndex) {
- if (opts.tooltip) {
- if (opts.tooltip.index == seriesIndex) {
- context.beginPath();
- context.setFillStyle(hexToRgb(eachSeries.color, opts.extra.pie.activeOpacity || 0.5));
- context.moveTo(centerPosition.x, centerPosition.y);
- context.arc(centerPosition.x, centerPosition.y, eachSeries._radius_ + activeRadius, eachSeries._start_,
- eachSeries._start_ + 2 *
- eachSeries._proportion_ * Math.PI);
- context.closePath();
- context.fill();
- }
- }
- context.beginPath();
- context.setLineWidth(pieOption.borderWidth * opts.pixelRatio);
- context.lineJoin = "round";
- context.setStrokeStyle(pieOption.borderColor);
- context.setFillStyle(eachSeries.color);
- context.moveTo(centerPosition.x, centerPosition.y);
- context.arc(centerPosition.x, centerPosition.y, eachSeries._radius_, eachSeries._start_, eachSeries._start_ + 2 * eachSeries._proportion_ * Math.PI);
- context.closePath();
- context.fill();
- if (pieOption.border == true) {
- context.stroke();
- }
- });
-
- if (opts.type === 'ring') {
- var innerPieWidth = radius * 0.6;
- if (typeof opts.extra.pie.ringWidth === 'number' && opts.extra.pie.ringWidth > 0) {
- innerPieWidth = Math.max(0, radius - opts.extra.pie.ringWidth);
- }
- context.beginPath();
- context.setFillStyle(opts.background || '#ffffff');
- context.moveTo(centerPosition.x, centerPosition.y);
- context.arc(centerPosition.x, centerPosition.y, innerPieWidth, 0, 2 * Math.PI);
- context.closePath();
- context.fill();
- }
-
- if (opts.dataLabel !== false && process === 1) {
- var valid = false;
- for (var i = 0, len = series.length; i < len; i++) {
- if (series[i].data > 0) {
- valid = true;
- break;
- }
- }
-
- if (valid) {
- drawPieText(series, opts, config, context, radius, centerPosition);
- }
- }
-
- if (process === 1 && opts.type === 'ring') {
- drawRingTitle(opts, config, context, centerPosition);
- }
-
- return {
- center: centerPosition,
- radius: radius,
- series: series
- };
-}
-
-function drawRoseDataPoints(series, opts, config, context) {
- var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
- var roseOption = assign({}, {
- type: 'area',
- activeOpacity: 0.5,
- activeRadius: 10 * opts.pixelRatio,
- offsetAngle: 0,
- labelWidth: 15 * opts.pixelRatio,
- border:false,
- borderWidth:2,
- borderColor:'#FFFFFF'
- }, opts.extra.rose);
- if (config.pieChartLinePadding == 0) {
- config.pieChartLinePadding = roseOption.activeRadius;
- }
- var centerPosition = {
- x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2,
- y: opts.area[0] + (opts.height - opts.area[0] - opts.area[2]) / 2
- };
- var radius = Math.min((opts.width - opts.area[1] - opts.area[3]) / 2 - config.pieChartLinePadding - config.pieChartTextPadding - config._pieTextMaxLength_, (opts.height - opts.area[0] - opts.area[2]) / 2 - config.pieChartLinePadding - config.pieChartTextPadding);
- var minRadius = roseOption.minRadius || radius * 0.5;
-
- series = getRoseDataPoints(series, roseOption.type, minRadius, radius, process);
-
- var activeRadius = roseOption.activeRadius;
-
- series = series.map(function(eachSeries) {
- eachSeries._start_ += (roseOption.offsetAngle || 0) * Math.PI / 180;
- return eachSeries;
- });
-
- series.forEach(function(eachSeries, seriesIndex) {
- if (opts.tooltip) {
- if (opts.tooltip.index == seriesIndex) {
- context.beginPath();
- context.setFillStyle(hexToRgb(eachSeries.color, roseOption.activeOpacity || 0.5));
- context.moveTo(centerPosition.x, centerPosition.y);
- context.arc(centerPosition.x, centerPosition.y, activeRadius + eachSeries._radius_, eachSeries._start_,
- eachSeries._start_ + 2 * eachSeries._rose_proportion_ * Math.PI);
- context.closePath();
- context.fill();
- }
- }
- context.beginPath();
- context.setLineWidth(roseOption.borderWidth * opts.pixelRatio);
- context.lineJoin = "round";
- context.setStrokeStyle(roseOption.borderColor);
- context.setFillStyle(eachSeries.color);
- context.moveTo(centerPosition.x, centerPosition.y);
- context.arc(centerPosition.x, centerPosition.y, eachSeries._radius_, eachSeries._start_, eachSeries._start_ + 2 *
- eachSeries._rose_proportion_ * Math.PI);
- context.closePath();
- context.fill();
- if (roseOption.border == true) {
- context.stroke();
- }
- });
-
- if (opts.dataLabel !== false && process === 1) {
- var valid = false;
- for (var i = 0, len = series.length; i < len; i++) {
- if (series[i].data > 0) {
- valid = true;
- break;
- }
- }
-
- if (valid) {
- drawPieText(series, opts, config, context, radius, centerPosition);
- }
- }
-
- return {
- center: centerPosition,
- radius: radius,
- series: series
- };
-}
-
-function drawArcbarDataPoints(series, opts, config, context) {
- var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
- var arcbarOption = assign({}, {
- startAngle: 0.75,
- endAngle: 0.25,
- type: 'default',
- width: 12 * opts.pixelRatio
- }, opts.extra.arcbar);
-
- series = getArcbarDataPoints(series, arcbarOption, process);
- var centerPosition = {
- x: opts.width / 2,
- y: opts.height / 2
- };
- var radius = Math.min(centerPosition.x, centerPosition.y);
- radius -= 5 * opts.pixelRatio;
- radius -= arcbarOption.width / 2;
-
- //背景颜色
- context.setLineWidth(arcbarOption.width);
- context.setStrokeStyle(arcbarOption.backgroundColor || '#E9E9E9');
- context.setLineCap('round');
- context.beginPath();
- if (arcbarOption.type == 'default') {
- context.arc(centerPosition.x, centerPosition.y, radius, arcbarOption.startAngle * Math.PI, arcbarOption.endAngle *
- Math.PI, false);
- } else {
- context.arc(centerPosition.x, centerPosition.y, radius, 0, 2 * Math.PI, false);
- }
- context.stroke();
-
- for (let i = 0; i < series.length; i++) {
- let eachSeries = series[i];
- context.setLineWidth(arcbarOption.width);
- context.setStrokeStyle(eachSeries.color);
- context.setLineCap('round');
- context.beginPath();
- context.arc(centerPosition.x, centerPosition.y, radius, arcbarOption.startAngle * Math.PI, eachSeries._proportion_ *
- Math.PI, false);
- context.stroke();
- }
-
- drawRingTitle(opts, config, context, centerPosition);
-
- return {
- center: centerPosition,
- radius: radius,
- series: series
- };
-}
-
-function drawGaugeDataPoints(categories, series, opts, config, context) {
- var process = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1;
- var gaugeOption = assign({}, {
- startAngle: 0.75,
- endAngle: 0.25,
- width: 15,
- splitLine: {
- fixRadius: 0,
- splitNumber: 10,
- width: 15,
- color: '#FFFFFF',
- childNumber: 5,
- childWidth: 5
- },
- pointer: {
- width: 15,
- color: 'auto'
- }
- }, opts.extra.gauge);
-
- if (gaugeOption.oldAngle == undefined) {
- gaugeOption.oldAngle = gaugeOption.startAngle;
- }
- if (gaugeOption.oldData == undefined) {
- gaugeOption.oldData = 0;
- }
- categories = getGaugeAxisPoints(categories, gaugeOption.startAngle, gaugeOption.endAngle);
-
- var centerPosition = {
- x: opts.width / 2,
- y: opts.height / 2
- };
- var radius = Math.min(centerPosition.x, centerPosition.y);
- radius -= 5 * opts.pixelRatio;
- radius -= gaugeOption.width / 2;
- var innerRadius = radius - gaugeOption.width;
-
- //画背景
- context.setLineWidth(gaugeOption.width);
- context.setLineCap('butt');
- for (let i = 0; i < categories.length; i++) {
- let eachCategories = categories[i];
- context.beginPath();
- context.setStrokeStyle(eachCategories.color);
- context.arc(centerPosition.x, centerPosition.y, radius, eachCategories._startAngle_ * Math.PI, eachCategories._endAngle_ *
- Math.PI, false);
- context.stroke();
- }
- context.save();
-
- //画刻度线
- let totalAngle = gaugeOption.startAngle - gaugeOption.endAngle + 1;
- let splitAngle = totalAngle / gaugeOption.splitLine.splitNumber;
- let childAngle = totalAngle / gaugeOption.splitLine.splitNumber / gaugeOption.splitLine.childNumber;
- let startX = -radius - gaugeOption.width * 0.5 - gaugeOption.splitLine.fixRadius;
- let endX = -radius - gaugeOption.width * 0.5 - gaugeOption.splitLine.fixRadius + gaugeOption.splitLine.width;
- let childendX = -radius - gaugeOption.width * 0.5 - gaugeOption.splitLine.fixRadius + gaugeOption.splitLine.childWidth;
-
- context.translate(centerPosition.x, centerPosition.y);
- context.rotate((gaugeOption.startAngle - 1) * Math.PI);
-
- for (let i = 0; i < gaugeOption.splitLine.splitNumber + 1; i++) {
- context.beginPath();
- context.setStrokeStyle(gaugeOption.splitLine.color);
- context.setLineWidth(2 * opts.pixelRatio);
- context.moveTo(startX, 0);
- context.lineTo(endX, 0);
- context.stroke();
- context.rotate(splitAngle * Math.PI);
- }
- context.restore();
-
- context.save();
- context.translate(centerPosition.x, centerPosition.y);
- context.rotate((gaugeOption.startAngle - 1) * Math.PI);
-
- for (let i = 0; i < gaugeOption.splitLine.splitNumber * gaugeOption.splitLine.childNumber + 1; i++) {
- context.beginPath();
- context.setStrokeStyle(gaugeOption.splitLine.color);
- context.setLineWidth(1 * opts.pixelRatio);
- context.moveTo(startX, 0);
- context.lineTo(childendX, 0);
- context.stroke();
- context.rotate(childAngle * Math.PI);
- }
- context.restore();
-
- //画指针
- series = getGaugeDataPoints(series, categories, gaugeOption, process);
-
- for (let i = 0; i < series.length; i++) {
- let eachSeries = series[i];
- context.save();
- context.translate(centerPosition.x, centerPosition.y);
- context.rotate((eachSeries._proportion_ - 1) * Math.PI);
- context.beginPath();
- context.setFillStyle(eachSeries.color);
- context.moveTo(gaugeOption.pointer.width, 0);
- context.lineTo(0, -gaugeOption.pointer.width / 2);
- context.lineTo(-innerRadius, 0);
- context.lineTo(0, gaugeOption.pointer.width / 2);
- context.lineTo(gaugeOption.pointer.width, 0);
- context.closePath();
- context.fill();
- context.beginPath();
- context.setFillStyle('#FFFFFF');
- context.arc(0, 0, gaugeOption.pointer.width / 6, 0, 2 * Math.PI, false);
- context.fill();
- context.restore();
- }
-
- if (opts.dataLabel !== false) {
- drawGaugeLabel(gaugeOption, radius, centerPosition, opts, config, context);
- }
-
- drawRingTitle(opts, config, context, centerPosition);
-
- if (process === 1 && opts.type === 'gauge') {
- opts.extra.gauge.oldAngle = series[0]._proportion_;
- opts.extra.gauge.oldData = series[0].data;
- }
- return {
- center: centerPosition,
- radius: radius,
- innerRadius: innerRadius,
- categories: categories,
- totalAngle: totalAngle
- };
-}
-
-function drawRadarDataPoints(series, opts, config, context) {
- var process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
- var radarOption = assign({},{
- gridColor: '#cccccc',
- labelColor: '#666666',
- opacity: 0.2
- },opts.extra.radar);
-
- var coordinateAngle = getRadarCoordinateSeries(opts.categories.length);
-
- var centerPosition = {
- x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2,
- y: opts.area[0] + (opts.height - opts.area[0] - opts.area[2]) / 2
- };
-
- var radius = Math.min(centerPosition.x - (getMaxTextListLength(opts.categories) + config.radarLabelTextMargin),
- centerPosition.y - config.radarLabelTextMargin);
- //TODO逻辑不对
- radius -= opts.padding[1];
-
- // draw grid
- context.beginPath();
- context.setLineWidth(1 * opts.pixelRatio);
- context.setStrokeStyle(radarOption.gridColor);
- coordinateAngle.forEach(function(angle) {
- var pos = convertCoordinateOrigin(radius * Math.cos(angle), radius * Math.sin(angle), centerPosition);
- context.moveTo(centerPosition.x, centerPosition.y);
- context.lineTo(pos.x, pos.y);
- });
- context.stroke();
- context.closePath();
- // draw split line grid
-
- var _loop = function _loop(i) {
- var startPos = {};
- context.beginPath();
- context.setLineWidth(1 * opts.pixelRatio);
- context.setStrokeStyle(radarOption.gridColor);
- coordinateAngle.forEach(function(angle, index) {
- var pos = convertCoordinateOrigin(radius / config.radarGridCount * i * Math.cos(angle), radius / config.radarGridCount *
- i * Math.sin(angle), centerPosition);
- if (index === 0) {
- startPos = pos;
- context.moveTo(pos.x, pos.y);
- } else {
- context.lineTo(pos.x, pos.y);
- }
- });
- context.lineTo(startPos.x, startPos.y);
- context.stroke();
- context.closePath();
- };
-
- for (var i = 1; i <= config.radarGridCount; i++) {
- _loop(i);
- }
-
- var radarDataPoints = getRadarDataPoints(coordinateAngle, centerPosition, radius, series, opts, process);
-
- radarDataPoints.forEach(function(eachSeries, seriesIndex) {
- // 绘制区域数据
- context.beginPath();
- context.setFillStyle(hexToRgb(eachSeries.color, radarOption.opacity));
- eachSeries.data.forEach(function(item, index) {
- if (index === 0) {
- context.moveTo(item.position.x, item.position.y);
- } else {
- context.lineTo(item.position.x, item.position.y);
- }
- });
- context.closePath();
- context.fill();
-
- if (opts.dataPointShape !== false) {
- var shape = config.dataPointShape[seriesIndex % config.dataPointShape.length];
- var points = eachSeries.data.map(function(item) {
- return item.position;
- });
- drawPointShape(points, eachSeries.color, shape, context, opts);
- }
- });
- // draw label text
- drawRadarLabel(coordinateAngle, radius, centerPosition, opts, config, context);
-
- return {
- center: centerPosition,
- radius: radius,
- angleList: coordinateAngle
- };
-}
-
-function normalInt(min, max, iter) {
- iter = iter==0?1:iter;
- var arr = [];
- for (var i = 0; i < iter; i++) {
- arr[i] = Math.random();
- };
- return Math.floor(arr.reduce(function(i,j){return i+j})/iter*(max-min))+min;
-};
-
-function collisionNew(area,points,width,height){
- var isIn=false;
- for(let i=0;ipoints[i].area[2]||area[1]>points[i].area[3]||area[2]width || area[3]>height){
- isIn=true;
- break;
- }else{
- isIn=false;
- }
- }else{
- isIn=true;
- break;
- }
- }
- }
- return isIn;
-};
-
-function getBoundingBox(data) {
- var bounds = {}, coords;
- bounds.xMin = 180;
- bounds.xMax = 0;
- bounds.yMin = 90;
- bounds.yMax = 0
- for (var i = 0; i < data.length; i++) {
- var coorda = data[i].geometry.coordinates
- for (var k = 0; k < coorda.length; k++) {
- coords = coorda[k];
- if (coords.length == 1) {
- coords = coords[0]
- }
- for (var j = 0; j < coords.length; j++) {
- var longitude = coords[j][0];
- var latitude = coords[j][1];
- var point = {
- x: longitude,
- y: latitude
- }
- bounds.xMin = bounds.xMin < point.x ? bounds.xMin : point.x;
- bounds.xMax = bounds.xMax > point.x ? bounds.xMax : point.x;
- bounds.yMin = bounds.yMin < point.y ? bounds.yMin : point.y;
- bounds.yMax = bounds.yMax > point.y ? bounds.yMax : point.y;
- }
- }
- }
- return bounds;
-}
-
-function coordinateToPoint(latitude, longitude,bounds,scale,xoffset,yoffset) {
- return {
- x: (longitude - bounds.xMin) * scale+xoffset,
- y: (bounds.yMax - latitude) * scale+yoffset
- };
-}
-
-function pointToCoordinate(pointY, pointX,bounds,scale,xoffset,yoffset) {
- return {
- x: (pointX-xoffset)/scale+bounds.xMin,
- y: bounds.yMax - (pointY-yoffset)/scale
- };
-}
-
-function isRayIntersectsSegment(poi,s_poi,e_poi){
- if (s_poi[1]==e_poi[1]){return false;}
- if (s_poi[1]>poi[1] && e_poi[1]>poi[1]){return false;}
- if (s_poi[1]poi[1]){return false;}
- if (e_poi[1]==poi[1] && s_poi[1]>poi[1]){return false;}
- if (s_poi[0]0.7) {
- return true;
- }else {return false};
- };
- for (let i = 0; i < points.length; i++) {
- let text = points[i].name;
- let tHeight = points[i].textSize;
- let tWidth = measureText(text,tHeight);
- let isSpin = Spin();
- let x,y,area,areav;
- let breaknum=0;
- while(true) {
- breaknum++;
- let isCollision;
- if (isSpin) {
- x = normalInt(-opts.width/2, opts.width/2,5) - tWidth/2;
- y = normalInt(-opts.height/2, opts.height/2,5)+tHeight/2;
- area=[y-5-tWidth+opts.width/2,(-x-5+opts.height/2),y+5+opts.width/2,(-x+tHeight+5+opts.height/2)];
- areav=[opts.width-(opts.width/2-opts.height/2)-(-x+tHeight+5+opts.height/2)-5,(opts.height/2-opts.width/2)+(y-5-tWidth+opts.width/2)-5,opts.width-(opts.width/2-opts.height/2)-(-x+tHeight+5+opts.height/2)+tHeight,(opts.height/2-opts.width/2)+(y-5-tWidth+opts.width/2)+tWidth+5];
- isCollision = collisionNew(areav,points,opts.height,opts.width);
- }else{
- x = normalInt(-opts.width/2, opts.width/2,5) - tWidth/2;
- y = normalInt(-opts.height/2, opts.height/2,5)+tHeight/2;
- area=[x-5+opts.width/2,y-5-tHeight+opts.height/2,x+tWidth+5+opts.width/2,y+5+opts.height/2];
- isCollision = collisionNew(area,points,opts.width,opts.height);
- }
- if (!isCollision) break;
- if (breaknum==1000){
- area=[-1000,-1000,-1000,-1000];
- break;
- }
- };
- if (isSpin) {
- points[i].area=areav;
- points[i].areav=area;
- }else{
- points[i].area=area;
- }
- points[i].rotate=isSpin;
- };
- break;
- }
- return points;
-}
-
-
-function drawWordCloudDataPoints(series, opts, config, context) {
- let process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
- let wordOption = assign({},{
- type: 'normal',
- autoColors: true
- },opts.extra.word);
-
- context.beginPath();
- context.setFillStyle(opts.background||'#FFFFFF');
- context.rect(0,0,opts.width,opts.height);
- context.fill();
- context.save();
- let points = opts.chartData.wordCloudData;
- context.translate(opts.width/2,opts.height/2);
-
- for(let i=0;i0){
- if (opts.tooltip) {
- if (opts.tooltip.index == i) {
- context.strokeText(text,(points[i].areav[0]+5-opts.width/2)*process-tWidth*(1-process)/2,(points[i].areav[1]+5+tHeight-opts.height/2)*process);
- }else{
- context.fillText(text,(points[i].areav[0]+5-opts.width/2)*process-tWidth*(1-process)/2,(points[i].areav[1]+5+tHeight-opts.height/2)*process);
- }
- }else{
- context.fillText(text,(points[i].areav[0]+5-opts.width/2)*process-tWidth*(1-process)/2,(points[i].areav[1]+5+tHeight-opts.height/2)*process);
- }
- }
- }else{
- if(points[i].area[0]>0){
- if (opts.tooltip) {
- if (opts.tooltip.index == i) {
- context.strokeText(text,(points[i].area[0]+5-opts.width/2)*process-tWidth*(1-process)/2,(points[i].area[1]+5+tHeight-opts.height/2)*process);
- }else{
- context.fillText(text,(points[i].area[0]+5-opts.width/2)*process-tWidth*(1-process)/2,(points[i].area[1]+5+tHeight-opts.height/2)*process);
- }
- }else{
- context.fillText(text,(points[i].area[0]+5-opts.width/2)*process-tWidth*(1-process)/2,(points[i].area[1]+5+tHeight-opts.height/2)*process);
- }
-
- }
- }
-
- context.stroke();
- context.restore();
- }
- context.restore();
-}
-
-function drawFunnelDataPoints(series, opts, config, context) {
- let process = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
- let funnelOption = assign({},{
- activeWidth:10,
- activeOpacity:0.3,
- border:false,
- borderWidth:2,
- borderColor:'#FFFFFF',
- fillOpacity:1,
- labelAlign:'right'
- },opts.extra.funnel);
- let eachSpacing = (opts.height - opts.area[0] - opts.area[2])/series.length;
- let centerPosition = {
- x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2,
- y: opts.height-opts.area[2]
- };
- let activeWidth = funnelOption.activeWidth;
- let radius = Math.min((opts.width - opts.area[1] - opts.area[3]) / 2 - activeWidth, (opts.height - opts.area[0] - opts.area[2]) / 2 - activeWidth);
- series = getFunnelDataPoints(series, radius, process);
- context.save();
- context.translate(centerPosition.x,centerPosition.y);
- for(let i=0;i 0 && arguments[0] !== undefined ? arguments[0] : {};
- this.opts = assign({}, this.opts, data);
- this.opts.updateData = true;
- let scrollPosition = data.scrollPosition || 'current';
- switch (scrollPosition) {
- case 'current':
- this.opts._scrollDistance_ = this.scrollOption.currentOffset;
- break;
- case 'left':
- this.opts._scrollDistance_ = 0;
- this.scrollOption = {
- currentOffset: 0,
- startTouchX: 0,
- distance: 0,
- lastMoveTime: 0
- };
- break;
- case 'right':
- let _calYAxisData = calYAxisData(this.opts.series, this.opts, this.config),
- yAxisWidth = _calYAxisData.yAxisWidth;
- this.config.yAxisWidth = yAxisWidth;
- let offsetLeft = 0;
- let _getXAxisPoints0 = getXAxisPoints(this.opts.categories, this.opts, this.config),
- xAxisPoints = _getXAxisPoints0.xAxisPoints,
- startX = _getXAxisPoints0.startX,
- endX = _getXAxisPoints0.endX,
- eachSpacing = _getXAxisPoints0.eachSpacing;
- let totalWidth = eachSpacing * (xAxisPoints.length - 1);
- let screenWidth = endX - startX;
- offsetLeft = screenWidth - totalWidth;
- this.scrollOption = {
- currentOffset: offsetLeft,
- startTouchX: offsetLeft,
- distance: 0,
- lastMoveTime: 0
- };
- this.opts._scrollDistance_ = offsetLeft;
- break;
- }
- drawCharts.call(this, this.opts.type, this.opts, this.config, this.context);
-};
-
-Charts.prototype.zoom = function() {
- var val = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.opts.xAxis.itemCount;
- if (this.opts.enableScroll !== true) {
- console.log('请启用滚动条后使用!')
- return;
- }
- //当前屏幕中间点
- let centerPoint = Math.round(Math.abs(this.scrollOption.currentOffset) / this.opts.chartData.eachSpacing) + Math.round(
- this.opts.xAxis.itemCount / 2);
- this.opts.animation = false;
- this.opts.xAxis.itemCount = val.itemCount;
- //重新计算x轴偏移距离
- let _calYAxisData = calYAxisData(this.opts.series, this.opts, this.config),
- yAxisWidth = _calYAxisData.yAxisWidth;
- this.config.yAxisWidth = yAxisWidth;
- let offsetLeft = 0;
- let _getXAxisPoints0 = getXAxisPoints(this.opts.categories, this.opts, this.config),
- xAxisPoints = _getXAxisPoints0.xAxisPoints,
- startX = _getXAxisPoints0.startX,
- endX = _getXAxisPoints0.endX,
- eachSpacing = _getXAxisPoints0.eachSpacing;
- let centerLeft = eachSpacing * centerPoint;
- let screenWidth = endX - startX;
- let MaxLeft = screenWidth - eachSpacing * (xAxisPoints.length - 1);
- offsetLeft = screenWidth / 2 - centerLeft;
- if (offsetLeft > 0) {
- offsetLeft = 0;
- }
- if (offsetLeft < MaxLeft) {
- offsetLeft = MaxLeft;
- }
- this.scrollOption = {
- currentOffset: offsetLeft,
- startTouchX: offsetLeft,
- distance: 0,
- lastMoveTime: 0
- };
- this.opts._scrollDistance_ = offsetLeft;
- drawCharts.call(this, this.opts.type, this.opts, this.config, this.context);
-};
-
-Charts.prototype.stopAnimation = function() {
- this.animationInstance && this.animationInstance.stop();
-};
-
-Charts.prototype.addEventListener = function(type, listener) {
- this.event.addEventListener(type, listener);
-};
-
-Charts.prototype.getCurrentDataIndex = function(e) {
- var touches = null;
- if (e.changedTouches) {
- touches = e.changedTouches[0];
- } else {
- touches = e.mp.changedTouches[0];
- }
- if (touches) {
- let _touches$ = getTouches(touches, this.opts, e);
- if (this.opts.type === 'pie' || this.opts.type === 'ring' || this.opts.type === 'rose') {
- return findPieChartCurrentIndex({
- x: _touches$.x,
- y: _touches$.y
- }, this.opts.chartData.pieData);
- } else if (this.opts.type === 'radar') {
- return findRadarChartCurrentIndex({
- x: _touches$.x,
- y: _touches$.y
- }, this.opts.chartData.radarData, this.opts.categories.length);
- } else if (this.opts.type === 'funnel') {
- return findFunnelChartCurrentIndex({
- x: _touches$.x,
- y: _touches$.y
- }, this.opts.chartData.funnelData);
- } else if (this.opts.type === 'map') {
- return findMapChartCurrentIndex({
- x: _touches$.x,
- y: _touches$.y
- }, this.opts);
- }else if (this.opts.type === 'word') {
- return findWordChartCurrentIndex({
- x: _touches$.x,
- y: _touches$.y
- }, this.opts.chartData.wordCloudData);
- } else {
- return findCurrentIndex({
- x: _touches$.x,
- y: _touches$.y
- }, this.opts.chartData.xAxisPoints, this.opts, this.config, Math.abs(this.scrollOption.currentOffset));
- }
- }
- return -1;
-};
-
-Charts.prototype.getLegendDataIndex = function(e) {
- var touches = null;
- if (e.changedTouches) {
- touches = e.changedTouches[0];
- } else {
- touches = e.mp.changedTouches[0];
- }
- if (touches) {
- let _touches$ = getTouches(touches, this.opts, e);
- return findLegendIndex({
- x: _touches$.x,
- y: _touches$.y
- }, this.opts.chartData.legendData);
- }
- return -1;
-};
-
-Charts.prototype.touchLegend = function(e) {
- var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var touches = null;
- if (e.changedTouches) {
- touches = e.changedTouches[0];
- } else {
- touches = e.mp.changedTouches[0];
- }
- if (touches) {
- var _touches$ = getTouches(touches, this.opts, e);
- var index = this.getLegendDataIndex(e);
- if (index >= 0) {
- this.opts.series[index].show = !this.opts.series[index].show;
- this.opts.animation = option.animation ? true : false;
- drawCharts.call(this, this.opts.type, this.opts, this.config, this.context);
- }
- }
-
-};
-
-Charts.prototype.showToolTip = function(e) {
- var option = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
- var touches = null;
- if (e.changedTouches) {
- touches = e.changedTouches[0];
- } else {
- touches = e.mp.changedTouches[0];
- }
- if (!touches) {
- console.log("touchError");
- }
- var _touches$ = getTouches(touches, this.opts, e);
- var currentOffset = this.scrollOption.currentOffset;
- var opts = assign({}, this.opts, {
- _scrollDistance_: currentOffset,
- animation: false
- });
- if (this.opts.type === 'line' || this.opts.type === 'area' || this.opts.type === 'column') {
- var index = this.getCurrentDataIndex(e);
- if (index > -1) {
- var seriesData = getSeriesDataItem(this.opts.series, index);
- if (seriesData.length !== 0) {
- var _getToolTipData = getToolTipData(seriesData, this.opts.chartData.calPoints, index, this.opts.categories,option),
- textList = _getToolTipData.textList,
- offset = _getToolTipData.offset;
- offset.y = _touches$.y;
- opts.tooltip = {
- textList: textList,
- offset: offset,
- option: option,
- index: index
- };
- }
- }
- drawCharts.call(this, opts.type, opts, this.config, this.context);
- }
- if (this.opts.type === 'mix') {
- var index = this.getCurrentDataIndex(e);
- if (index > -1) {
- var currentOffset = this.scrollOption.currentOffset;
- var opts = assign({}, this.opts, {
- _scrollDistance_: currentOffset,
- animation: false
- });
- var seriesData = getSeriesDataItem(this.opts.series, index);
- if (seriesData.length !== 0) {
- var _getMixToolTipData = getMixToolTipData(seriesData, this.opts.chartData.calPoints, index, this.opts.categories,option),
- textList = _getMixToolTipData.textList,
- offset = _getMixToolTipData.offset;
- offset.y = _touches$.y;
- opts.tooltip = {
- textList: textList,
- offset: offset,
- option: option,
- index: index
- };
- }
- }
- drawCharts.call(this, opts.type, opts, this.config, this.context);
- }
- if (this.opts.type === 'candle') {
- var index = this.getCurrentDataIndex(e);
- if (index > -1) {
- var currentOffset = this.scrollOption.currentOffset;
- var opts = assign({}, this.opts, {
- _scrollDistance_: currentOffset,
- animation: false
- });
- var seriesData = getSeriesDataItem(this.opts.series, index);
- if (seriesData.length !== 0) {
- var _getToolTipData = getCandleToolTipData(this.opts.series[0].data, seriesData, this.opts.chartData.calPoints,
- index, this.opts.categories, this.opts.extra.candle, option),
- textList = _getToolTipData.textList,
- offset = _getToolTipData.offset;
- offset.y = _touches$.y;
- opts.tooltip = {
- textList: textList,
- offset: offset,
- option: option,
- index: index
- };
- }
- }
- drawCharts.call(this, opts.type, opts, this.config, this.context);
- }
- if (this.opts.type === 'pie' || this.opts.type === 'ring' || this.opts.type === 'rose'||this.opts.type === 'funnel' ) {
- var index = this.getCurrentDataIndex(e);
- if (index > -1) {
- var currentOffset = this.scrollOption.currentOffset;
- var opts = assign({}, this.opts, {
- _scrollDistance_: currentOffset,
- animation: false
- });
- var seriesData = this.opts._series_[index];
- var textList = [{
- text: option.format ? option.format(seriesData) : seriesData.name + ': ' + seriesData.data,
- color: seriesData.color
- }];
- var offset = {
- x: _touches$.x,
- y: _touches$.y
- };
- opts.tooltip = {
- textList: textList,
- offset: offset,
- option: option,
- index: index
- };
- }
- drawCharts.call(this, opts.type, opts, this.config, this.context);
- }
- if (this.opts.type === 'map'||this.opts.type === 'word') {
- var index = this.getCurrentDataIndex(e);
- if (index > -1) {
- var currentOffset = this.scrollOption.currentOffset;
- var opts = assign({}, this.opts, {
- _scrollDistance_: currentOffset,
- animation: false
- });
- var seriesData = this.opts._series_[index];
- var textList = [{
- text: option.format ? option.format(seriesData) : seriesData.properties.name ,
- color: seriesData.color
- }];
- var offset = {
- x: _touches$.x,
- y: _touches$.y
- };
- opts.tooltip = {
- textList: textList,
- offset: offset,
- option: option,
- index: index
- };
- }
- opts.updateData = false;
- drawCharts.call(this, opts.type, opts, this.config, this.context);
- }
- if (this.opts.type === 'radar') {
- var index = this.getCurrentDataIndex(e);
- if (index > -1) {
- var currentOffset = this.scrollOption.currentOffset;
- var opts = assign({}, this.opts, {
- _scrollDistance_: currentOffset,
- animation: false
- });
- var seriesData = getSeriesDataItem(this.opts.series, index);
- if (seriesData.length !== 0) {
- var textList = seriesData.map(function(item) {
- return {
- text: option.format ? option.format(item) : item.name + ': ' + item.data,
- color: item.color
- };
- });
- var offset = {
- x: _touches$.x,
- y: _touches$.y
- };
- opts.tooltip = {
- textList: textList,
- offset: offset,
- option: option,
- index: index
- };
- }
- }
- drawCharts.call(this, opts.type, opts, this.config, this.context);
- }
-};
-
-Charts.prototype.translate = function(distance) {
- this.scrollOption = {
- currentOffset: distance,
- startTouchX: distance,
- distance: 0,
- lastMoveTime: 0
- };
- let opts = assign({}, this.opts, {
- _scrollDistance_: distance,
- animation: false
- });
- drawCharts.call(this, this.opts.type, opts, this.config, this.context);
-};
-
-Charts.prototype.scrollStart = function(e) {
- var touches = null;
- if (e.changedTouches) {
- touches = e.changedTouches[0];
- } else {
- touches = e.mp.changedTouches[0];
- }
- var _touches$ = getTouches(touches, this.opts, e);
- if (touches && this.opts.enableScroll === true) {
- this.scrollOption.startTouchX = _touches$.x;
- }
-};
-
-Charts.prototype.scroll = function(e) {
- if (this.scrollOption.lastMoveTime === 0) {
- this.scrollOption.lastMoveTime = Date.now();
- }
- let Limit = this.opts.extra.touchMoveLimit || 20;
- let currMoveTime = Date.now();
- let duration = currMoveTime - this.scrollOption.lastMoveTime;
- if (duration < Math.floor(1000 / Limit)) return;
- this.scrollOption.lastMoveTime = currMoveTime;
- var touches = null;
- if (e.changedTouches) {
- touches = e.changedTouches[0];
- } else {
- touches = e.mp.changedTouches[0];
- }
- if (touches && this.opts.enableScroll === true) {
- var _touches$ = getTouches(touches, this.opts, e);
- var _distance;
- _distance = _touches$.x - this.scrollOption.startTouchX;
- var currentOffset = this.scrollOption.currentOffset;
- var validDistance = calValidDistance(currentOffset + _distance, this.opts.chartData, this.config, this.opts);
- this.scrollOption.distance = _distance = validDistance - currentOffset;
- var opts = assign({}, this.opts, {
- _scrollDistance_: currentOffset + _distance,
- animation: false
- });
- drawCharts.call(this, opts.type, opts, this.config, this.context);
- return currentOffset + _distance;
- }
-};
-
-Charts.prototype.scrollEnd = function(e) {
- if (this.opts.enableScroll === true) {
- var _scrollOption = this.scrollOption,
- currentOffset = _scrollOption.currentOffset,
- distance = _scrollOption.distance;
- this.scrollOption.currentOffset = currentOffset + distance;
- this.scrollOption.distance = 0;
- }
-};
-if (typeof module === "object" && typeof module.exports === "object") {
- module.exports = Charts;
- //export default Charts;//建议使用nodejs的module导出方式,如报错请使用export方式导出
-}
diff --git a/fe/PDA/components/u-link/u-link.vue b/fe/PDA/components/u-link/u-link.vue
deleted file mode 100644
index de56c4110..000000000
--- a/fe/PDA/components/u-link/u-link.vue
+++ /dev/null
@@ -1,59 +0,0 @@
-
- {{text}}
-
-
-
-
-
diff --git a/fe/PDA/components/uni-data-select/changelog.md b/fe/PDA/components/uni-data-select/changelog.md
new file mode 100644
index 000000000..016e3d2f6
--- /dev/null
+++ b/fe/PDA/components/uni-data-select/changelog.md
@@ -0,0 +1,39 @@
+## 1.0.8(2024-03-28)
+- 修复 在vue2下:style动态绑定导致编译失败的bug
+## 1.0.7(2024-01-20)
+- 修复 长文本回显超过容器的bug,超过容器部分显示省略号
+## 1.0.6(2023-04-12)
+- 修复 微信小程序点击时会改变背景颜色的 bug
+## 1.0.5(2023-02-03)
+- 修复 禁用时会显示清空按钮
+## 1.0.4(2023-02-02)
+- 优化 查询条件短期内多次变更只查询最后一次变更后的结果
+- 调整 内部缓存键名调整为 uni-data-select-lastSelectedValue
+## 1.0.3(2023-01-16)
+- 修复 不关联服务空间报错的问题
+## 1.0.2(2023-01-14)
+- 新增 属性 `format` 可用于格式化显示选项内容
+## 1.0.1(2022-12-06)
+- 修复 当where变化时,数据不会自动更新的问题
+## 0.1.9(2022-09-05)
+- 修复 微信小程序下拉框出现后选择会点击到蒙板后面的输入框
+## 0.1.8(2022-08-29)
+- 修复 点击的位置不准确
+## 0.1.7(2022-08-12)
+- 新增 支持 disabled 属性
+## 0.1.6(2022-07-06)
+- 修复 pc端宽度异常的bug
+## 0.1.5
+- 修复 pc端宽度异常的bug
+## 0.1.4(2022-07-05)
+- 优化 显示样式
+## 0.1.3(2022-06-02)
+- 修复 localdata 赋值不生效的 bug
+- 新增 支持 uni.scss 修改颜色
+- 新增 支持选项禁用(数据选项设置 disabled: true 即禁用)
+## 0.1.2(2022-05-08)
+- 修复 当 value 为 0 时选择不生效的 bug
+## 0.1.1(2022-05-07)
+- 新增 记住上次的选项(仅 collection 存在时有效)
+## 0.1.0(2022-04-22)
+- 初始化
diff --git a/fe/PDA/components/uni-data-select/components/uni-data-select/uni-data-select.vue b/fe/PDA/components/uni-data-select/components/uni-data-select/uni-data-select.vue
new file mode 100644
index 000000000..edab65a61
--- /dev/null
+++ b/fe/PDA/components/uni-data-select/components/uni-data-select/uni-data-select.vue
@@ -0,0 +1,562 @@
+
+
+ {{label + ':'}}
+
+
+
+ {{textShow}}
+ {{typePlaceholder}}
+
+
+
+
+
+
+
+
+
+
+
+
+ {{emptyTips}}
+
+
+ {{formatItemName(item)}}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/components/uni-data-select/package.json b/fe/PDA/components/uni-data-select/package.json
new file mode 100644
index 000000000..5864594ef
--- /dev/null
+++ b/fe/PDA/components/uni-data-select/package.json
@@ -0,0 +1,86 @@
+{
+ "id": "uni-data-select",
+ "displayName": "uni-data-select 下拉框选择器",
+ "version": "1.0.8",
+ "description": "通过数据驱动的下拉框选择器",
+ "keywords": [
+ "uni-ui",
+ "select",
+ "uni-data-select",
+ "下拉框",
+ "下拉选"
+],
+ "repository": "https://github.com/dcloudio/uni-ui",
+ "engines": {
+ "HBuilderX": "^3.1.1"
+ },
+ "directories": {
+ "example": "../../temps/example_temps"
+ },
+"dcloudext": {
+ "sale": {
+ "regular": {
+ "price": "0.00"
+ },
+ "sourcecode": {
+ "price": "0.00"
+ }
+ },
+ "contact": {
+ "qq": ""
+ },
+ "declaration": {
+ "ads": "无",
+ "data": "无",
+ "permissions": "无"
+ },
+ "npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui",
+ "type": "component-vue"
+ },
+ "uni_modules": {
+ "dependencies": ["uni-load-more"],
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "y",
+ "aliyun": "y",
+ "alipay": "n"
+ },
+ "client": {
+ "App": {
+ "app-vue": "u",
+ "app-nvue": "n"
+ },
+ "H5-mobile": {
+ "Safari": "y",
+ "Android Browser": "y",
+ "微信浏览器(Android)": "y",
+ "QQ浏览器(Android)": "y"
+ },
+ "H5-pc": {
+ "Chrome": "y",
+ "IE": "y",
+ "Edge": "y",
+ "Firefox": "y",
+ "Safari": "y"
+ },
+ "小程序": {
+ "微信": "y",
+ "阿里": "u",
+ "百度": "u",
+ "字节跳动": "u",
+ "QQ": "u",
+ "京东": "u"
+ },
+ "快应用": {
+ "华为": "u",
+ "联盟": "u"
+ },
+ "Vue": {
+ "vue2": "y",
+ "vue3": "y"
+ }
+ }
+ }
+ }
+}
diff --git a/fe/PDA/components/uni-data-select/readme.md b/fe/PDA/components/uni-data-select/readme.md
new file mode 100644
index 000000000..eb58de300
--- /dev/null
+++ b/fe/PDA/components/uni-data-select/readme.md
@@ -0,0 +1,8 @@
+## DataSelect 下拉框选择器
+> **组件名:uni-data-select**
+> 代码块: `uDataSelect`
+
+当选项过多时,使用下拉菜单展示并选择内容
+
+### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-data-select)
+#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
diff --git a/fe/PDA/components/uni-data-select/uni-data-select.vue b/fe/PDA/components/uni-data-select/uni-data-select.vue
new file mode 100644
index 000000000..edab65a61
--- /dev/null
+++ b/fe/PDA/components/uni-data-select/uni-data-select.vue
@@ -0,0 +1,562 @@
+
+
+ {{label + ':'}}
+
+
+
+ {{textShow}}
+ {{typePlaceholder}}
+
+
+
+
+
+
+
+
+
+
+
+
+ {{emptyTips}}
+
+
+ {{formatItemName(item)}}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/components/uni-tag/uni-tag.vue b/fe/PDA/components/uni-tag/uni-tag.vue
index 93f6372e9..f0f9caf94 100644
--- a/fe/PDA/components/uni-tag/uni-tag.vue
+++ b/fe/PDA/components/uni-tag/uni-tag.vue
@@ -116,8 +116,9 @@
/* #ifdef APP-NVUE */
align-self: flex-start;
/* #endif */
- padding: 0px 16px;
- line-height: 30px;
+ /* padding: 0px 16px; */
+ padding: 8rpx;
+ line-height: 50rpx;
color: #333;
border-radius: 3px;
background-color: #f8f8f8;
diff --git a/fe/PDA/main.js b/fe/PDA/main.js
index a7df16dd5..5ffd766e4 100644
--- a/fe/PDA/main.js
+++ b/fe/PDA/main.js
@@ -5,6 +5,8 @@ import request from './common/request.js'
import url from './common/config.js'
import modelConfig from './common/modelConfig.js'
import utils from './common/utils.js'
+import uView from "./uni_modules/uview-ui";
+
// import message from "@/common/message";
import axios from 'axios';
let startApp = function() {
@@ -44,6 +46,7 @@ import {
Vue.use(barcode)
Vue.use(VueAxios, axios)
+Vue.use(uView);
Vue.prototype.$request = request
Vue.prototype.$url = url.url_config
diff --git a/fe/PDA/mycomponents/common/comMessage.vue b/fe/PDA/mycomponents/common/comMessage.vue
index a26f2b955..b75e72ed9 100644
--- a/fe/PDA/mycomponents/common/comMessage.vue
+++ b/fe/PDA/mycomponents/common/comMessage.vue
@@ -4,7 +4,7 @@
@@ -186,8 +196,15 @@
finishCountJob,
getBalancesByFilterAsync,
getitems,
- locationsAsync
+ locationsAsync,
+ getCountJobList
} from '@/api/index.js';
+
+ import {
+ simulationReqGetList,
+ getDataList
+ } from "./mock.js"
+
import {
getJobStatuStyle,
getJobStatuDesc,
@@ -265,7 +282,9 @@
loadingType: "",
currentPage: 0,
pageSize: 20,
- jobStatus:""
+ jobStatus:"",
+ candidates: ['北京', '南京', '东京', '武汉', '天津', '上海', '海口'],
+ city: '',
// array: [{
// text: '待检',
// value: 1
@@ -285,10 +304,37 @@
// text: '冻结',
// value: 6
// }],
+ radioDataList: [],
+ dataForm: {
+ radio: '',
+ checkbox: [],
+ checkbox2: []
+ }
}
},
props: {},
onLoad: function(param) {
+ // this.radioDataList = getDataList()
+
+ let params = {
+ pageSize:20,
+ pageIndex: 1
+ };
+ getCountJobList(params)
+ .then(res => {
+ var list = res.items;
+
+ this.radioDataList=list;
+ })
+ .catch(err => {
+ this.loadingType = "";
+ this.showMessage(err.message);
+ uni.hideLoading();
+ if (type === "refresh") {
+ uni.stopPullDownRefresh();
+ }
+ });
+
this.id = param.id;
if (param.jobStatus == 1) {
this.receive((callback => {
@@ -366,6 +412,13 @@
})
},
methods: {
+ reqGetList(data) {
+ return simulationReqGetList({
+ pageIndex: data.pageIndex,
+ pageSize: data.pageSize,
+ name: data.searchValue
+ })
+ },
getDetail() {
uni.showLoading({
title: '加载中...',
diff --git a/fe/PDA/pages/task/injectionIssueJob.vue b/fe/PDA/pages/task/injectionIssueJob.vue
index 5db39b1ad..a40fe5714 100644
--- a/fe/PDA/pages/task/injectionIssueJob.vue
+++ b/fe/PDA/pages/task/injectionIssueJob.vue
@@ -4,7 +4,7 @@
-
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-alert-tips/u-alert-tips.vue b/fe/PDA/uni_modules/uview-ui/components/u-alert-tips/u-alert-tips.vue
new file mode 100644
index 000000000..e81fc3797
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-alert-tips/u-alert-tips.vue
@@ -0,0 +1,256 @@
+
+
+
+
+
+
+
+ {{title}}
+
+
+ {{description}}
+
+
+
+
+
+ {{closeText}}
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-avatar-cropper/u-avatar-cropper.vue b/fe/PDA/uni_modules/uview-ui/components/u-avatar-cropper/u-avatar-cropper.vue
new file mode 100644
index 000000000..a48dd5464
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-avatar-cropper/u-avatar-cropper.vue
@@ -0,0 +1,290 @@
+
+
+
+
+
+
+
+
+ 选择图片
+
+
+ 重新选择
+
+ 确定
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-avatar-cropper/weCropper.js b/fe/PDA/uni_modules/uview-ui/components/u-avatar-cropper/weCropper.js
new file mode 100644
index 000000000..df0248386
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-avatar-cropper/weCropper.js
@@ -0,0 +1,1265 @@
+/**
+ * we-cropper v1.3.9
+ * (c) 2020 dlhandsome
+ * @license MIT
+ */
+(function(global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
+ typeof define === 'function' && define.amd ? define(factory) :
+ (global.WeCropper = factory());
+}(this, (function() {
+ 'use strict';
+
+ var device = void 0;
+ var TOUCH_STATE = ['touchstarted', 'touchmoved', 'touchended'];
+
+ function firstLetterUpper(str) {
+ return str.charAt(0).toUpperCase() + str.slice(1)
+ }
+
+ function setTouchState(instance) {
+ var arg = [],
+ len = arguments.length - 1;
+ while (len-- > 0) arg[len] = arguments[len + 1];
+
+ TOUCH_STATE.forEach(function(key, i) {
+ if (arg[i] !== undefined) {
+ instance[key] = arg[i];
+ }
+ });
+ }
+
+ function validator(instance, o) {
+ Object.defineProperties(instance, o);
+ }
+
+ function getDevice() {
+ if (!device) {
+ device = uni.getSystemInfoSync();
+ }
+ return device
+ }
+
+ var tmp = {};
+
+ var ref = getDevice();
+ var pixelRatio = ref.pixelRatio;
+
+ var DEFAULT = {
+ id: {
+ default: 'cropper',
+ get: function get() {
+ return tmp.id
+ },
+ set: function set(value) {
+ if (typeof(value) !== 'string') {
+ console.error(("id:" + value + " is invalid"));
+ }
+ tmp.id = value;
+ }
+ },
+ width: {
+ default: 750,
+ get: function get() {
+ return tmp.width
+ },
+ set: function set(value) {
+ if (typeof(value) !== 'number') {
+ console.error(("width:" + value + " is invalid"));
+ }
+ tmp.width = value;
+ }
+ },
+ height: {
+ default: 750,
+ get: function get() {
+ return tmp.height
+ },
+ set: function set(value) {
+ if (typeof(value) !== 'number') {
+ console.error(("height:" + value + " is invalid"));
+ }
+ tmp.height = value;
+ }
+ },
+ pixelRatio: {
+ default: pixelRatio,
+ get: function get() {
+ return tmp.pixelRatio
+ },
+ set: function set(value) {
+ if (typeof(value) !== 'number') {
+ console.error(("pixelRatio:" + value + " is invalid"));
+ }
+ tmp.pixelRatio = value;
+ }
+ },
+ scale: {
+ default: 2.5,
+ get: function get() {
+ return tmp.scale
+ },
+ set: function set(value) {
+ if (typeof(value) !== 'number') {
+ console.error(("scale:" + value + " is invalid"));
+ }
+ tmp.scale = value;
+ }
+ },
+ zoom: {
+ default: 5,
+ get: function get() {
+ return tmp.zoom
+ },
+ set: function set(value) {
+ if (typeof(value) !== 'number') {
+ console.error(("zoom:" + value + " is invalid"));
+ } else if (value < 0 || value > 10) {
+ console.error("zoom should be ranged in 0 ~ 10");
+ }
+ tmp.zoom = value;
+ }
+ },
+ src: {
+ default: '',
+ get: function get() {
+ return tmp.src
+ },
+ set: function set(value) {
+ if (typeof(value) !== 'string') {
+ console.error(("src:" + value + " is invalid"));
+ }
+ tmp.src = value;
+ }
+ },
+ cut: {
+ default: {},
+ get: function get() {
+ return tmp.cut
+ },
+ set: function set(value) {
+ if (typeof(value) !== 'object') {
+ console.error(("cut:" + value + " is invalid"));
+ }
+ tmp.cut = value;
+ }
+ },
+ boundStyle: {
+ default: {},
+ get: function get() {
+ return tmp.boundStyle
+ },
+ set: function set(value) {
+ if (typeof(value) !== 'object') {
+ console.error(("boundStyle:" + value + " is invalid"));
+ }
+ tmp.boundStyle = value;
+ }
+ },
+ onReady: {
+ default: null,
+ get: function get() {
+ return tmp.ready
+ },
+ set: function set(value) {
+ tmp.ready = value;
+ }
+ },
+ onBeforeImageLoad: {
+ default: null,
+ get: function get() {
+ return tmp.beforeImageLoad
+ },
+ set: function set(value) {
+ tmp.beforeImageLoad = value;
+ }
+ },
+ onImageLoad: {
+ default: null,
+ get: function get() {
+ return tmp.imageLoad
+ },
+ set: function set(value) {
+ tmp.imageLoad = value;
+ }
+ },
+ onBeforeDraw: {
+ default: null,
+ get: function get() {
+ return tmp.beforeDraw
+ },
+ set: function set(value) {
+ tmp.beforeDraw = value;
+ }
+ }
+ };
+
+ var ref$1 = getDevice();
+ var windowWidth = ref$1.windowWidth;
+
+ function prepare() {
+ var self = this;
+
+ // v1.4.0 版本中将不再自动绑定we-cropper实例
+ self.attachPage = function() {
+ var pages = getCurrentPages();
+ // 获取到当前page上下文
+ var pageContext = pages[pages.length - 1];
+ // 把this依附在Page上下文的wecropper属性上,便于在page钩子函数中访问
+ Object.defineProperty(pageContext, 'wecropper', {
+ get: function get() {
+ console.warn(
+ 'Instance will not be automatically bound to the page after v1.4.0\n\n' +
+ 'Please use a custom instance name instead\n\n' +
+ 'Example: \n' +
+ 'this.mycropper = new WeCropper(options)\n\n' +
+ '// ...\n' +
+ 'this.mycropper.getCropperImage()'
+ );
+ return self
+ },
+ configurable: true
+ });
+ };
+
+ self.createCtx = function() {
+ var id = self.id;
+ var targetId = self.targetId;
+
+ if (id) {
+ self.ctx = self.ctx || uni.createCanvasContext(id);
+ self.targetCtx = self.targetCtx || uni.createCanvasContext(targetId);
+ } else {
+ console.error("constructor: create canvas context failed, 'id' must be valuable");
+ }
+ };
+
+ self.deviceRadio = windowWidth / 750;
+ }
+
+ var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !==
+ 'undefined' ? self : {};
+
+
+
+
+
+ function createCommonjsModule(fn, module) {
+ return module = {
+ exports: {}
+ }, fn(module, module.exports), module.exports;
+ }
+
+ var tools = createCommonjsModule(function(module, exports) {
+ /**
+ * String type check
+ */
+ exports.isStr = function(v) {
+ return typeof v === 'string';
+ };
+ /**
+ * Number type check
+ */
+ exports.isNum = function(v) {
+ return typeof v === 'number';
+ };
+ /**
+ * Array type check
+ */
+ exports.isArr = Array.isArray;
+ /**
+ * undefined type check
+ */
+ exports.isUndef = function(v) {
+ return v === undefined;
+ };
+
+ exports.isTrue = function(v) {
+ return v === true;
+ };
+
+ exports.isFalse = function(v) {
+ return v === false;
+ };
+ /**
+ * Function type check
+ */
+ exports.isFunc = function(v) {
+ return typeof v === 'function';
+ };
+ /**
+ * Quick object check - this is primarily used to tell
+ * Objects from primitive values when we know the value
+ * is a JSON-compliant type.
+ */
+ exports.isObj = exports.isObject = function(obj) {
+ return obj !== null && typeof obj === 'object'
+ };
+
+ /**
+ * Strict object type check. Only returns true
+ * for plain JavaScript objects.
+ */
+ var _toString = Object.prototype.toString;
+ exports.isPlainObject = function(obj) {
+ return _toString.call(obj) === '[object Object]'
+ };
+
+ /**
+ * Check whether the object has the property.
+ */
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+ exports.hasOwn = function(obj, key) {
+ return hasOwnProperty.call(obj, key)
+ };
+
+ /**
+ * Perform no operation.
+ * Stubbing args to make Flow happy without leaving useless transpiled code
+ * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/)
+ */
+ exports.noop = function(a, b, c) {};
+
+ /**
+ * Check if val is a valid array index.
+ */
+ exports.isValidArrayIndex = function(val) {
+ var n = parseFloat(String(val));
+ return n >= 0 && Math.floor(n) === n && isFinite(val)
+ };
+ });
+
+ var tools_7 = tools.isFunc;
+ var tools_10 = tools.isPlainObject;
+
+ var EVENT_TYPE = ['ready', 'beforeImageLoad', 'beforeDraw', 'imageLoad'];
+
+ function observer() {
+ var self = this;
+
+ self.on = function(event, fn) {
+ if (EVENT_TYPE.indexOf(event) > -1) {
+ if (tools_7(fn)) {
+ event === 'ready' ?
+ fn(self) :
+ self[("on" + (firstLetterUpper(event)))] = fn;
+ }
+ } else {
+ console.error(("event: " + event + " is invalid"));
+ }
+ return self
+ };
+ }
+
+ function wxPromise(fn) {
+ return function(obj) {
+ var args = [],
+ len = arguments.length - 1;
+ while (len-- > 0) args[len] = arguments[len + 1];
+
+ if (obj === void 0) obj = {};
+ return new Promise(function(resolve, reject) {
+ obj.success = function(res) {
+ resolve(res);
+ };
+ obj.fail = function(err) {
+ reject(err);
+ };
+ fn.apply(void 0, [obj].concat(args));
+ })
+ }
+ }
+
+ function draw(ctx, reserve) {
+ if (reserve === void 0) reserve = false;
+
+ return new Promise(function(resolve) {
+ ctx.draw(reserve, resolve);
+ })
+ }
+
+ var getImageInfo = wxPromise(uni.getImageInfo);
+
+ var canvasToTempFilePath = wxPromise(uni.canvasToTempFilePath);
+
+ var base64 = createCommonjsModule(function(module, exports) {
+ /*! http://mths.be/base64 v0.1.0 by @mathias | MIT license */
+ (function(root) {
+
+ // Detect free variables `exports`.
+ var freeExports = 'object' == 'object' && exports;
+
+ // Detect free variable `module`.
+ var freeModule = 'object' == 'object' && module &&
+ module.exports == freeExports && module;
+
+ // Detect free variable `global`, from Node.js or Browserified code, and use
+ // it as `root`.
+ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal;
+ if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
+ root = freeGlobal;
+ }
+
+ /*--------------------------------------------------------------------------*/
+
+ var InvalidCharacterError = function(message) {
+ this.message = message;
+ };
+ InvalidCharacterError.prototype = new Error;
+ InvalidCharacterError.prototype.name = 'InvalidCharacterError';
+
+ var error = function(message) {
+ // Note: the error messages used throughout this file match those used by
+ // the native `atob`/`btoa` implementation in Chromium.
+ throw new InvalidCharacterError(message);
+ };
+
+ var TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
+ // http://whatwg.org/html/common-microsyntaxes.html#space-character
+ var REGEX_SPACE_CHARACTERS = /[\t\n\f\r ]/g;
+
+ // `decode` is designed to be fully compatible with `atob` as described in the
+ // HTML Standard. http://whatwg.org/html/webappapis.html#dom-windowbase64-atob
+ // The optimized base64-decoding algorithm used is based on @atk’s excellent
+ // implementation. https://gist.github.com/atk/1020396
+ var decode = function(input) {
+ input = String(input)
+ .replace(REGEX_SPACE_CHARACTERS, '');
+ var length = input.length;
+ if (length % 4 == 0) {
+ input = input.replace(/==?$/, '');
+ length = input.length;
+ }
+ if (
+ length % 4 == 1 ||
+ // http://whatwg.org/C#alphanumeric-ascii-characters
+ /[^+a-zA-Z0-9/]/.test(input)
+ ) {
+ error(
+ 'Invalid character: the string to be decoded is not correctly encoded.'
+ );
+ }
+ var bitCounter = 0;
+ var bitStorage;
+ var buffer;
+ var output = '';
+ var position = -1;
+ while (++position < length) {
+ buffer = TABLE.indexOf(input.charAt(position));
+ bitStorage = bitCounter % 4 ? bitStorage * 64 + buffer : buffer;
+ // Unless this is the first of a group of 4 characters…
+ if (bitCounter++ % 4) {
+ // …convert the first 8 bits to a single ASCII character.
+ output += String.fromCharCode(
+ 0xFF & bitStorage >> (-2 * bitCounter & 6)
+ );
+ }
+ }
+ return output;
+ };
+
+ // `encode` is designed to be fully compatible with `btoa` as described in the
+ // HTML Standard: http://whatwg.org/html/webappapis.html#dom-windowbase64-btoa
+ var encode = function(input) {
+ input = String(input);
+ if (/[^\0-\xFF]/.test(input)) {
+ // Note: no need to special-case astral symbols here, as surrogates are
+ // matched, and the input is supposed to only contain ASCII anyway.
+ error(
+ 'The string to be encoded contains characters outside of the ' +
+ 'Latin1 range.'
+ );
+ }
+ var padding = input.length % 3;
+ var output = '';
+ var position = -1;
+ var a;
+ var b;
+ var c;
+ var buffer;
+ // Make sure any padding is handled outside of the loop.
+ var length = input.length - padding;
+
+ while (++position < length) {
+ // Read three bytes, i.e. 24 bits.
+ a = input.charCodeAt(position) << 16;
+ b = input.charCodeAt(++position) << 8;
+ c = input.charCodeAt(++position);
+ buffer = a + b + c;
+ // Turn the 24 bits into four chunks of 6 bits each, and append the
+ // matching character for each of them to the output.
+ output += (
+ TABLE.charAt(buffer >> 18 & 0x3F) +
+ TABLE.charAt(buffer >> 12 & 0x3F) +
+ TABLE.charAt(buffer >> 6 & 0x3F) +
+ TABLE.charAt(buffer & 0x3F)
+ );
+ }
+
+ if (padding == 2) {
+ a = input.charCodeAt(position) << 8;
+ b = input.charCodeAt(++position);
+ buffer = a + b;
+ output += (
+ TABLE.charAt(buffer >> 10) +
+ TABLE.charAt((buffer >> 4) & 0x3F) +
+ TABLE.charAt((buffer << 2) & 0x3F) +
+ '='
+ );
+ } else if (padding == 1) {
+ buffer = input.charCodeAt(position);
+ output += (
+ TABLE.charAt(buffer >> 2) +
+ TABLE.charAt((buffer << 4) & 0x3F) +
+ '=='
+ );
+ }
+
+ return output;
+ };
+
+ var base64 = {
+ 'encode': encode,
+ 'decode': decode,
+ 'version': '0.1.0'
+ };
+
+ // Some AMD build optimizers, like r.js, check for specific condition patterns
+ // like the following:
+ if (
+ typeof undefined == 'function' &&
+ typeof undefined.amd == 'object' &&
+ undefined.amd
+ ) {
+ undefined(function() {
+ return base64;
+ });
+ } else if (freeExports && !freeExports.nodeType) {
+ if (freeModule) { // in Node.js or RingoJS v0.8.0+
+ freeModule.exports = base64;
+ } else { // in Narwhal or RingoJS v0.7.0-
+ for (var key in base64) {
+ base64.hasOwnProperty(key) && (freeExports[key] = base64[key]);
+ }
+ }
+ } else { // in Rhino or a web browser
+ root.base64 = base64;
+ }
+
+ }(commonjsGlobal));
+ });
+
+ function makeURI(strData, type) {
+ return 'data:' + type + ';base64,' + strData
+ }
+
+ function fixType(type) {
+ type = type.toLowerCase().replace(/jpg/i, 'jpeg');
+ var r = type.match(/png|jpeg|bmp|gif/)[0];
+ return 'image/' + r
+ }
+
+ function encodeData(data) {
+ var str = '';
+ if (typeof data === 'string') {
+ str = data;
+ } else {
+ for (var i = 0; i < data.length; i++) {
+ str += String.fromCharCode(data[i]);
+ }
+ }
+ return base64.encode(str)
+ }
+
+ /**
+ * 获取图像区域隐含的像素数据
+ * @param canvasId canvas标识
+ * @param x 将要被提取的图像数据矩形区域的左上角 x 坐标
+ * @param y 将要被提取的图像数据矩形区域的左上角 y 坐标
+ * @param width 将要被提取的图像数据矩形区域的宽度
+ * @param height 将要被提取的图像数据矩形区域的高度
+ * @param done 完成回调
+ */
+ function getImageData(canvasId, x, y, width, height, done) {
+ uni.canvasGetImageData({
+ canvasId: canvasId,
+ x: x,
+ y: y,
+ width: width,
+ height: height,
+ success: function success(res) {
+ done(res, null);
+ },
+ fail: function fail(res) {
+ done(null, res);
+ }
+ });
+ }
+
+ /**
+ * 生成bmp格式图片
+ * 按照规则生成图片响应头和响应体
+ * @param oData 用来描述 canvas 区域隐含的像素数据 { data, width, height } = oData
+ * @returns {*} base64字符串
+ */
+ function genBitmapImage(oData) {
+ //
+ // BITMAPFILEHEADER: http://msdn.microsoft.com/en-us/library/windows/desktop/dd183374(v=vs.85).aspx
+ // BITMAPINFOHEADER: http://msdn.microsoft.com/en-us/library/dd183376.aspx
+ //
+ var biWidth = oData.width;
+ var biHeight = oData.height;
+ var biSizeImage = biWidth * biHeight * 3;
+ var bfSize = biSizeImage + 54; // total header size = 54 bytes
+
+ //
+ // typedef struct tagBITMAPFILEHEADER {
+ // WORD bfType;
+ // DWORD bfSize;
+ // WORD bfReserved1;
+ // WORD bfReserved2;
+ // DWORD bfOffBits;
+ // } BITMAPFILEHEADER;
+ //
+ var BITMAPFILEHEADER = [
+ // WORD bfType -- The file type signature; must be "BM"
+ 0x42, 0x4D,
+ // DWORD bfSize -- The size, in bytes, of the bitmap file
+ bfSize & 0xff, bfSize >> 8 & 0xff, bfSize >> 16 & 0xff, bfSize >> 24 & 0xff,
+ // WORD bfReserved1 -- Reserved; must be zero
+ 0, 0,
+ // WORD bfReserved2 -- Reserved; must be zero
+ 0, 0,
+ // DWORD bfOffBits -- The offset, in bytes, from the beginning of the BITMAPFILEHEADER structure to the bitmap bits.
+ 54, 0, 0, 0
+ ];
+
+ //
+ // typedef struct tagBITMAPINFOHEADER {
+ // DWORD biSize;
+ // LONG biWidth;
+ // LONG biHeight;
+ // WORD biPlanes;
+ // WORD biBitCount;
+ // DWORD biCompression;
+ // DWORD biSizeImage;
+ // LONG biXPelsPerMeter;
+ // LONG biYPelsPerMeter;
+ // DWORD biClrUsed;
+ // DWORD biClrImportant;
+ // } BITMAPINFOHEADER, *PBITMAPINFOHEADER;
+ //
+ var BITMAPINFOHEADER = [
+ // DWORD biSize -- The number of bytes required by the structure
+ 40, 0, 0, 0,
+ // LONG biWidth -- The width of the bitmap, in pixels
+ biWidth & 0xff, biWidth >> 8 & 0xff, biWidth >> 16 & 0xff, biWidth >> 24 & 0xff,
+ // LONG biHeight -- The height of the bitmap, in pixels
+ biHeight & 0xff, biHeight >> 8 & 0xff, biHeight >> 16 & 0xff, biHeight >> 24 & 0xff,
+ // WORD biPlanes -- The number of planes for the target device. This value must be set to 1
+ 1, 0,
+ // WORD biBitCount -- The number of bits-per-pixel, 24 bits-per-pixel -- the bitmap
+ // has a maximum of 2^24 colors (16777216, Truecolor)
+ 24, 0,
+ // DWORD biCompression -- The type of compression, BI_RGB (code 0) -- uncompressed
+ 0, 0, 0, 0,
+ // DWORD biSizeImage -- The size, in bytes, of the image. This may be set to zero for BI_RGB bitmaps
+ biSizeImage & 0xff, biSizeImage >> 8 & 0xff, biSizeImage >> 16 & 0xff, biSizeImage >> 24 & 0xff,
+ // LONG biXPelsPerMeter, unused
+ 0, 0, 0, 0,
+ // LONG biYPelsPerMeter, unused
+ 0, 0, 0, 0,
+ // DWORD biClrUsed, the number of color indexes of palette, unused
+ 0, 0, 0, 0,
+ // DWORD biClrImportant, unused
+ 0, 0, 0, 0
+ ];
+
+ var iPadding = (4 - ((biWidth * 3) % 4)) % 4;
+
+ var aImgData = oData.data;
+
+ var strPixelData = '';
+ var biWidth4 = biWidth << 2;
+ var y = biHeight;
+ var fromCharCode = String.fromCharCode;
+
+ do {
+ var iOffsetY = biWidth4 * (y - 1);
+ var strPixelRow = '';
+ for (var x = 0; x < biWidth; x++) {
+ var iOffsetX = x << 2;
+ strPixelRow += fromCharCode(aImgData[iOffsetY + iOffsetX + 2]) +
+ fromCharCode(aImgData[iOffsetY + iOffsetX + 1]) +
+ fromCharCode(aImgData[iOffsetY + iOffsetX]);
+ }
+
+ for (var c = 0; c < iPadding; c++) {
+ strPixelRow += String.fromCharCode(0);
+ }
+
+ strPixelData += strPixelRow;
+ } while (--y)
+
+ var strEncoded = encodeData(BITMAPFILEHEADER.concat(BITMAPINFOHEADER)) + encodeData(strPixelData);
+
+ return strEncoded
+ }
+
+ /**
+ * 转换为图片base64
+ * @param canvasId canvas标识
+ * @param x 将要被提取的图像数据矩形区域的左上角 x 坐标
+ * @param y 将要被提取的图像数据矩形区域的左上角 y 坐标
+ * @param width 将要被提取的图像数据矩形区域的宽度
+ * @param height 将要被提取的图像数据矩形区域的高度
+ * @param type 转换图片类型
+ * @param done 完成回调
+ */
+ function convertToImage(canvasId, x, y, width, height, type, done) {
+ if (done === void 0) done = function() {};
+
+ if (type === undefined) {
+ type = 'png';
+ }
+ type = fixType(type);
+ if (/bmp/.test(type)) {
+ getImageData(canvasId, x, y, width, height, function(data, err) {
+ var strData = genBitmapImage(data);
+ tools_7(done) && done(makeURI(strData, 'image/' + type), err);
+ });
+ } else {
+ console.error('暂不支持生成\'' + type + '\'类型的base64图片');
+ }
+ }
+
+ var CanvasToBase64 = {
+ convertToImage: convertToImage,
+ // convertToPNG: function (width, height, done) {
+ // return convertToImage(width, height, 'png', done)
+ // },
+ // convertToJPEG: function (width, height, done) {
+ // return convertToImage(width, height, 'jpeg', done)
+ // },
+ // convertToGIF: function (width, height, done) {
+ // return convertToImage(width, height, 'gif', done)
+ // },
+ convertToBMP: function(ref, done) {
+ if (ref === void 0) ref = {};
+ var canvasId = ref.canvasId;
+ var x = ref.x;
+ var y = ref.y;
+ var width = ref.width;
+ var height = ref.height;
+ if (done === void 0) done = function() {};
+
+ return convertToImage(canvasId, x, y, width, height, 'bmp', done)
+ }
+ };
+
+ function methods() {
+ var self = this;
+
+ var boundWidth = self.width; // 裁剪框默认宽度,即整个画布宽度
+ var boundHeight = self.height; // 裁剪框默认高度,即整个画布高度
+
+ var id = self.id;
+ var targetId = self.targetId;
+ var pixelRatio = self.pixelRatio;
+
+ var ref = self.cut;
+ var x = ref.x;
+ if (x === void 0) x = 0;
+ var y = ref.y;
+ if (y === void 0) y = 0;
+ var width = ref.width;
+ if (width === void 0) width = boundWidth;
+ var height = ref.height;
+ if (height === void 0) height = boundHeight;
+
+ self.updateCanvas = function(done) {
+ if (self.croperTarget) {
+ // 画布绘制图片
+ self.ctx.drawImage(
+ self.croperTarget,
+ self.imgLeft,
+ self.imgTop,
+ self.scaleWidth,
+ self.scaleHeight
+ );
+ }
+ tools_7(self.onBeforeDraw) && self.onBeforeDraw(self.ctx, self);
+
+ self.setBoundStyle(self.boundStyle); // 设置边界样式
+
+ self.ctx.draw(false, done);
+ return self
+ };
+
+ self.pushOrigin = self.pushOrign = function(src) {
+ self.src = src;
+
+ tools_7(self.onBeforeImageLoad) && self.onBeforeImageLoad(self.ctx, self);
+
+ return getImageInfo({
+ src: src
+ })
+ .then(function(res) {
+ var innerAspectRadio = res.width / res.height;
+ var customAspectRadio = width / height;
+
+ self.croperTarget = res.path;
+
+ if (innerAspectRadio < customAspectRadio) {
+ self.rectX = x;
+ self.baseWidth = width;
+ self.baseHeight = width / innerAspectRadio;
+ self.rectY = y - Math.abs((height - self.baseHeight) / 2);
+ } else {
+ self.rectY = y;
+ self.baseWidth = height * innerAspectRadio;
+ self.baseHeight = height;
+ self.rectX = x - Math.abs((width - self.baseWidth) / 2);
+ }
+
+ self.imgLeft = self.rectX;
+ self.imgTop = self.rectY;
+ self.scaleWidth = self.baseWidth;
+ self.scaleHeight = self.baseHeight;
+
+ self.update();
+
+ return new Promise(function(resolve) {
+ self.updateCanvas(resolve);
+ })
+ })
+ .then(function() {
+ tools_7(self.onImageLoad) && self.onImageLoad(self.ctx, self);
+ })
+ };
+
+ self.removeImage = function() {
+ self.src = '';
+ self.croperTarget = '';
+ return draw(self.ctx)
+ };
+
+ self.getCropperBase64 = function(done) {
+ if (done === void 0) done = function() {};
+
+ CanvasToBase64.convertToBMP({
+ canvasId: id,
+ x: x,
+ y: y,
+ width: width,
+ height: height
+ }, done);
+ };
+
+ self.getCropperImage = function(opt, fn) {
+ var customOptions = opt;
+
+ var canvasOptions = {
+ canvasId: id,
+ x: x,
+ y: y,
+ width: width,
+ height: height
+ };
+
+ var task = function() {
+ return Promise.resolve();
+ };
+
+ if (
+ tools_10(customOptions) &&
+ customOptions.original
+ ) {
+ // original mode
+ task = function() {
+ self.targetCtx.drawImage(
+ self.croperTarget,
+ self.imgLeft * pixelRatio,
+ self.imgTop * pixelRatio,
+ self.scaleWidth * pixelRatio,
+ self.scaleHeight * pixelRatio
+ );
+
+ canvasOptions = {
+ canvasId: targetId,
+ x: x * pixelRatio,
+ y: y * pixelRatio,
+ width: width * pixelRatio,
+ height: height * pixelRatio
+ };
+
+ return draw(self.targetCtx)
+ };
+ }
+
+ return task()
+ .then(function() {
+ if (tools_10(customOptions)) {
+ canvasOptions = Object.assign({}, canvasOptions, customOptions);
+ }
+
+ if (tools_7(customOptions)) {
+ fn = customOptions;
+ }
+
+ var arg = canvasOptions.componentContext ?
+ [canvasOptions, canvasOptions.componentContext] :
+ [canvasOptions];
+
+ return canvasToTempFilePath.apply(null, arg)
+ })
+ .then(function(res) {
+ var tempFilePath = res.tempFilePath;
+
+ return tools_7(fn) ?
+ fn.call(self, tempFilePath, null) :
+ tempFilePath
+ })
+ .catch(function(err) {
+ if (tools_7(fn)) {
+ fn.call(self, null, err);
+ } else {
+ throw err
+ }
+ })
+ };
+ }
+
+ /**
+ * 获取最新缩放值
+ * @param oldScale 上一次触摸结束后的缩放值
+ * @param oldDistance 上一次触摸结束后的双指距离
+ * @param zoom 缩放系数
+ * @param touch0 第一指touch对象
+ * @param touch1 第二指touch对象
+ * @returns {*}
+ */
+ var getNewScale = function(oldScale, oldDistance, zoom, touch0, touch1) {
+ var xMove, yMove, newDistance;
+ // 计算二指最新距离
+ xMove = Math.round(touch1.x - touch0.x);
+ yMove = Math.round(touch1.y - touch0.y);
+ newDistance = Math.round(Math.sqrt(xMove * xMove + yMove * yMove));
+
+ return oldScale + 0.001 * zoom * (newDistance - oldDistance)
+ };
+
+ function update() {
+ var self = this;
+
+ if (!self.src) {
+ return
+ }
+
+ self.__oneTouchStart = function(touch) {
+ self.touchX0 = Math.round(touch.x);
+ self.touchY0 = Math.round(touch.y);
+ };
+
+ self.__oneTouchMove = function(touch) {
+ var xMove, yMove;
+ // 计算单指移动的距离
+ if (self.touchended) {
+ return self.updateCanvas()
+ }
+ xMove = Math.round(touch.x - self.touchX0);
+ yMove = Math.round(touch.y - self.touchY0);
+
+ var imgLeft = Math.round(self.rectX + xMove);
+ var imgTop = Math.round(self.rectY + yMove);
+
+ self.outsideBound(imgLeft, imgTop);
+
+ self.updateCanvas();
+ };
+
+ self.__twoTouchStart = function(touch0, touch1) {
+ var xMove, yMove, oldDistance;
+
+ self.touchX1 = Math.round(self.rectX + self.scaleWidth / 2);
+ self.touchY1 = Math.round(self.rectY + self.scaleHeight / 2);
+
+ // 计算两指距离
+ xMove = Math.round(touch1.x - touch0.x);
+ yMove = Math.round(touch1.y - touch0.y);
+ oldDistance = Math.round(Math.sqrt(xMove * xMove + yMove * yMove));
+
+ self.oldDistance = oldDistance;
+ };
+
+ self.__twoTouchMove = function(touch0, touch1) {
+ var oldScale = self.oldScale;
+ var oldDistance = self.oldDistance;
+ var scale = self.scale;
+ var zoom = self.zoom;
+
+ self.newScale = getNewScale(oldScale, oldDistance, zoom, touch0, touch1);
+
+ // 设定缩放范围
+ self.newScale <= 1 && (self.newScale = 1);
+ self.newScale >= scale && (self.newScale = scale);
+
+ self.scaleWidth = Math.round(self.newScale * self.baseWidth);
+ self.scaleHeight = Math.round(self.newScale * self.baseHeight);
+ var imgLeft = Math.round(self.touchX1 - self.scaleWidth / 2);
+ var imgTop = Math.round(self.touchY1 - self.scaleHeight / 2);
+
+ self.outsideBound(imgLeft, imgTop);
+
+ self.updateCanvas();
+ };
+
+ self.__xtouchEnd = function() {
+ self.oldScale = self.newScale;
+ self.rectX = self.imgLeft;
+ self.rectY = self.imgTop;
+ };
+ }
+
+ var handle = {
+ // 图片手势初始监测
+ touchStart: function touchStart(e) {
+ var self = this;
+ var ref = e.touches;
+ var touch0 = ref[0];
+ var touch1 = ref[1];
+
+ if (!self.src) {
+ return
+ }
+
+ setTouchState(self, true, null, null);
+
+ // 计算第一个触摸点的位置,并参照改点进行缩放
+ self.__oneTouchStart(touch0);
+
+ // 两指手势触发
+ if (e.touches.length >= 2) {
+ self.__twoTouchStart(touch0, touch1);
+ }
+ },
+
+ // 图片手势动态缩放
+ touchMove: function touchMove(e) {
+ var self = this;
+ var ref = e.touches;
+ var touch0 = ref[0];
+ var touch1 = ref[1];
+
+ if (!self.src) {
+ return
+ }
+
+ setTouchState(self, null, true);
+
+ // 单指手势时触发
+ if (e.touches.length === 1) {
+ self.__oneTouchMove(touch0);
+ }
+ // 两指手势触发
+ if (e.touches.length >= 2) {
+ self.__twoTouchMove(touch0, touch1);
+ }
+ },
+
+ touchEnd: function touchEnd(e) {
+ var self = this;
+
+ if (!self.src) {
+ return
+ }
+
+ setTouchState(self, false, false, true);
+ self.__xtouchEnd();
+ }
+ };
+
+ function cut() {
+ var self = this;
+ var boundWidth = self.width; // 裁剪框默认宽度,即整个画布宽度
+ var boundHeight = self.height;
+ // 裁剪框默认高度,即整个画布高度
+ var ref = self.cut;
+ var x = ref.x;
+ if (x === void 0) x = 0;
+ var y = ref.y;
+ if (y === void 0) y = 0;
+ var width = ref.width;
+ if (width === void 0) width = boundWidth;
+ var height = ref.height;
+ if (height === void 0) height = boundHeight;
+
+ /**
+ * 设置边界
+ * @param imgLeft 图片左上角横坐标值
+ * @param imgTop 图片左上角纵坐标值
+ */
+ self.outsideBound = function(imgLeft, imgTop) {
+ self.imgLeft = imgLeft >= x ?
+ x :
+ self.scaleWidth + imgLeft - x <= width ?
+ x + width - self.scaleWidth :
+ imgLeft;
+
+ self.imgTop = imgTop >= y ?
+ y :
+ self.scaleHeight + imgTop - y <= height ?
+ y + height - self.scaleHeight :
+ imgTop;
+ };
+
+ /**
+ * 设置边界样式
+ * @param color 边界颜色
+ */
+ self.setBoundStyle = function(ref) {
+ if (ref === void 0) ref = {};
+ var color = ref.color;
+ if (color === void 0) color = '#04b00f';
+ var mask = ref.mask;
+ if (mask === void 0) mask = 'rgba(0, 0, 0, 0.3)';
+ var lineWidth = ref.lineWidth;
+ if (lineWidth === void 0) lineWidth = 1;
+
+ var half = lineWidth / 2;
+ var boundOption = [{
+ start: {
+ x: x - half,
+ y: y + 10 - half
+ },
+ step1: {
+ x: x - half,
+ y: y - half
+ },
+ step2: {
+ x: x + 10 - half,
+ y: y - half
+ }
+ },
+ {
+ start: {
+ x: x - half,
+ y: y + height - 10 + half
+ },
+ step1: {
+ x: x - half,
+ y: y + height + half
+ },
+ step2: {
+ x: x + 10 - half,
+ y: y + height + half
+ }
+ },
+ {
+ start: {
+ x: x + width - 10 + half,
+ y: y - half
+ },
+ step1: {
+ x: x + width + half,
+ y: y - half
+ },
+ step2: {
+ x: x + width + half,
+ y: y + 10 - half
+ }
+ },
+ {
+ start: {
+ x: x + width + half,
+ y: y + height - 10 + half
+ },
+ step1: {
+ x: x + width + half,
+ y: y + height + half
+ },
+ step2: {
+ x: x + width - 10 + half,
+ y: y + height + half
+ }
+ }
+ ];
+
+ // 绘制半透明层
+ self.ctx.beginPath();
+ self.ctx.setFillStyle(mask);
+ self.ctx.fillRect(0, 0, x, boundHeight);
+ self.ctx.fillRect(x, 0, width, y);
+ self.ctx.fillRect(x, y + height, width, boundHeight - y - height);
+ self.ctx.fillRect(x + width, 0, boundWidth - x - width, boundHeight);
+ self.ctx.fill();
+
+ boundOption.forEach(function(op) {
+ self.ctx.beginPath();
+ self.ctx.setStrokeStyle(color);
+ self.ctx.setLineWidth(lineWidth);
+ self.ctx.moveTo(op.start.x, op.start.y);
+ self.ctx.lineTo(op.step1.x, op.step1.y);
+ self.ctx.lineTo(op.step2.x, op.step2.y);
+ self.ctx.stroke();
+ });
+ };
+ }
+
+ var version = "1.3.9";
+
+ var WeCropper = function WeCropper(params) {
+ var self = this;
+ var _default = {};
+
+ validator(self, DEFAULT);
+
+ Object.keys(DEFAULT).forEach(function(key) {
+ _default[key] = DEFAULT[key].default;
+ });
+ Object.assign(self, _default, params);
+
+ self.prepare();
+ self.attachPage();
+ self.createCtx();
+ self.observer();
+ self.cutt();
+ self.methods();
+ self.init();
+ self.update();
+
+ return self
+ };
+
+ WeCropper.prototype.init = function init() {
+ var self = this;
+ var src = self.src;
+
+ self.version = version;
+
+ typeof self.onReady === 'function' && self.onReady(self.ctx, self);
+
+ if (src) {
+ self.pushOrign(src);
+ } else {
+ self.updateCanvas();
+ }
+ setTouchState(self, false, false, false);
+
+ self.oldScale = 1;
+ self.newScale = 1;
+
+ return self
+ };
+
+ Object.assign(WeCropper.prototype, handle);
+
+ WeCropper.prototype.prepare = prepare;
+ WeCropper.prototype.observer = observer;
+ WeCropper.prototype.methods = methods;
+ WeCropper.prototype.cutt = cut;
+ WeCropper.prototype.update = update;
+
+ return WeCropper;
+
+})));
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-avatar/u-avatar.vue b/fe/PDA/uni_modules/uview-ui/components/u-avatar/u-avatar.vue
new file mode 100644
index 000000000..289b9b029
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-avatar/u-avatar.vue
@@ -0,0 +1,244 @@
+
+
+
+ {{uText}}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-back-top/u-back-top.vue b/fe/PDA/uni_modules/uview-ui/components/u-back-top/u-back-top.vue
new file mode 100644
index 000000000..7970fc7ab
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-back-top/u-back-top.vue
@@ -0,0 +1,153 @@
+
+
+
+
+
+ {{tips}}
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-badge/u-badge.vue b/fe/PDA/uni_modules/uview-ui/components/u-badge/u-badge.vue
new file mode 100644
index 000000000..e85b133ae
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-badge/u-badge.vue
@@ -0,0 +1,216 @@
+
+
+ {{showText}}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-button/u-button.vue b/fe/PDA/uni_modules/uview-ui/components/u-button/u-button.vue
new file mode 100644
index 000000000..82c3a6f08
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-button/u-button.vue
@@ -0,0 +1,596 @@
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-calendar/u-calendar.vue b/fe/PDA/uni_modules/uview-ui/components/u-calendar/u-calendar.vue
new file mode 100644
index 000000000..2b3018426
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-calendar/u-calendar.vue
@@ -0,0 +1,639 @@
+
+
+
+
+
+
+
+
+
+
+
+ {{ showTitle }}
+
+
+
+
+
+
+
+
+ {{item}}
+
+
+
+
+
+
+
+
+ {{ index + 1 }}
+
+ {{startText}}
+ {{endText}}
+
+ {{month}}
+
+
+
+ {{mode == 'date' ? activeDate : startDate}}
+ 至{{endDate}}
+
+
+ 确定
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-car-keyboard/u-car-keyboard.vue b/fe/PDA/uni_modules/uview-ui/components/u-car-keyboard/u-car-keyboard.vue
new file mode 100644
index 000000000..84b14678e
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-car-keyboard/u-car-keyboard.vue
@@ -0,0 +1,257 @@
+
+ {}">
+
+
+
+
+ {{ item }}
+
+
+
+
+
+
+ 中
+ /
+ 英
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-card/u-card.vue b/fe/PDA/uni_modules/uview-ui/components/u-card/u-card.vue
new file mode 100644
index 000000000..a3cb2aa92
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-card/u-card.vue
@@ -0,0 +1,299 @@
+
+
+
+
+
+
+
+ {{ title }}
+
+
+
+
+ {{ subTitle }}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-cell-group/u-cell-group.vue b/fe/PDA/uni_modules/uview-ui/components/u-cell-group/u-cell-group.vue
new file mode 100644
index 000000000..3fbca7258
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-cell-group/u-cell-group.vue
@@ -0,0 +1,70 @@
+
+
+
+ {{title}}
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-cell-item/u-cell-item.vue b/fe/PDA/uni_modules/uview-ui/components/u-cell-item/u-cell-item.vue
new file mode 100644
index 000000000..055af3a63
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-cell-item/u-cell-item.vue
@@ -0,0 +1,316 @@
+
+
+
+
+
+
+
+ {{ title }}
+
+
+
+ {{ label }}
+
+
+
+
+
+ {{ value }}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-checkbox-group/u-checkbox-group.vue b/fe/PDA/uni_modules/uview-ui/components/u-checkbox-group/u-checkbox-group.vue
new file mode 100644
index 000000000..6a149b33f
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-checkbox-group/u-checkbox-group.vue
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-checkbox/u-checkbox.vue b/fe/PDA/uni_modules/uview-ui/components/u-checkbox/u-checkbox.vue
new file mode 100644
index 000000000..94144616b
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-checkbox/u-checkbox.vue
@@ -0,0 +1,284 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-circle-progress/u-circle-progress.vue b/fe/PDA/uni_modules/uview-ui/components/u-circle-progress/u-circle-progress.vue
new file mode 100644
index 000000000..46e7c1810
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-circle-progress/u-circle-progress.vue
@@ -0,0 +1,220 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-circle-progress/u-line-progress/u-line-progress.vue b/fe/PDA/uni_modules/uview-ui/components/u-circle-progress/u-line-progress/u-line-progress.vue
new file mode 100644
index 000000000..77e2da202
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-circle-progress/u-line-progress/u-line-progress.vue
@@ -0,0 +1,147 @@
+
+
+
+
+
+ {{percent + '%'}}
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-col/u-col.vue b/fe/PDA/uni_modules/uview-ui/components/u-col/u-col.vue
new file mode 100644
index 000000000..3b6cc64ec
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-col/u-col.vue
@@ -0,0 +1,156 @@
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-collapse-item/u-collapse-item.vue b/fe/PDA/uni_modules/uview-ui/components/u-collapse-item/u-collapse-item.vue
new file mode 100644
index 000000000..66566576f
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-collapse-item/u-collapse-item.vue
@@ -0,0 +1,205 @@
+
+
+
+
+
+ {{ title }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-collapse/u-collapse.vue b/fe/PDA/uni_modules/uview-ui/components/u-collapse/u-collapse.vue
new file mode 100644
index 000000000..8572957ad
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-collapse/u-collapse.vue
@@ -0,0 +1,99 @@
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-column-notice/u-column-notice.vue b/fe/PDA/uni_modules/uview-ui/components/u-column-notice/u-column-notice.vue
new file mode 100644
index 000000000..dd8bd3182
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-column-notice/u-column-notice.vue
@@ -0,0 +1,237 @@
+
+
+
+
+
+
+
+
+ {{ item }}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-count-down/u-count-down.vue b/fe/PDA/uni_modules/uview-ui/components/u-count-down/u-count-down.vue
new file mode 100644
index 000000000..7285d6721
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-count-down/u-count-down.vue
@@ -0,0 +1,318 @@
+
+
+
+
+ {{ d }}
+
+
+
+ {{ separator == 'colon' ? ':' : '天' }}
+
+
+
+ {{ h }}
+
+
+
+ {{ separator == 'colon' ? ':' : '时' }}
+
+
+
+ {{ i }}
+
+
+
+ {{ separator == 'colon' ? ':' : '分' }}
+
+
+
+ {{ s }}
+
+
+
+ 秒
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-count-to/u-count-to.vue b/fe/PDA/uni_modules/uview-ui/components/u-count-to/u-count-to.vue
new file mode 100644
index 000000000..053dc5ffe
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-count-to/u-count-to.vue
@@ -0,0 +1,241 @@
+
+
+ {{ displayValue }}
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-divider/u-divider.vue b/fe/PDA/uni_modules/uview-ui/components/u-divider/u-divider.vue
new file mode 100644
index 000000000..6f8d7e69e
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-divider/u-divider.vue
@@ -0,0 +1,153 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-dropdown-item/u-dropdown-item.vue b/fe/PDA/uni_modules/uview-ui/components/u-dropdown-item/u-dropdown-item.vue
new file mode 100644
index 000000000..ba60d8f76
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-dropdown-item/u-dropdown-item.vue
@@ -0,0 +1,132 @@
+
+ {}" @tap.stop.prevent="() => {}">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-dropdown/u-dropdown.vue b/fe/PDA/uni_modules/uview-ui/components/u-dropdown/u-dropdown.vue
new file mode 100644
index 000000000..a62e469ae
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-dropdown/u-dropdown.vue
@@ -0,0 +1,298 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-empty/u-empty.vue b/fe/PDA/uni_modules/uview-ui/components/u-empty/u-empty.vue
new file mode 100644
index 000000000..2c77b24ee
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-empty/u-empty.vue
@@ -0,0 +1,193 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-field/u-field.vue b/fe/PDA/uni_modules/uview-ui/components/u-field/u-field.vue
new file mode 100644
index 000000000..b562798ac
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-field/u-field.vue
@@ -0,0 +1,384 @@
+
+
+
+
+
+
+
+
+ {{ label }}
+
+
+
+
+
+
+
+
+
+
+
+ {{ errorMessage }}
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-form-item/u-form-item.vue b/fe/PDA/uni_modules/uview-ui/components/u-form-item/u-form-item.vue
new file mode 100644
index 000000000..d6b8c8b05
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-form-item/u-form-item.vue
@@ -0,0 +1,431 @@
+
+
+
+
+
+
+
+
+ *
+
+
+
+
+ {{label}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{validateMessage}}
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-form/u-form.vue b/fe/PDA/uni_modules/uview-ui/components/u-form/u-form.vue
new file mode 100644
index 000000000..bdbafaf08
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-form/u-form.vue
@@ -0,0 +1,134 @@
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-full-screen/u-full-screen.vue b/fe/PDA/uni_modules/uview-ui/components/u-full-screen/u-full-screen.vue
new file mode 100644
index 000000000..4f7e7d95b
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-full-screen/u-full-screen.vue
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-gap/u-gap.vue b/fe/PDA/uni_modules/uview-ui/components/u-gap/u-gap.vue
new file mode 100644
index 000000000..6c01f9437
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-gap/u-gap.vue
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-grid-item/u-grid-item.vue b/fe/PDA/uni_modules/uview-ui/components/u-grid-item/u-grid-item.vue
new file mode 100644
index 000000000..0773307c2
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-grid-item/u-grid-item.vue
@@ -0,0 +1,126 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-grid/u-grid.vue b/fe/PDA/uni_modules/uview-ui/components/u-grid/u-grid.vue
new file mode 100644
index 000000000..6588c06fc
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-grid/u-grid.vue
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-icon/u-icon.vue b/fe/PDA/uni_modules/uview-ui/components/u-icon/u-icon.vue
new file mode 100644
index 000000000..db1b01953
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-icon/u-icon.vue
@@ -0,0 +1,336 @@
+
+
+
+
+
+
+
+
+ {{ label }}
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-image/u-image.vue b/fe/PDA/uni_modules/uview-ui/components/u-image/u-image.vue
new file mode 100644
index 000000000..c729c3c80
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-image/u-image.vue
@@ -0,0 +1,267 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-index-anchor/u-index-anchor.vue b/fe/PDA/uni_modules/uview-ui/components/u-index-anchor/u-index-anchor.vue
new file mode 100644
index 000000000..5038827b6
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-index-anchor/u-index-anchor.vue
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+ {{ index }}
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-index-list/u-index-list.vue b/fe/PDA/uni_modules/uview-ui/components/u-index-list/u-index-list.vue
new file mode 100644
index 000000000..30fcda094
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-index-list/u-index-list.vue
@@ -0,0 +1,315 @@
+
+
+
+
+
+
+
+ {{indexList[touchmoveIndex]}}
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-input/u-input.vue b/fe/PDA/uni_modules/uview-ui/components/u-input/u-input.vue
new file mode 100644
index 000000000..f2aea72fe
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-input/u-input.vue
@@ -0,0 +1,387 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-keyboard/u-keyboard.vue b/fe/PDA/uni_modules/uview-ui/components/u-keyboard/u-keyboard.vue
new file mode 100644
index 000000000..1904a2ba2
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-keyboard/u-keyboard.vue
@@ -0,0 +1,217 @@
+
+
+
+
+
+ {{cancelBtn ? cancelText : ''}}
+
+
+ {{tips ? tips : mode == 'number' ? '数字键盘' : mode == 'card' ? '身份证键盘' : '车牌号键盘'}}
+
+
+ {{confirmBtn ? confirmText : ''}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-lazy-load/u-lazy-load.vue b/fe/PDA/uni_modules/uview-ui/components/u-lazy-load/u-lazy-load.vue
new file mode 100644
index 000000000..429a680cf
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-lazy-load/u-lazy-load.vue
@@ -0,0 +1,244 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-line-progress/u-line-progress.vue b/fe/PDA/uni_modules/uview-ui/components/u-line-progress/u-line-progress.vue
new file mode 100644
index 000000000..77e2da202
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-line-progress/u-line-progress.vue
@@ -0,0 +1,147 @@
+
+
+
+
+
+ {{percent + '%'}}
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-line/u-line.vue b/fe/PDA/uni_modules/uview-ui/components/u-line/u-line.vue
new file mode 100644
index 000000000..c56fbc3fa
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-line/u-line.vue
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-link/u-link.vue b/fe/PDA/uni_modules/uview-ui/components/u-link/u-link.vue
new file mode 100644
index 000000000..2dd2a7355
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-link/u-link.vue
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-loading-page/u-loading-page.vue b/fe/PDA/uni_modules/uview-ui/components/u-loading-page/u-loading-page.vue
new file mode 100644
index 000000000..7e0440135
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-loading-page/u-loading-page.vue
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-loading/u-loading.vue b/fe/PDA/uni_modules/uview-ui/components/u-loading/u-loading.vue
new file mode 100644
index 000000000..c747f6439
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-loading/u-loading.vue
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-loadmore/u-loadmore.vue b/fe/PDA/uni_modules/uview-ui/components/u-loadmore/u-loadmore.vue
new file mode 100644
index 000000000..6b852a8a7
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-loadmore/u-loadmore.vue
@@ -0,0 +1,203 @@
+
+
+
+
+
+
+
+
+
+
+ {{ showText }}
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-mask/u-mask.vue b/fe/PDA/uni_modules/uview-ui/components/u-mask/u-mask.vue
new file mode 100644
index 000000000..0b55d9d84
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-mask/u-mask.vue
@@ -0,0 +1,123 @@
+
+ {}" :class="{
+ 'u-mask-zoom': zoom,
+ 'u-mask-show': show
+ }">
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-message-input/u-message-input.vue b/fe/PDA/uni_modules/uview-ui/components/u-message-input/u-message-input.vue
new file mode 100644
index 000000000..41e071938
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-message-input/u-message-input.vue
@@ -0,0 +1,311 @@
+
+
+
+
+
+
+
+
+
+ {{ charArr[index] ? charArr[index] : ''}}
+
+ {{ charArr[index] ? '●' : ''}}
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-modal/u-modal.vue b/fe/PDA/uni_modules/uview-ui/components/u-modal/u-modal.vue
new file mode 100644
index 000000000..ce5811330
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-modal/u-modal.vue
@@ -0,0 +1,283 @@
+
+
+
+
+ {{ title }}
+
+
+
+
+ {{ content }}
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-navbar/u-navbar.vue b/fe/PDA/uni_modules/uview-ui/components/u-navbar/u-navbar.vue
new file mode 100644
index 000000000..450242e99
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-navbar/u-navbar.vue
@@ -0,0 +1,315 @@
+
+
+
+
+
+
+
+
+
+ {{ backText }}
+
+
+
+ {{ title }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-no-network/u-no-network.vue b/fe/PDA/uni_modules/uview-ui/components/u-no-network/u-no-network.vue
new file mode 100644
index 000000000..51d9f4f02
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-no-network/u-no-network.vue
@@ -0,0 +1,233 @@
+
+ {}">
+
+
+
+ {{tips}}
+
+
+
+
+ 请检查网络,或前往设置
+
+
+
+ 重试
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-notice-bar/u-notice-bar.vue b/fe/PDA/uni_modules/uview-ui/components/u-notice-bar/u-notice-bar.vue
new file mode 100644
index 000000000..41a6cc474
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-notice-bar/u-notice-bar.vue
@@ -0,0 +1,272 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-number-box/u-number-box.vue b/fe/PDA/uni_modules/uview-ui/components/u-number-box/u-number-box.vue
new file mode 100644
index 000000000..54a679eb5
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-number-box/u-number-box.vue
@@ -0,0 +1,363 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-number-keyboard/u-number-keyboard.vue b/fe/PDA/uni_modules/uview-ui/components/u-number-keyboard/u-number-keyboard.vue
new file mode 100644
index 000000000..6425a1f8d
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-number-keyboard/u-number-keyboard.vue
@@ -0,0 +1,158 @@
+
+ {}">
+
+
+ {{ item }}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-parse/libs/CssHandler.js b/fe/PDA/uni_modules/uview-ui/components/u-parse/libs/CssHandler.js
new file mode 100644
index 000000000..75c601541
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-parse/libs/CssHandler.js
@@ -0,0 +1,100 @@
+const cfg = require('./config.js'),
+ isLetter = c => (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
+
+function CssHandler(tagStyle) {
+ var styles = Object.assign(Object.create(null), cfg.userAgentStyles);
+ for (var item in tagStyle)
+ styles[item] = (styles[item] ? styles[item] + ';' : '') + tagStyle[item];
+ this.styles = styles;
+}
+CssHandler.prototype.getStyle = function(data) {
+ this.styles = new parser(data, this.styles).parse();
+}
+CssHandler.prototype.match = function(name, attrs) {
+ var tmp, matched = (tmp = this.styles[name]) ? tmp + ';' : '';
+ if (attrs.class) {
+ var items = attrs.class.split(' ');
+ for (var i = 0, item; item = items[i]; i++)
+ if (tmp = this.styles['.' + item])
+ matched += tmp + ';';
+ }
+ if (tmp = this.styles['#' + attrs.id])
+ matched += tmp + ';';
+ return matched;
+}
+module.exports = CssHandler;
+
+function parser(data, init) {
+ this.data = data;
+ this.floor = 0;
+ this.i = 0;
+ this.list = [];
+ this.res = init;
+ this.state = this.Space;
+}
+parser.prototype.parse = function() {
+ for (var c; c = this.data[this.i]; this.i++)
+ this.state(c);
+ return this.res;
+}
+parser.prototype.section = function() {
+ return this.data.substring(this.start, this.i);
+}
+// 状态机
+parser.prototype.Space = function(c) {
+ if (c == '.' || c == '#' || isLetter(c)) {
+ this.start = this.i;
+ this.state = this.Name;
+ } else if (c == '/' && this.data[this.i + 1] == '*')
+ this.Comment();
+ else if (!cfg.blankChar[c] && c != ';')
+ this.state = this.Ignore;
+}
+parser.prototype.Comment = function() {
+ this.i = this.data.indexOf('*/', this.i) + 1;
+ if (!this.i) this.i = this.data.length;
+ this.state = this.Space;
+}
+parser.prototype.Ignore = function(c) {
+ if (c == '{') this.floor++;
+ else if (c == '}' && !--this.floor) {
+ this.list = [];
+ this.state = this.Space;
+ }
+}
+parser.prototype.Name = function(c) {
+ if (cfg.blankChar[c]) {
+ this.list.push(this.section());
+ this.state = this.NameSpace;
+ } else if (c == '{') {
+ this.list.push(this.section());
+ this.Content();
+ } else if (c == ',') {
+ this.list.push(this.section());
+ this.Comma();
+ } else if (!isLetter(c) && (c < '0' || c > '9') && c != '-' && c != '_')
+ this.state = this.Ignore;
+}
+parser.prototype.NameSpace = function(c) {
+ if (c == '{') this.Content();
+ else if (c == ',') this.Comma();
+ else if (!cfg.blankChar[c]) this.state = this.Ignore;
+}
+parser.prototype.Comma = function() {
+ while (cfg.blankChar[this.data[++this.i]]);
+ if (this.data[this.i] == '{') this.Content();
+ else {
+ this.start = this.i--;
+ this.state = this.Name;
+ }
+}
+parser.prototype.Content = function() {
+ this.start = ++this.i;
+ if ((this.i = this.data.indexOf('}', this.i)) == -1) this.i = this.data.length;
+ var content = this.section();
+ for (var i = 0, item; item = this.list[i++];)
+ if (this.res[item]) this.res[item] += ';' + content;
+ else this.res[item] = content;
+ this.list = [];
+ this.state = this.Space;
+}
diff --git a/fe/PDA/uni_modules/uview-ui/components/u-parse/libs/MpHtmlParser.js b/fe/PDA/uni_modules/uview-ui/components/u-parse/libs/MpHtmlParser.js
new file mode 100644
index 000000000..aeb0fc385
--- /dev/null
+++ b/fe/PDA/uni_modules/uview-ui/components/u-parse/libs/MpHtmlParser.js
@@ -0,0 +1,580 @@
+/**
+ * html 解析器
+ * @tutorial https://github.com/jin-yufeng/Parser
+ * @version 20201029
+ * @author JinYufeng
+ * @listens MIT
+ */
+const cfg = require('./config.js'),
+ blankChar = cfg.blankChar,
+ CssHandler = require('./CssHandler.js'),
+ windowWidth = uni.getSystemInfoSync().windowWidth;
+var emoji;
+
+function MpHtmlParser(data, options = {}) {
+ this.attrs = {};
+ this.CssHandler = new CssHandler(options.tagStyle, windowWidth);
+ this.data = data;
+ this.domain = options.domain;
+ this.DOM = [];
+ this.i = this.start = this.audioNum = this.imgNum = this.videoNum = 0;
+ options.prot = (this.domain || '').includes('://') ? this.domain.split('://')[0] : 'http';
+ this.options = options;
+ this.state = this.Text;
+ this.STACK = [];
+ // 工具函数
+ this.bubble = () => {
+ for (var i = this.STACK.length, item; item = this.STACK[--i];) {
+ if (cfg.richOnlyTags[item.name]) return false;
+ item.c = 1;
+ }
+ return true;
+ }
+ this.decode = (val, amp) => {
+ var i = -1,
+ j, en;
+ while (1) {
+ if ((i = val.indexOf('&', i + 1)) == -1) break;
+ if ((j = val.indexOf(';', i + 2)) == -1) break;
+ if (val[i + 1] == '#') {
+ en = parseInt((val[i + 2] == 'x' ? '0' : '') + val.substring(i + 2, j));
+ if (!isNaN(en)) val = val.substr(0, i) + String.fromCharCode(en) + val.substr(j + 1);
+ } else {
+ en = val.substring(i + 1, j);
+ if (cfg.entities[en] || en == amp)
+ val = val.substr(0, i) + (cfg.entities[en] || '&') + val.substr(j + 1);
+ }
+ }
+ return val;
+ }
+ this.getUrl = url => {
+ if (url[0] == '/') {
+ if (url[1] == '/') url = this.options.prot + ':' + url;
+ else if (this.domain) url = this.domain + url;
+ } else if (this.domain && url.indexOf('data:') != 0 && !url.includes('://'))
+ url = this.domain + '/' + url;
+ return url;
+ }
+ this.isClose = () => this.data[this.i] == '>' || (this.data[this.i] == '/' && this.data[this.i + 1] == '>');
+ this.section = () => this.data.substring(this.start, this.i);
+ this.parent = () => this.STACK[this.STACK.length - 1];
+ this.siblings = () => this.STACK.length ? this.parent().children : this.DOM;
+}
+MpHtmlParser.prototype.parse = function() {
+ if (emoji) this.data = emoji.parseEmoji(this.data);
+ for (var c; c = this.data[this.i]; this.i++)
+ this.state(c);
+ if (this.state == this.Text) this.setText();
+ while (this.STACK.length) this.popNode(this.STACK.pop());
+ return this.DOM;
+}
+// 设置属性
+MpHtmlParser.prototype.setAttr = function() {
+ var name = this.attrName.toLowerCase(),
+ val = this.attrVal;
+ if (cfg.boolAttrs[name]) this.attrs[name] = 'T';
+ else if (val) {
+ if (name == 'src' || (name == 'data-src' && !this.attrs.src)) this.attrs.src = this.getUrl(this.decode(val, 'amp'));
+ else if (name == 'href' || name == 'style') this.attrs[name] = this.decode(val, 'amp');
+ else if (name.substr(0, 5) != 'data-') this.attrs[name] = val;
+ }
+ this.attrVal = '';
+ while (blankChar[this.data[this.i]]) this.i++;
+ if (this.isClose()) this.setNode();
+ else {
+ this.start = this.i;
+ this.state = this.AttrName;
+ }
+}
+// 设置文本节点
+MpHtmlParser.prototype.setText = function() {
+ var back, text = this.section();
+ if (!text) return;
+ text = (cfg.onText && cfg.onText(text, () => back = true)) || text;
+ if (back) {
+ this.data = this.data.substr(0, this.start) + text + this.data.substr(this.i);
+ let j = this.start + text.length;
+ for (this.i = this.start; this.i < j; this.i++) this.state(this.data[this.i]);
+ return;
+ }
+ if (!this.pre) {
+ // 合并空白符
+ var flag, tmp = [];
+ for (let i = text.length, c; c = text[--i];)
+ if (!blankChar[c]) {
+ tmp.unshift(c);
+ if (!flag) flag = 1;
+ } else {
+ if (tmp[0] != ' ') tmp.unshift(' ');
+ if (c == '\n' && flag == void 0) flag = 0;
+ }
+ if (flag == 0) return;
+ text = tmp.join('');
+ }
+ this.siblings().push({
+ type: 'text',
+ text: this.decode(text)
+ });
+}
+// 设置元素节点
+MpHtmlParser.prototype.setNode = function() {
+ var node = {
+ name: this.tagName.toLowerCase(),
+ attrs: this.attrs
+ },
+ close = cfg.selfClosingTags[node.name];
+ if (this.options.nodes.length) node.type = 'node';
+ this.attrs = {};
+ if (!cfg.ignoreTags[node.name]) {
+ // 处理属性
+ var attrs = node.attrs,
+ style = this.CssHandler.match(node.name, attrs, node) + (attrs.style || ''),
+ styleObj = {};
+ if (attrs.id) {
+ if (this.options.compress & 1) attrs.id = void 0;
+ else if (this.options.useAnchor) this.bubble();
+ }
+ if ((this.options.compress & 2) && attrs.class) attrs.class = void 0;
+ switch (node.name) {
+ case 'a':
+ case 'ad': // #ifdef APP-PLUS
+ case 'iframe':
+ // #endif
+ this.bubble();
+ break;
+ case 'font':
+ if (attrs.color) {
+ styleObj['color'] = attrs.color;
+ attrs.color = void 0;
+ }
+ if (attrs.face) {
+ styleObj['font-family'] = attrs.face;
+ attrs.face = void 0;
+ }
+ if (attrs.size) {
+ var size = parseInt(attrs.size);
+ if (size < 1) size = 1;
+ else if (size > 7) size = 7;
+ var map = ['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'];
+ styleObj['font-size'] = map[size - 1];
+ attrs.size = void 0;
+ }
+ break;
+ case 'embed':
+ // #ifndef APP-PLUS
+ var src = node.attrs.src || '',
+ type = node.attrs.type || '';
+ if (type.includes('video') || src.includes('.mp4') || src.includes('.3gp') || src.includes('.m3u8'))
+ node.name = 'video';
+ else if (type.includes('audio') || src.includes('.m4a') || src.includes('.wav') || src.includes('.mp3') || src.includes(
+ '.aac'))
+ node.name = 'audio';
+ else break;
+ if (node.attrs.autostart)
+ node.attrs.autoplay = 'T';
+ node.attrs.controls = 'T';
+ // #endif
+ // #ifdef APP-PLUS
+ this.bubble();
+ break;
+ // #endif
+ case 'video':
+ case 'audio':
+ if (!attrs.id) attrs.id = node.name + (++this[`${node.name}Num`]);
+ else this[`${node.name}Num`]++;
+ if (node.name == 'video') {
+ if (this.videoNum > 3)
+ node.lazyLoad = 1;
+ if (attrs.width) {
+ styleObj.width = parseFloat(attrs.width) + (attrs.width.includes('%') ? '%' : 'px');
+ attrs.width = void 0;
+ }
+ if (attrs.height) {
+ styleObj.height = parseFloat(attrs.height) + (attrs.height.includes('%') ? '%' : 'px');
+ attrs.height = void 0;
+ }
+ }
+ if (!attrs.controls && !attrs.autoplay) attrs.controls = 'T';
+ attrs.source = [];
+ if (attrs.src) {
+ attrs.source.push(attrs.src);
+ attrs.src = void 0;
+ }
+ this.bubble();
+ break;
+ case 'td':
+ case 'th':
+ if (attrs.colspan || attrs.rowspan)
+ for (var k = this.STACK.length, item; item = this.STACK[--k];)
+ if (item.name == 'table') {
+ item.flag = 1;
+ break;
+ }
+ }
+ if (attrs.align) {
+ if (node.name == 'table') {
+ if (attrs.align == 'center') styleObj['margin-inline-start'] = styleObj['margin-inline-end'] = 'auto';
+ else styleObj['float'] = attrs.align;
+ } else styleObj['text-align'] = attrs.align;
+ attrs.align = void 0;
+ }
+ // 压缩 style
+ var styles = style.split(';');
+ style = '';
+ for (var i = 0, len = styles.length; i < len; i++) {
+ var info = styles[i].split(':');
+ if (info.length < 2) continue;
+ let key = info[0].trim().toLowerCase(),
+ value = info.slice(1).join(':').trim();
+ if (value[0] == '-' || value.includes('safe'))
+ style += `;${key}:${value}`;
+ else if (!styleObj[key] || value.includes('import') || !styleObj[key].includes('import'))
+ styleObj[key] = value;
+ }
+ if (node.name == 'img') {
+ if (attrs.src && !attrs.ignore) {
+ if (this.bubble())
+ attrs.i = (this.imgNum++).toString();
+ else attrs.ignore = 'T';
+ }
+ if (attrs.ignore) {
+ style += ';-webkit-touch-callout:none';
+ styleObj['max-width'] = '100%';
+ }
+ var width;
+ if (styleObj.width) width = styleObj.width;
+ else if (attrs.width) width = attrs.width.includes('%') ? attrs.width : parseFloat(attrs.width) + 'px';
+ if (width) {
+ styleObj.width = width;
+ attrs.width = '100%';
+ if (parseInt(width) > windowWidth) {
+ styleObj.height = '';
+ if (attrs.height) attrs.height = void 0;
+ }
+ }
+ if (styleObj.height) {
+ attrs.height = styleObj.height;
+ styleObj.height = '';
+ } else if (attrs.height && !attrs.height.includes('%'))
+ attrs.height = parseFloat(attrs.height) + 'px';
+ }
+ for (var key in styleObj) {
+ var value = styleObj[key];
+ if (!value) continue;
+ if (key.includes('flex') || key == 'order' || key == 'self-align') node.c = 1;
+ // 填充链接
+ if (value.includes('url')) {
+ var j = value.indexOf('(');
+ if (j++ != -1) {
+ while (value[j] == '"' || value[j] == "'" || blankChar[value[j]]) j++;
+ value = value.substr(0, j) + this.getUrl(value.substr(j));
+ }
+ }
+ // 转换 rpx
+ else if (value.includes('rpx'))
+ value = value.replace(/[0-9.]+\s*rpx/g, $ => parseFloat($) * windowWidth / 750 + 'px');
+ else if (key == 'white-space' && value.includes('pre') && !close)
+ this.pre = node.pre = true;
+ style += `;${key}:${value}`;
+ }
+ style = style.substr(1);
+ if (style) attrs.style = style;
+ if (!close) {
+ node.children = [];
+ if (node.name == 'pre' && cfg.highlight) {
+ this.remove(node);
+ this.pre = node.pre = true;
+ }
+ this.siblings().push(node);
+ this.STACK.push(node);
+ } else if (!cfg.filter || cfg.filter(node, this) != false)
+ this.siblings().push(node);
+ } else {
+ if (!close) this.remove(node);
+ else if (node.name == 'source') {
+ var parent = this.parent();
+ if (parent && (parent.name == 'video' || parent.name == 'audio') && node.attrs.src)
+ parent.attrs.source.push(node.attrs.src);
+ } else if (node.name == 'base' && !this.domain) this.domain = node.attrs.href;
+ }
+ if (this.data[this.i] == '/') this.i++;
+ this.start = this.i + 1;
+ this.state = this.Text;
+}
+// 移除标签
+MpHtmlParser.prototype.remove = function(node) {
+ var name = node.name,
+ j = this.i;
+ // 处理 svg
+ var handleSvg = () => {
+ var src = this.data.substring(j, this.i + 1);
+ node.attrs.xmlns = 'http://www.w3.org/2000/svg';
+ for (var key in node.attrs) {
+ if (key == 'viewbox') src = ` viewBox="${node.attrs.viewbox}"` + src;
+ else if (key != 'style') src = ` ${key}="${node.attrs[key]}"` + src;
+ }
+ src = '