uniapp 图表 插件 qiun-data-charts

41 篇文章 0 订阅
<view class="charts-box">
	<!-- 开启onmovetip后,同时开启canvas2d模式(需要传canvasId),否则在小程序端会很卡。-->
     <qiun-data-charts
        type="line"
		:canvas2d="true"
		:canvasId="canvasId"
        :chartData="chartData"
		background="none"
		:ontouch="true"
		:onmovetip="true"
		:animation="false"
		:opts="lineOpts"
		tooltipFormat="tooltipIncome"
      />
</view>

data(){
return {
	chartData: {},
	canvasId: '',
	lineOpts: {
		"type": "line",
		"canvasId": new Date().getTime(),
		"canvas2d": false,
		"background": "none",
		"animation": true,
		"timing": "easeOut",
		"duration": 1000,
		"color": [
			"#47C5FF",
			"#FFCD30",
			"#3DF366"
		],
		"padding": [
			20,
			20,
			10,
			5
		],
		"rotate": false,
		"errorReload": true,
		"fontSize": 12,
		"fontColor": "#999999",
		"enableScroll": false,
		"touchMoveLimit": 60,
		"enableMarkLine": false,
		"dataLabel": false,
		"dataPointShape": false,
		"dataPointShapeType": "solid",
		"xAxis": {
			"disabled": false,
			"axisLine": false,
			"axisLineColor": "#EEEEEE",
			"calibration": false,
			"fontColor": "#999999",
			"fontSize": 12,
			"rotateLabel": false,
			"labelCount": 10, 
			"boundaryGap": "justify",
			"disableGrid": true,
			"gridColor": "#CCCCCC",
			"gridType": "dash",
			"dashLength": 4,
			"gridEval": 1
		},
		"yAxis": {
			"disabled": false,
			"disableGrid": false,
			"splitNumber": 4,
			"gridType": "solid",
			"dashLength": 2,
			"gridColor": "#CCCCCC",
			"padding": 10,
			"showTitle": false,
			"data": [
				{
					"position": "left",
					"disabled": false,
					"axisLine": true,
					"axisLineColor": "#fff",
					"calibration": false,
					"fontColor": "#999999",
					"fontSize": 12,
					"textAlign": "right",
					"title": "",
					"titleFontSize": 13,
					"titleOffsetY": 0,
					"titleOffsetX": 0,
					"titleFontColor": "#666666",
					"min": null,
					"max": null,
					"tofix": 2,
					"unit": "",
					"format": ""
				}
			]
		},
		"legend": {
			"show": true,
			"position": "bottom",
			"float": "center",
			"padding": 5,
			"margin": 5,
			"backgroundColor": "rgba(0,0,0,0)",
			"borderColor": "rgba(0,0,0,0)",
			"borderWidth": 0,
			"fontSize": 12,
			"fontColor": "#999999",
			"lineHeight": 20,
			"hiddenColor": "#CECECE",
			"itemGap": 10
		},
		"extra": {
			"tooltip": {
				"showBox": true,
				"showArrow": true,
				"showCategory": false,
				"borderWidth": 0,
				"borderRadius": 5,
				"borderColor": "#000000",
				"borderOpacity": 0.7,
				"bgColor": "#000000",
				"bgOpacity": 0.7,
				"gridType": "solid",
				"dashLength": 4,
				"gridColor": "#CCCCCC",
				"fontColor": "#FFFFFF",
				"splitLine": true,
				"horizentalLine": false,
				"xAxisLabel": false,
				"yAxisLabel": false,
				"labelBgColor": "#FFFFFF",
				"labelBgOpacity": 0.7,
				"labelFontColor": "#666666"
			},
			"markLine": {
				"type": "solid",
				"dashLength": 4,
				"data": []
			}
		}
	},
}
}

onLoad() {
	this.canvasId = this.randomString();
}

methods: {
// 生成32位随机字符串
randomString() {
	let len = 32;
	let chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
	let maxPos = chars.length;
	let result = '';
	for (let i = 0; i < len; i++) {
		result += chars.charAt(Math.floor(Math.random() * maxPos));
	}
	return result;
}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值