index.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279
  1. <template >
  2. <view >
  3. <uni-collapse class="uni-flex">
  4. <uni-collapse-item title="常用操作">
  5. <uni-grid :column="3" :square="false" :highlight="false">
  6. <uni-grid-item>
  7. <view class="grid-item-box pointer" @click="toSign1">
  8. <uni-icons type="settings" size="20"></uni-icons>
  9. <text class="text">签证申请单</text>
  10. </view>
  11. </uni-grid-item>
  12. <uni-grid-item>
  13. <view class="grid-item-box pointer" @click="toSign2">
  14. <uni-icons type="settings" size="20"></uni-icons>
  15. <text class="text">待审签证单</text>
  16. </view>
  17. </uni-grid-item>
  18. <uni-grid-item>
  19. <navigator url="../template/GetMaterialIns/GetMaterialIns">
  20. <view class="grid-item-box pointer" >
  21. <uni-icons type="settings" size="20"></uni-icons>
  22. <text class="text">入库单</text>
  23. </view>
  24. </navigator>
  25. </uni-grid-item>
  26. </uni-grid>
  27. <uni-grid :column="3" :square="false" :highlight="false">
  28. <uni-grid-item>
  29. <view class="grid-item-box pointer" @click="selectProject">
  30. <uni-icons type="close" size="20"></uni-icons>
  31. <text class="text">选择项目</text>
  32. </view>
  33. </uni-grid-item>
  34. <uni-grid-item>
  35. <navigator url="../template/GetMaterialOuts/GetMaterialOuts">
  36. <view class="grid-item-box pointer" >
  37. <uni-icons type="settings" size="20"></uni-icons>
  38. <text class="text">领料单</text>
  39. </view>
  40. </navigator>
  41. </uni-grid-item>
  42. <uni-grid-item>
  43. <view class="grid-item-box pointer" @click="logout">
  44. <uni-icons type="close" size="20"></uni-icons>
  45. <text class="text">登出</text>
  46. </view>
  47. </uni-grid-item>
  48. </uni-grid>
  49. </uni-collapse-item>
  50. </uni-collapse>
  51. <view class="qiun-columns">
  52. <view class="qiun-padding" style="font-size: 32rpx;">
  53. <text>{{tips}}</text>
  54. </view>
  55. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  56. <view class="qiun-title-dot-light">项目进度图</view>
  57. </view>
  58. <view class="qiun-charts1">
  59. <text class="gree">节点1</text class="gree"> => <text class="gree">节点2</text> => <text class="gree">节点3</text> =>
  60. <text class="gree">节点4</text> => <text class="orange">节点1</text class="gray"> => <text class="gray">节点2</text> =>
  61. <text class="gray">节点3</text> => <text class="gray">节点4</text>
  62. </view>
  63. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  64. <view class="qiun-title-dot-light">工程进度图</view>
  65. </view>
  66. <view class="qiun-charts3">
  67. <!--#ifndef MP-ALIPAY -->
  68. <canvas canvas-id="canvasArcbar1" id="canvasArcbar1" class="charts3"></canvas>
  69. <canvas canvas-id="canvasArcbar2" id="canvasArcbar2" class="charts3" style="margin-left: 250rpx;"></canvas>
  70. <canvas canvas-id="canvasArcbar3" id="canvasArcbar3" class="charts3" style="margin-left: 500rpx;"></canvas>
  71. <!--#endif-->
  72. </view>
  73. <view class="qiun-title-bar" style="background-color: #E5FDC3;">
  74. <view class="qiun-title-dot-light">质量图</view>
  75. </view>
  76. <view class="qiun-charts" style="background-color: #E5FDC3;">
  77. <!--#ifdef MP-ALIPAY -->
  78. <canvas canvas-id="canvasColumn" id="canvasColumn" class="charts" style="background-color: #E5FDC3;" :width="cWidth*pixelRatio"
  79. :height="cHeight*pixelRatio" :style="{'width':cWidth+'px','height':cHeight+'px'}" @touchstart="touchIt($event,'canvasColumn')"></canvas>
  80. <!--#endif-->
  81. <!--#ifndef MP-ALIPAY -->
  82. <canvas canvas-id="canvasColumn" id="canvasColumn" class="charts" style="background-color: #E5FDC3;" @touchstart="touchIt($event,'canvasColumn')"></canvas>
  83. <!--#endif-->
  84. </view>
  85. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  86. <view class="qiun-title-dot-light">安全图</view>
  87. </view>
  88. <view class="qiun-charts">
  89. <!--#ifdef MP-ALIPAY -->
  90. <canvas canvas-id="canvasMix" id="canvasMix" class="charts" :width="cWidth*pixelRatio" :height="cHeight*pixelRatio"
  91. :style="{'width':cWidth+'px','height':cHeight+'px'}" disable-scroll=true @touchstart="touchMix" @touchmove="moveMix"
  92. @touchend="touchEndMix"></canvas>
  93. <!--#endif-->
  94. <!--#ifndef MP-ALIPAY -->
  95. <canvas canvas-id="canvasMix" id="canvasMix" class="charts" disable-scroll=true @touchstart="touchMix" @touchmove="moveMix"
  96. @touchend="touchEndMix"></canvas>
  97. <!--#endif-->
  98. </view>
  99. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  100. <view class="qiun-title-dot-light">文明施工图</view>
  101. </view>
  102. <view class="qiun-charts">
  103. <!--#ifndef MP-ALIPAY -->
  104. <canvas canvas-id="canvasPie" id="canvasPie" class="charts" @touchstart="touchPie($event,'canvasPie')"></canvas>
  105. <!--#endif-->
  106. </view>
  107. <view class="qiun-bg-white qiun-title-bar qiun-common-mt">
  108. <view class="qiun-title-dot-light">环形图</view>
  109. </view>
  110. <view class="qiun-charts">
  111. <!--#ifndef MP-ALIPAY -->
  112. <canvas canvas-id="canvasRing" id="canvasRing" class="charts" @touchstart="touchPie($event,'canvasRing')"></canvas>
  113. <!--#endif-->
  114. </view>
  115. </view>
  116. </view>
  117. </template>
  118. <script>
  119. import uCharts from '@/components/u-charts/u-charts.js';
  120. var startX,startY;
  121. var endPos={},isScrolling;
  122. var _self;
  123. var canvasObj = {};
  124. export default {
  125. data() {
  126. return {
  127. href: '',
  128. state: this.$store.state,
  129. cWidth: '',
  130. cHeight: '',
  131. cWidth2: '', //横屏图表
  132. cHeight2: '', //横屏图表
  133. cWidth3: '', //圆弧进度图
  134. cHeight3: '', //圆弧进度图
  135. arcbarWidth: '', //圆弧进度图,进度条宽度,此设置可使各端宽度一致
  136. gaugeWidth: '', //仪表盘宽度,此设置可使各端宽度一致
  137. tips: '',
  138. pixelRatio: 1,
  139. serverData: '',
  140. itemCount: 30, //x轴单屏数据密度
  141. sliderMax: 50
  142. }
  143. },
  144. onLoad() {
  145. console.info("首页1");
  146. //判断登录是否超时,若超时,则跳转到登录界面
  147. this.$util.persistLogin(this);
  148. _self = this;
  149. //#ifdef MP-ALIPAY
  150. uni.getSystemInfo({
  151. success: function(res) {
  152. if (res.pixelRatio > 1) {
  153. //正常这里给2就行,如果pixelRatio=3性能会降低一点
  154. //_self.pixelRatio =res.pixelRatio;
  155. _self.pixelRatio = 2;
  156. }
  157. }
  158. });
  159. //#endif
  160. this.cWidth = uni.upx2px(750);
  161. this.cHeight = uni.upx2px(500);
  162. this.cWidth2 = uni.upx2px(700);
  163. this.cHeight2 = uni.upx2px(1100);
  164. this.cWidth3 = uni.upx2px(250);
  165. this.cHeight3 = uni.upx2px(250);
  166. this.arcbarWidth = uni.upx2px(24);
  167. this.gaugeWidth = uni.upx2px(30);
  168. document.addEventListener("touchstart",function(e){
  169. startX = e.touches[0].pageX;
  170. startY = e.touches[0].pageY;
  171. });
  172. document.addEventListener('touchmove', function(event) {
  173. //console.info('左右滑动',event);
  174. //当屏幕有多个touch或者页面被缩放过,就不执行move操作
  175. if (event.targetTouches.length > 1 || event.scale && event.scale !== 1) return;
  176. var touch = event.targetTouches[0];
  177. endPos = {
  178. x: touch.pageX - startX,
  179. y: touch.pageY - startY
  180. };
  181. isScrolling = Math.abs(endPos.x) < Math.abs(endPos.y) ? 1 : 0; //isScrolling为1时,表示纵向滑动,0为横向滑动
  182. if (isScrolling === 0) { //横向滑动
  183. // alert(0);
  184. event.preventDefault(); //阻止触摸事件的默认行为,即阻止滚屏
  185. }
  186. }, { passive: false });
  187. },
  188. onReady() {
  189. this.getServerData();
  190. },
  191. methods: {
  192. toSign1() {
  193. uni.navigateTo({
  194. url: '/pages/template/requisitionlist/requisitionlist'
  195. });
  196. },
  197. toSign2() {
  198. uni.navigateTo({
  199. url: '/pages/template/GetVises/GetVises'
  200. });
  201. },
  202. preventhuadong() {
  203. },
  204. logout() {
  205. console.info("logout");
  206. this.$store.commit('setIsLogin', false);
  207. this.$store.commit('setUser', null);
  208. this.$store.commit('setToken', '');
  209. this.$store.commit('setName', '');
  210. this.$store.commit('setRoles', '');
  211. uni.navigateTo({
  212. url: "/"
  213. });
  214. },
  215. /* 选择项目 */
  216. selectProject() {
  217. uni.navigateTo({
  218. url: '/pages/SelectProject/SelectProject'
  219. });
  220. },
  221. /* 图表 start*/
  222. getServerData() {
  223. uni.showLoading({
  224. title: "正在加载数据..."
  225. })
  226. uni.request({
  227. url: 'https://unidemo.dcloud.net.cn/hello-uniapp-ucharts-data.json',
  228. data: {},
  229. success: function(res) {
  230. _self.fillData(res.data);
  231. },
  232. fail: () => {
  233. _self.tips = "网络错误,小程序端请检查合法域名";
  234. },
  235. complete() {
  236. uni.hideLoading();
  237. }
  238. });
  239. },
  240. fillData(data) {
  241. this.serverData = data;
  242. this.tips = data.tips;
  243. this.sliderMax = data.Candle.categories.length;
  244. let Column = {
  245. categories: [],
  246. series: []
  247. };
  248. let ColumnMeter = {
  249. categories: [],
  250. series: []
  251. };
  252. let LineA = {
  253. categories: [],
  254. series: []
  255. };
  256. let LineB = {
  257. categories: [],
  258. series: []
  259. };
  260. let Area = {
  261. categories: [],
  262. series: []
  263. };
  264. let Pie = {
  265. series: []
  266. };
  267. let Ring = {
  268. series: []
  269. };
  270. let Funnel = {
  271. series: []
  272. };
  273. let Radar = {
  274. categories: [],
  275. series: []
  276. };
  277. let Arcbar1 = {
  278. series: []
  279. };
  280. let Arcbar2 = {
  281. series: []
  282. };
  283. let Arcbar3 = {
  284. series: []
  285. };
  286. let Gauge = {
  287. categories: [],
  288. series: []
  289. };
  290. let Candle = {
  291. categories: [],
  292. series: []
  293. };
  294. let Mix = {
  295. categories: [],
  296. series: []
  297. };
  298. //这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
  299. Column.categories = data.Column.categories;
  300. //这里的series数据是后台做好的,如果您的数据没有和前面我注释掉的格式一样,请自行拼接数据
  301. Column.series = data.Column.series;
  302. ColumnMeter.categories = data.ColumnMeter.categories;
  303. //这里的series数据,如果为Meter,series[0]定义为外层数据,series[1]定义为内层数据
  304. ColumnMeter.series = data.ColumnMeter.series;
  305. LineA.categories = data.LineA.categories;
  306. LineA.series = data.LineA.series;
  307. LineB.categories = data.LineB.categories;
  308. LineB.series = data.LineB.series;
  309. Area.categories = data.Area.categories;
  310. Area.series = data.Area.series;
  311. Pie.series = data.Pie.series;
  312. Ring.series = data.Ring.series;
  313. Funnel.series = data.Pie.series;
  314. //自定义文案示例,需设置format字段
  315. for (let i = 0; i < Ring.series.length; i++) {
  316. Ring.series[i].format = () => {
  317. return Ring.series[i].name + Ring.series[i].data
  318. };
  319. }
  320. Radar.categories = data.Radar.categories;
  321. Radar.series = data.Radar.series;
  322. Arcbar1.series = data.Arcbar1.series;
  323. Arcbar2.series = data.Arcbar2.series;
  324. Arcbar3.series = data.Arcbar3.series;
  325. Gauge.categories = data.Gauge.categories;
  326. Gauge.series = data.Gauge.series;
  327. Candle.categories = data.Candle.categories;
  328. Candle.series = data.Candle.series;
  329. Mix.categories = data.Mix.categories;
  330. Mix.series = data.Mix.series;
  331. this.showColumn("canvasColumn", Column);
  332. this.showColumnMeter("canvasColumnMeter", ColumnMeter);
  333. this.showLineA("canvasLineA", LineA);
  334. this.showLineB("canvasLineB", LineB);
  335. this.showArea("canvasArea", Area);
  336. this.showPie("canvasPie", Pie);
  337. this.showRing("canvasRing", Ring);
  338. this.showFunnel("canvasFunnel", Funnel);
  339. this.showRadar("canvasRadar", Radar);
  340. this.showArcbar("canvasArcbar1", Arcbar1);
  341. this.showArcbar2("canvasArcbar2", Arcbar2);
  342. this.showArcbar3("canvasArcbar3", Arcbar3);
  343. this.showGauge("canvasGauge", Gauge);
  344. this.showCandle("canvasCandle", Candle);
  345. this.showMix("canvasMix", Mix);
  346. },
  347. showColumn(canvasId, chartData) {
  348. canvasObj[canvasId] = new uCharts({
  349. $this: _self,
  350. canvasId: canvasId,
  351. type: 'column',
  352. padding: [15, 15, 0, 15],
  353. legend: {
  354. show: true,
  355. padding: 5,
  356. lineHeight: 11,
  357. margin: 0,
  358. },
  359. fontSize: 11,
  360. background: '#FFFFFF',
  361. pixelRatio: _self.pixelRatio,
  362. animation: false,
  363. categories: chartData.categories,
  364. series: chartData.series,
  365. xAxis: {
  366. disableGrid: true,
  367. },
  368. yAxis: {
  369. format: (val) => {
  370. return val.toFixed(0) + '元'
  371. }
  372. },
  373. dataLabel: true,
  374. width: _self.cWidth * _self.pixelRatio,
  375. height: _self.cHeight * _self.pixelRatio,
  376. extra: {
  377. column: {
  378. type: 'group',
  379. width: _self.cWidth * _self.pixelRatio * 0.45 / chartData.categories.length
  380. }
  381. }
  382. });
  383. },
  384. showColumnMeter(canvasId, chartData) {
  385. canvasObj[canvasId] = new uCharts({
  386. $this: _self,
  387. canvasId: canvasId,
  388. type: 'column',
  389. padding: [15, 15, 0, 15],
  390. legend: {
  391. show: true,
  392. padding: 5,
  393. lineHeight: 11,
  394. margin: 0,
  395. },
  396. fontSize: 11,
  397. background: '#FFFFFF',
  398. pixelRatio: _self.pixelRatio,
  399. animation: false,
  400. categories: chartData.categories,
  401. series: chartData.series,
  402. xAxis: {
  403. disableGrid: true,
  404. },
  405. yAxis: {
  406. //disabled:true
  407. },
  408. dataLabel: true,
  409. width: _self.cWidth * _self.pixelRatio,
  410. height: _self.cHeight * _self.pixelRatio,
  411. extra: {
  412. column: {
  413. type: 'meter',
  414. width: _self.cWidth * _self.pixelRatio * 0.45 / chartData.categories.length,
  415. meter: {
  416. border: 4,
  417. fillColor: '#E5FDC3'
  418. }
  419. }
  420. }
  421. });
  422. },
  423. showLineA(canvasId, chartData) {
  424. canvasObj[canvasId] = new uCharts({
  425. $this: _self,
  426. canvasId: canvasId,
  427. type: 'line',
  428. fontSize: 11,
  429. padding: [15, 15, 0, 15],
  430. legend: {
  431. show: true,
  432. padding: 5,
  433. lineHeight: 11,
  434. margin: 5,
  435. },
  436. dataLabel: false,
  437. dataPointShape: false,
  438. background: '#FFFFFF',
  439. pixelRatio: _self.pixelRatio,
  440. categories: chartData.categories,
  441. series: chartData.series,
  442. animation: false,
  443. enableScroll: true, //开启图表拖拽功能
  444. xAxis: {
  445. disableGrid: false,
  446. type: 'grid',
  447. gridType: 'dash',
  448. itemCount: 4,
  449. scrollShow: true,
  450. scrollAlign: 'left',
  451. //scrollBackgroundColor:'#F7F7FF',//可不填写,配合enableScroll图表拖拽功能使用,X轴滚动条背景颜色,默认为 #EFEBEF
  452. //scrollColor:'#DEE7F7',//可不填写,配合enableScroll图表拖拽功能使用,X轴滚动条颜色,默认为 #A6A6A6
  453. },
  454. yAxis: {
  455. //disabled:true
  456. gridType: 'dash',
  457. splitNumber: 8,
  458. min: 10,
  459. max: 180,
  460. format: (val) => {
  461. return val.toFixed(0) + '元'
  462. } //如不写此方法,Y轴刻度默认保留两位小数
  463. },
  464. width: _self.cWidth * _self.pixelRatio,
  465. height: _self.cHeight * _self.pixelRatio,
  466. dataLabel: true,
  467. dataPointShape: true,
  468. extra: {
  469. lineStyle: 'straight'
  470. },
  471. });
  472. },
  473. showLineB(canvasId, chartData) {
  474. canvasObj[canvasId] = new uCharts({
  475. $this: _self,
  476. canvasId: canvasId,
  477. type: 'line',
  478. fontSize: 11,
  479. padding: [15, 15, 0, 15],
  480. legend: {
  481. show: true,
  482. padding: 5,
  483. lineHeight: 11,
  484. margin: 5,
  485. },
  486. background: '#FFFFFF',
  487. pixelRatio: _self.pixelRatio,
  488. rotate: true, //开启图表横屏
  489. // #ifdef MP-ALIPAY
  490. rotateLock: true, //百度及支付宝需要锁定旋转
  491. // #endif
  492. categories: chartData.categories,
  493. animation: false,
  494. series: chartData.series,
  495. xAxis: {
  496. disableGrid: true,
  497. },
  498. yAxis: {
  499. //disabled:true
  500. },
  501. width: _self.cWidth2 * _self.pixelRatio,
  502. height: _self.cHeight2 * _self.pixelRatio,
  503. dataLabel: true,
  504. dataPointShape: true,
  505. extra: {
  506. lineStyle: 'curve'
  507. },
  508. });
  509. },
  510. showArea(canvasId, chartData) {
  511. canvasObj[canvasId] = new uCharts({
  512. $this: _self,
  513. canvasId: canvasId,
  514. type: 'area',
  515. fontSize: 11,
  516. padding: [0, 15, 10, 15],
  517. legend: {
  518. show: true,
  519. position: 'top',
  520. float: 'center',
  521. itemGap: 30,
  522. padding: 5,
  523. lineHeight: 18,
  524. margin: 0,
  525. },
  526. dataLabel: false,
  527. dataPointShape: true,
  528. background: '#FFFFFF',
  529. pixelRatio: _self.pixelRatio,
  530. categories: chartData.categories,
  531. series: chartData.series,
  532. animation: false,
  533. xAxis: {
  534. type: 'grid',
  535. gridColor: '#CCCCCC',
  536. gridType: 'dash',
  537. dashLength: 8,
  538. boundaryGap: 'justify' //两端不留白配置
  539. },
  540. yAxis: {
  541. gridType: 'dash',
  542. gridColor: '#CCCCCC',
  543. dashLength: 8,
  544. splitNumber: 5,
  545. },
  546. width: _self.cWidth * _self.pixelRatio,
  547. height: _self.cHeight * _self.pixelRatio,
  548. extra: {
  549. area: {
  550. type: 'curve',
  551. opacity: 0.2,
  552. addLine: true,
  553. width: 2
  554. }
  555. }
  556. });
  557. },
  558. showPie(canvasId, chartData) {
  559. canvasObj[canvasId] = new uCharts({
  560. $this: _self,
  561. canvasId: canvasId,
  562. type: 'pie',
  563. fontSize: 11,
  564. padding: [15, 15, 0, 15],
  565. legend: {
  566. show: true,
  567. padding: 5,
  568. lineHeight: 11,
  569. margin: 0,
  570. },
  571. background: '#FFFFFF',
  572. pixelRatio: _self.pixelRatio,
  573. series: chartData.series,
  574. animation: false,
  575. width: _self.cWidth * _self.pixelRatio,
  576. height: _self.cHeight * _self.pixelRatio,
  577. dataLabel: true,
  578. extra: {
  579. pie: {
  580. lableWidth: 15
  581. }
  582. },
  583. });
  584. },
  585. showRing(canvasId, chartData) {
  586. canvasObj[canvasId] = new uCharts({
  587. $this: _self,
  588. canvasId: canvasId,
  589. type: 'ring',
  590. fontSize: 11,
  591. padding: [5, 5, 5, 5],
  592. legend: {
  593. show: true,
  594. position: 'right',
  595. float: 'center',
  596. itemGap: 10,
  597. padding: 5,
  598. lineHeight: 26,
  599. margin: 5,
  600. //backgroundColor:'rgba(41,198,90,0.2)',
  601. //borderColor :'rgba(41,198,90,0.5)',
  602. borderWidth: 1
  603. },
  604. title: {
  605. name: '70%',
  606. color: '#7cb5ec',
  607. fontSize: 25 * _self.pixelRatio,
  608. },
  609. subtitle: {
  610. name: '收益率',
  611. color: '#666666',
  612. fontSize: 15 * _self.pixelRatio,
  613. },
  614. extra: {
  615. pie: {
  616. lableWidth: 15,
  617. ringWidth: 40 * _self.pixelRatio, //圆环的宽度
  618. offsetAngle: 0 //圆环的角度
  619. }
  620. },
  621. background: '#FFFFFF',
  622. pixelRatio: _self.pixelRatio,
  623. series: chartData.series,
  624. animation: false,
  625. width: _self.cWidth * _self.pixelRatio,
  626. height: _self.cHeight * _self.pixelRatio,
  627. disablePieStroke: true,
  628. dataLabel: true,
  629. });
  630. },
  631. showFunnel(canvasId, chartData) {
  632. canvasObj[canvasId] = new uCharts({
  633. $this: _self,
  634. canvasId: canvasId,
  635. type: 'funnel',
  636. fontSize: 11,
  637. padding: [15, 15, 0, 15],
  638. legend: {
  639. show: true,
  640. padding: 5,
  641. lineHeight: 11,
  642. margin: 0,
  643. },
  644. background: '#FFFFFF',
  645. pixelRatio: _self.pixelRatio,
  646. series: chartData.series,
  647. animation: false,
  648. width: _self.cWidth * _self.pixelRatio,
  649. height: _self.cHeight * _self.pixelRatio,
  650. dataLabel: true,
  651. extra: {
  652. funnel: {
  653. border: true,
  654. borderWidth: 2,
  655. borderColor: '#FFFFFF'
  656. }
  657. },
  658. });
  659. },
  660. showRadar(canvasId, chartData) {
  661. canvasObj[canvasId] = new uCharts({
  662. $this: _self,
  663. canvasId: canvasId,
  664. type: 'radar',
  665. fontSize: 11,
  666. padding: [15, 15, 0, 15],
  667. legend: {
  668. show: true,
  669. padding: 5,
  670. lineHeight: 11,
  671. margin: 0,
  672. },
  673. background: '#FFFFFF',
  674. pixelRatio: _self.pixelRatio,
  675. animation: false,
  676. dataLabel: true,
  677. categories: chartData.categories,
  678. series: chartData.series,
  679. width: _self.cWidth * _self.pixelRatio,
  680. height: _self.cHeight * _self.pixelRatio,
  681. extra: {
  682. radar: {
  683. max: 200 //雷达数值的最大值
  684. }
  685. }
  686. });
  687. },
  688. showArcbar(canvasId, chartData) {
  689. new uCharts({
  690. $this: _self,
  691. canvasId: canvasId,
  692. type: 'arcbar',
  693. fontSize: 11,
  694. title: {
  695. name: Math.round(chartData.series[0].data * 100) + '%',
  696. color: chartData.series[0].color,
  697. fontSize: 25 * _self.pixelRatio
  698. },
  699. subtitle: {
  700. name: chartData.series[0].name,
  701. color: '#666666',
  702. fontSize: 15 * _self.pixelRatio
  703. },
  704. extra: {
  705. arcbar: {
  706. type: 'default',
  707. width: _self.arcbarWidth * _self.pixelRatio, //圆弧的宽度
  708. }
  709. },
  710. background: '#FFFFFF',
  711. pixelRatio: _self.pixelRatio,
  712. series: chartData.series,
  713. animation: false,
  714. width: _self.cWidth3 * _self.pixelRatio,
  715. height: _self.cHeight3 * _self.pixelRatio,
  716. dataLabel: true,
  717. });
  718. },
  719. showArcbar2(canvasId, chartData) {
  720. new uCharts({
  721. $this: _self,
  722. canvasId: canvasId,
  723. type: 'arcbar',
  724. fontSize: 11,
  725. title: {
  726. name: Math.round(chartData.series[0].data * 100) + '%',
  727. color: chartData.series[0].color,
  728. fontSize: 25 * _self.pixelRatio
  729. },
  730. subtitle: {
  731. name: chartData.series[0].name,
  732. color: '#666666',
  733. fontSize: 15 * _self.pixelRatio
  734. },
  735. extra: {
  736. arcbar: {
  737. type: 'default',
  738. width: _self.arcbarWidth * _self.pixelRatio, //圆弧的宽度
  739. backgroundColor: '#ffe3e8',
  740. startAngle: 1.25,
  741. endAngle: 0.75
  742. }
  743. },
  744. background: '#FFFFFF',
  745. pixelRatio: _self.pixelRatio,
  746. series: chartData.series,
  747. animation: false,
  748. width: _self.cWidth3 * _self.pixelRatio,
  749. height: _self.cHeight3 * _self.pixelRatio,
  750. dataLabel: true,
  751. });
  752. },
  753. showArcbar3(canvasId, chartData) {
  754. new uCharts({
  755. $this: _self,
  756. canvasId: canvasId,
  757. type: 'arcbar',
  758. fontSize: 11,
  759. title: {
  760. name: Math.round(chartData.series[0].data * 100) + '%',
  761. color: chartData.series[0].color,
  762. fontSize: 25 * _self.pixelRatio
  763. },
  764. subtitle: {
  765. name: chartData.series[0].name,
  766. color: '#666666',
  767. fontSize: 15 * _self.pixelRatio
  768. },
  769. extra: {
  770. arcbar: {
  771. type: 'circle', //整圆类型进度条图
  772. width: _self.arcbarWidth * _self.pixelRatio, //圆弧的宽度
  773. startAngle: 0.5 //整圆类型只需配置起始角度即可
  774. }
  775. },
  776. background: '#FFFFFF',
  777. pixelRatio: _self.pixelRatio,
  778. series: chartData.series,
  779. animation: false,
  780. width: _self.cWidth3 * _self.pixelRatio,
  781. height: _self.cHeight3 * _self.pixelRatio,
  782. dataLabel: true,
  783. });
  784. },
  785. showGauge(canvasId, chartData) {
  786. canvasObj[canvasId] = new uCharts({
  787. $this: _self,
  788. canvasId: canvasId,
  789. type: 'gauge',
  790. fontSize: 11,
  791. title: {
  792. name: Math.round(chartData.series[0].data * 100) + '%',
  793. color: chartData.categories[1].color,
  794. fontSize: 25 * _self.pixelRatio,
  795. offsetY: 50 * _self.pixelRatio, //新增参数,自定义调整Y轴文案距离
  796. },
  797. subtitle: {
  798. name: chartData.series[0].name,
  799. color: '#666666',
  800. fontSize: 15 * _self.pixelRatio,
  801. offsetY: -50 * _self.pixelRatio, //新增参数,自定义调整Y轴文案距离
  802. },
  803. extra: {
  804. gauge: {
  805. type: 'default',
  806. width: _self.gaugeWidth * _self.pixelRatio, //仪表盘背景的宽度
  807. startAngle: 0.75,
  808. endAngle: 0.25,
  809. startNumber: 0,
  810. endNumber: 100,
  811. splitLine: {
  812. fixRadius: 0,
  813. splitNumber: 10,
  814. width: _self.gaugeWidth * _self.pixelRatio, //仪表盘背景的宽度
  815. color: '#FFFFFF',
  816. childNumber: 5,
  817. childWidth: _self.gaugeWidth * 0.4 * _self.pixelRatio, //仪表盘背景的宽度
  818. },
  819. pointer: {
  820. width: _self.gaugeWidth * 0.8 * _self.pixelRatio, //指针宽度
  821. color: 'auto'
  822. }
  823. }
  824. },
  825. background: '#FFFFFF',
  826. pixelRatio: _self.pixelRatio,
  827. categories: chartData.categories,
  828. series: chartData.series,
  829. animation: true,
  830. width: _self.cWidth * _self.pixelRatio,
  831. height: _self.cHeight * _self.pixelRatio,
  832. dataLabel: true,
  833. });
  834. },
  835. changeGaugeData() {
  836. let series = [{
  837. name: "完成率",
  838. data: Math.random()
  839. }]; //这里是随机数据,生产环境请从服务器获取,注意series数据类型为数组
  840. //这里我借用之前的categories数据,判断一下新数据的title.color,没有写死在程序里,以便于自定义
  841. let newTitleColor;
  842. for (let i = 0; i < _self.serverData.Gauge.categories.length; i++) {
  843. if (series[0].data <= _self.serverData.Gauge.categories[i].value) {
  844. newTitleColor = _self.serverData.Gauge.categories[i].color;
  845. break;
  846. }
  847. }
  848. canvasObj['canvasGauge'].updateData({
  849. series: series, //这里给了新数值
  850. categories: _self.serverData.Gauge.categories,
  851. title: {
  852. name: Math.round(series[0].data * 100) + '%',
  853. color: newTitleColor,
  854. fontSize: 25 * _self.pixelRatio,
  855. offsetY: 50 * _self.pixelRatio, //新增参数,自定义调整Y轴文案距离
  856. },
  857. subtitle: {
  858. name: '更新数据',
  859. color: '#666666',
  860. fontSize: 15 * _self.pixelRatio,
  861. offsetY: -50 * _self.pixelRatio, //新增参数,自定义调整Y轴文案距离
  862. }
  863. });
  864. },
  865. showCandle(canvasId, chartData) {
  866. canvasObj[canvasId] = new uCharts({
  867. $this: _self,
  868. canvasId: canvasId,
  869. type: 'candle',
  870. fontSize: 11,
  871. padding: [15, 15, 0, 15],
  872. legend: {
  873. show: true,
  874. padding: 5,
  875. lineHeight: 11,
  876. margin: 8,
  877. },
  878. background: '#FFFFFF',
  879. pixelRatio: _self.pixelRatio,
  880. enableMarkLine: true,
  881. /***需要开启标记线***/
  882. categories: chartData.categories,
  883. series: chartData.series,
  884. animation: true,
  885. enableScroll: true, //开启图表拖拽功能
  886. xAxis: {
  887. disableGrid: true, //不绘制X轴网格线
  888. labelCount: 4, //X轴文案数量
  889. //type:'grid',
  890. //gridType:'dash',
  891. itemCount: _self.itemCount, //可不填写,配合enableScroll图表拖拽功能使用,x轴单屏显示数据的数量,默认为5个
  892. scrollShow: true, //新增是否显示滚动条,默认false
  893. scrollAlign: 'right',
  894. //scrollBackgroundColor:'#F7F7FF',//可不填写,配合enableScroll图表拖拽功能使用,X轴滚动条背景颜色,默认为 #EFEBEF
  895. //scrollColor:'#DEE7F7',//可不填写,配合enableScroll图表拖拽功能使用,X轴滚动条颜色,默认为 #A6A6A6
  896. },
  897. yAxis: {
  898. //disabled:true
  899. gridType: 'dash',
  900. splitNumber: 5,
  901. format: (val) => {
  902. return val.toFixed(0)
  903. }
  904. },
  905. width: _self.cWidth * _self.pixelRatio,
  906. height: _self.cHeight * _self.pixelRatio,
  907. dataLabel: false,
  908. dataPointShape: true,
  909. extra: {
  910. candle: {
  911. color: {
  912. upLine: '#f04864',
  913. upFill: '#f04864',
  914. downLine: '#2fc25b',
  915. downFill: '#2fc25b'
  916. },
  917. average: {
  918. show: true,
  919. name: ['MA5', 'MA10', 'MA30'],
  920. day: [5, 10, 20],
  921. color: ['#1890ff', '#2fc25b', '#facc14']
  922. }
  923. },
  924. tooltip: {
  925. bgColor: '#000000',
  926. bgOpacity: 0.7,
  927. gridType: 'dash',
  928. dashLength: 5,
  929. gridColor: '#1890ff',
  930. fontColor: '#FFFFFF',
  931. horizentalLine: true,
  932. xAxisLabel: true,
  933. yAxisLabel: true,
  934. labelBgColor: '#DFE8FF',
  935. labelBgOpacity: 0.95,
  936. labelAlign: 'left',
  937. labelFontColor: '#666666'
  938. },
  939. markLine: {
  940. type: 'dash',
  941. dashLength: 5,
  942. data: [{
  943. value: 2150,
  944. lineColor: '#f04864',
  945. showLabel: true
  946. }, {
  947. value: 2350,
  948. lineColor: '#f04864',
  949. showLabel: true
  950. }]
  951. }
  952. }
  953. });
  954. },
  955. touchCandle(e) {
  956. canvasObj['canvasCandle'].scrollStart(e);
  957. },
  958. moveCandle(e) {
  959. canvasObj['canvasCandle'].scroll(e);
  960. },
  961. touchEndCandle(e) {
  962. canvasObj['canvasCandle'].scrollEnd(e);
  963. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  964. canvasObj['canvasCandle'].showToolTip(e, {
  965. format: function(item, category) {
  966. return category + ' ' + item.name + ':' + item.data
  967. }
  968. });
  969. },
  970. changeData() {
  971. canvasObj['canvasColumn'].updateData({
  972. series: _self.serverData.ColumnB.series,
  973. categories: _self.serverData.ColumnB.categories
  974. });
  975. },
  976. touchLineA(e) {
  977. canvasObj['canvasLineA'].scrollStart(e);
  978. },
  979. moveLineA(e) {
  980. canvasObj['canvasLineA'].scroll(e);
  981. },
  982. touchEndLineA(e) {
  983. canvasObj['canvasLineA'].scrollEnd(e);
  984. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  985. canvasObj['canvasLineA'].showToolTip(e, {
  986. format: function(item, category) {
  987. return category + ' ' + item.name + ':' + item.data
  988. }
  989. });
  990. },
  991. showMix(canvasId, chartData) {
  992. canvasObj[canvasId] = new uCharts({
  993. $this: _self,
  994. canvasId: canvasId,
  995. type: 'mix',
  996. fontSize: 11,
  997. padding: [15, 15, 0, 15],
  998. legend: {
  999. show: true,
  1000. padding: 5,
  1001. lineHeight: 11,
  1002. margin: 6,
  1003. },
  1004. background: '#FFFFFF',
  1005. pixelRatio: _self.pixelRatio,
  1006. categories: chartData.categories,
  1007. series: chartData.series,
  1008. animation: false,
  1009. enableScroll: true, //开启图表拖拽功能
  1010. xAxis: {
  1011. disableGrid: false,
  1012. type: 'grid',
  1013. gridType: 'dash',
  1014. itemCount: 4,
  1015. scrollShow: true,
  1016. scrollAlign: 'left',
  1017. },
  1018. yAxis: {
  1019. gridType: 'dash',
  1020. dashLength: 4,
  1021. splitNumber: 5,
  1022. min: 10,
  1023. max: 180,
  1024. format: (val) => {
  1025. return val.toFixed(0)
  1026. }
  1027. },
  1028. width: _self.cWidth * _self.pixelRatio,
  1029. height: _self.cHeight * _self.pixelRatio,
  1030. dataLabel: true,
  1031. dataPointShape: true,
  1032. extra: {
  1033. column: {
  1034. width: 20 * _self.pixelRatio
  1035. },
  1036. tooltip: {
  1037. bgColor: '#000000',
  1038. bgOpacity: 0.7,
  1039. gridType: 'dash',
  1040. dashLength: 8,
  1041. gridColor: '#1890ff',
  1042. fontColor: '#FFFFFF',
  1043. horizentalLine: true,
  1044. xAxisLabel: true,
  1045. yAxisLabel: true,
  1046. labelBgColor: '#DFE8FF',
  1047. labelBgOpacity: 0.95,
  1048. labelAlign: 'left',
  1049. labelFontColor: '#666666'
  1050. }
  1051. },
  1052. });
  1053. },
  1054. touchMix(e) {
  1055. canvasObj['canvasMix'].scrollStart(e);
  1056. },
  1057. moveMix(e) {
  1058. canvasObj['canvasMix'].scroll(e);
  1059. },
  1060. touchEndMix(e) {
  1061. canvasObj['canvasMix'].scrollEnd(e);
  1062. canvasObj['canvasMix'].touchLegend(e);
  1063. //下面是toolTip事件,如果滚动后不需要显示,可不填写
  1064. canvasObj['canvasMix'].showToolTip(e, {
  1065. format: function(item, category) {
  1066. return category + ' ' + item.name + ':' + item.data
  1067. }
  1068. });
  1069. },
  1070. touchIt(e, id) {
  1071. canvasObj[id].touchLegend(e, {
  1072. animation: false
  1073. });
  1074. canvasObj[id].showToolTip(e, {
  1075. format: function(item, category) {
  1076. if (typeof item.data === 'object') {
  1077. return category + ' ' + item.name + ':' + item.data.value
  1078. } else {
  1079. return category + ' ' + item.name + ':' + item.data
  1080. }
  1081. }
  1082. });
  1083. },
  1084. touchPie(e, id) {
  1085. canvasObj[id].showToolTip(e, {
  1086. format: function(item) {
  1087. return item.name + ':' + item.data
  1088. }
  1089. });
  1090. },
  1091. /* 图表end */
  1092. }
  1093. }
  1094. </script>
  1095. <style scoped>
  1096. uni-view {
  1097. font-size: 15px;
  1098. }
  1099. .uni-row {
  1100. height: 40px;
  1101. }
  1102. .uni-row-column {
  1103. float: left;
  1104. width: 150rpx;
  1105. height: 40px;
  1106. }
  1107. .grid-item-box {
  1108. flex: 1;
  1109. /* #ifndef APP-NVUE */
  1110. display: flex;
  1111. /* #endif */
  1112. flex-direction: column;
  1113. align-items: center;
  1114. justify-content: center;
  1115. padding: 15px 0;
  1116. }
  1117. .qiun-padding {
  1118. padding: 2%;
  1119. width: 96%;
  1120. }
  1121. .qiun-wrap {
  1122. display: flex;
  1123. flex-wrap: wrap;
  1124. }
  1125. .qiun-rows {
  1126. display: flex;
  1127. flex-direction: row !important;
  1128. }
  1129. .qiun-columns {
  1130. display: flex;
  1131. flex-direction: column !important;
  1132. }
  1133. .qiun-common-mt {
  1134. margin-top: 10rpx;
  1135. }
  1136. .qiun-bg-white {
  1137. background: #FFFFFF;
  1138. }
  1139. .qiun-title-bar {
  1140. width: 96%;
  1141. padding: 10rpx 2%;
  1142. flex-wrap: nowrap;
  1143. }
  1144. .qiun-title-dot-light {
  1145. border-left: 10rpx solid #0ea391;
  1146. padding-left: 10rpx;
  1147. font-size: 32rpx;
  1148. color: #000000
  1149. }
  1150. /* 通用样式 */
  1151. .qiun-charts {
  1152. width: 750rpx;
  1153. height: 500rpx;
  1154. background-color: #FFFFFF;
  1155. }
  1156. .qiun-charts1 {
  1157. width: 750rpx;
  1158. height: 100rpx;
  1159. padding: 5px 10px;
  1160. background-color: #FFFFFF;
  1161. }
  1162. .charts {
  1163. width: 750rpx;
  1164. height: 500rpx;
  1165. background-color: #FFFFFF;
  1166. }
  1167. /* 横屏样式 */
  1168. .qiun-charts-rotate {
  1169. width: 700rpx;
  1170. height: 1100rpx;
  1171. background-color: #FFFFFF;
  1172. padding: 25rpx;
  1173. }
  1174. .charts-rotate {
  1175. width: 700rpx;
  1176. height: 1100rpx;
  1177. background-color: #FFFFFF;
  1178. }
  1179. /* 圆弧进度样式 */
  1180. .qiun-charts3 {
  1181. width: 750rpx;
  1182. height: 250rpx;
  1183. background-color: #FFFFFF;
  1184. position: relative;
  1185. }
  1186. .charts3 {
  1187. position: absolute;
  1188. width: 250rpx;
  1189. height: 250rpx;
  1190. background-color: #FFFFFF;
  1191. }
  1192. .qiun-tip {
  1193. display: block;
  1194. width: auto;
  1195. overflow: hidden;
  1196. padding: 15rpx;
  1197. height: 30rpx;
  1198. line-height: 30rpx;
  1199. margin: 10rpx;
  1200. background: #ff9933;
  1201. font-size: 30rpx;
  1202. border-radius: 8rpx;
  1203. justify-content: center;
  1204. text-align: center;
  1205. border: 1px solid #dc7004;
  1206. color: #FFFFFF;
  1207. }
  1208. .gree {
  1209. color: #09BB07;
  1210. }
  1211. .orange {
  1212. color: orange;
  1213. }
  1214. .gray {
  1215. color: #E0E0E0;
  1216. }
  1217. </style>