uniapp uses charts (line, column, pie, radar, pyramid, etc.)

Look at the effects first: (This is just a random screenshot of a few effects for everyone to see. There are many, I’m afraid you won’t be able to use them all... Continue below see)

        

 

 


 Without further ado, let’s go straight to the tutorial: (Follow step by step, it only takes 15 seconds to display the effect of your page)

1: Import the plug-in directly into HBuliderX: (click to open the URL)

antv F2 v3 - DCloud plug-in market

                        Click to download directly 

① Or you can download it from the gitee warehouse, this is the addresslime-f2: ant chart antv F2, uniapp uses F2 chart, fully compatible with small programs, H5 and APP on all platforms ,Nvue

2. This is the official document of the plug-in (including mobile Antv F2, etc., which has various icons for you to use) 

① You don’t need to read this official document first, just look at the third process.

LimeUi - multi-terminal uniapp component library

 3. Partially reference the component (just put it directly in the <script> tag)

import F2 from '@/uni_modules/lime-f2/components/l-f2/f2-all.min.js'; 

 ① Pay attention to one thing; the introduction in the display code below any chart in the official document is this (import F2 from '@antv/f2') Don’t put this, remember, just use the longer one I have above. Got it

4. Just do the CV directly (I randomly created one here to show you the effect)

<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<view class="data-board">
				<l-f2 ref="chart"></l-f2>
			</view>
			</view>
	</view>
</template>
 
<script>
	import F2 from '@/uni_modules/lime-f2/components/l-f2/f2-all.min.js';
	export default {
		data() {
			return {
				
			}
		},
		onLoad() {
 
		},
		mounted() {
			const data = [
				{ genre: 'Sports', sales: 275 },
				{ genre: 'Strategy', sales: 115 },
				{ genre: 'Action', sales: 120 },
				{ genre: 'Shooter', sales: 350 },
				{ genre: 'Other', sales: 150 },
			];
			 
			this.$refs.chart.init(config => {
				const chart = new F2.Chart(config);
				chart.source(data);
				chart.interval()
				.position('genre*sales');
				chart.render();
				// 需要把 chart 返回
				return chart;
			});
		},
		methods: {
 
		}
	}
</script>
 
<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}
 
	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}
 
	.text-area {
		display: flex;
		justify-content: center;
	}
 
	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>

5. This is the effect style after cv is completed (for more chart styles, you can look back at the official document in Article 2)

Summarize:

    There are many charts, such as Baidu chart, Ant chart, uCharts, etc. Here we use antv F2 chart

If you don’t understand something, you can send a private message or leave a message~ 

It’s not easy to create. Just give it a thumbs up and go~

Guess you like

Origin blog.csdn.net/YN2000609/article/details/134692932