123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- <template>
- <view style="margin-bottom: 60upx;">
- <view class="achievementTotal">
- <view>
- <view><text>0</text></view>
- <view><text>年度签单保费</text></view>
- </view>
- <view>
- <view><text>0</text></view>
- <view><text>年度成交单数</text></view>
- </view>
- <view>
- <view><text>0</text></view>
- <view><text>年度单均保费</text></view>
- </view>
- </view>
- <view class="qiun-charts">
- <view class="qiun-title">日度报表统计图</view>
- <canvas canvas-id="canvasMix" id="canvasMix" class="charts" disable-scroll=true @touchstart="touchMix" @touchmove="moveMix"
- @touchend="touchEndMix"></canvas>
- <navigator url="../daysAchievement/daysAchievement">
- <view class="row d-flex a-center">
- <view>日度业务分析</view>
- <view>></view>
- </view>
- </navigator>
- </view>
- <view class="qiun-charts">
- <view class="qiun-title">月度报表统计图</view>
- <canvas canvas-id="canvasMix1" id="canvasMix1" class="charts" disable-scroll=true @touchstart="touchMix1" @touchmove="moveMix1"
- @touchend="touchEndMix1"></canvas>
- <navigator url="../monthsAchievement/monthsAchievement">
- <view class="row d-flex a-center">
- <view>月度业务分析</view>
- <view>></view>
- </view>
- </navigator>
- </view>
- </view>
- </template>
- <script>
- import uCharts from '@/components/modules/tools/achievement/u-charts/u-charts.js';
- var _self;
- var canvaMix = null;
- var canvaMix1 = null;
- export default {
- data() {
- return {
- cWidth: '',
- cHeight: '',
- pixelRatio: 1,
- }
- },
- onLoad() {
- _self = this;
- this.cWidth = uni.upx2px(750);
- this.cHeight = uni.upx2px(500);
- this.getServerData();
- },
- methods: {
- getServerData() {
- uni.request({
- url: 'https://www.ucharts.cn/data.json',
- data: {},
- success: function(res) {
- console.log(res.data.data)
- let Mix = {
- categories: [],
- series: []
- };
- //这里我后台返回的是数组,所以用等于,如果您后台返回的是单条数据,需要push进去
- Mix.categories = res.data.data.Mix.categories;
- Mix.series = res.data.data.Mix.series;
- _self.showMix("canvasMix", Mix);
- _self.showMix1("canvasMix1", Mix);
- },
- fail: () => {
- _self.tips = "网络错误,小程序端请检查合法域名";
- },
- });
- },
- showMix(canvasId, chartData) {
- canvaMix = new uCharts({
- $this: _self,
- canvasId: canvasId,
- type: 'mix',
- fontSize: 11,
- legend: {
- show: true
- },
- background: '#FFFFFF',
- pixelRatio: _self.pixelRatio,
- categories: chartData.categories,
- series: chartData.series,
- animation: true,
- enableScroll: true, //开启图表拖拽功能
- xAxis: {
- disableGrid: false,
- type: 'grid',
- gridType: 'dash',
- itemCount: 4,
- scrollShow: true,
- scrollAlign: 'left',
- },
- yAxis: {
- gridType: 'dash',
- splitNumber: 5,
- min: 10,
- max: 180,
- format: (val) => {
- return val.toFixed(0)
- }
- },
- width: _self.cWidth * _self.pixelRatio,
- height: _self.cHeight * _self.pixelRatio,
- dataLabel: true,
- dataPointShape: true,
- extra: {
- tooltip: {
- bgColor: '#000000',
- bgOpacity: 0.7,
- gridType: 'dash',
- dashLength: 8,
- gridColor: '#1890ff',
- fontColor: '#FFFFFF',
- horizentalLine: true,
- xAxisLabel: true,
- yAxisLabel: true,
- labelBgColor: '#DFE8FF',
- labelBgOpacity: 0.95,
- labelAlign: 'left',
- labelFontColor: '#666666'
- }
- },
- });
- },
- showMix1(canvasId, chartData) {
- canvaMix1 = new uCharts({
- $this: _self,
- canvasId: canvasId,
- type: 'mix',
- fontSize: 11,
- legend: {
- show: true
- },
- background: '#FFFFFF',
- pixelRatio: _self.pixelRatio,
- categories: chartData.categories,
- series: chartData.series,
- animation: true,
- enableScroll: true, //开启图表拖拽功能
- xAxis: {
- disableGrid: false,
- type: 'grid',
- gridType: 'dash',
- itemCount: 4,
- scrollShow: true,
- scrollAlign: 'left',
- },
- yAxis: {
- gridType: 'dash',
- splitNumber: 5,
- min: 10,
- max: 180,
- format: (val) => {
- return val.toFixed(0)
- }
- },
- width: _self.cWidth * _self.pixelRatio,
- height: _self.cHeight * _self.pixelRatio,
- dataLabel: true,
- dataPointShape: true,
- extra: {
- tooltip: {
- bgColor: '#000000',
- bgOpacity: 0.7,
- gridType: 'dash',
- dashLength: 8,
- gridColor: '#1890ff',
- fontColor: '#FFFFFF',
- horizentalLine: true,
- xAxisLabel: true,
- yAxisLabel: true,
- labelBgColor: '#DFE8FF',
- labelBgOpacity: 0.95,
- labelAlign: 'left',
- labelFontColor: '#666666'
- }
- },
- });
- },
- touchMix(e) {
- canvaMix.scrollStart(e);
- },
- touchMix1(e) {
- canvaMix1.scrollStart(e);
- },
- moveMix(e) {
- canvaMix.scroll(e);
- },
- moveMix1(e) {
- canvaMix1.scroll(e);
- },
- touchEndMix(e) {
- canvaMix.scrollEnd(e);
- //下面是toolTip事件,如果滚动后不需要显示,可不填写
- canvaMix.showToolTip(e, {
- format: function(item, category) {
- return category + ' ' + item.name + ':' + item.data
- }
- });
- },
- touchEndMix1(e) {
- canvaMix1.scrollEnd(e);
- //下面是toolTip事件,如果滚动后不需要显示,可不填写
- canvaMix1.showToolTip(e, {
- format: function(item, category) {
- return category + ' ' + item.name + ':' + item.data
- }
- });
- }
- }
- }
- </script>
- <style scoped>
- .achievementTotal {
- display: flex;
- flex-wrap: nowrap;
- justify-content: space-between;
- padding: 25upx 30upx;
- font-size: 28upx;
- border-bottom: 10upx solid #ccc;
- }
- .achievementTotal view {
- text-align: center;
- }
- .qiun-title {
- height: 70upx;
- line-height: 70upx;
- font-size: 30upx;
- font-weight: bold;
- padding: 0upx 20upx;
- background: #FAFAFA;
- }
- .charts {
- width: 750upx;
- height: 500upx;
- background-color: #FFFFFF;
- }
- .qiun-charts .row {
- line-height: 80upx;
- height: 80upx;
- padding: 0 30upx;
- font-size: 30upx;
- display: flex;
- justify-content: space-between;
- border-top: 1px solid #ccc;
- border-bottom: 1px solid #ccc;
- }
- </style>
|