index.vue 32 KB

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