index.vue 32 KB

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