【无标题】

代码:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>ECharts</title>
		<!-- 引入刚刚下载的 ECharts 文件 -->
		<script src="echarts.min.js"></script>
	</head>
	<body>
		<!-- 为 ECharts 准备一个定义了宽高的 DOM -->
		<div id="main" style="width: 1200px;height:600px;"></div>
		<script type="text/javascript">
			// 基于准备好的dom,初始化echarts实例
			var myChart = echarts.init(document.getElementById('main'));
			option = {
				title: {
					text: '服装销售'
				},
				tooltip: {
					trigger: 'axis',
					axisPointer: {
						type: 'cross',
						crossStyle: {
							color: '#999'
						}
					}
				},
				toolbox: {
					feature: {
						dataView: {
							show: true,
							readOnly: false
						},
						magicType: {
							show: true,
							type: ['line', 'bar']
						},
						restore: {
							show: true
						},
						saveAsImage: {
							show: true
						}
					}
				},
				legend: {
					data: ['shirt', 'cardigan', 'Chiffon shirt', 'trousers', 'high-heeled shoes', 'Socks', ]
				},
				xAxis: [{
					type: 'category',
					data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月', ],
					axisPointer: {
						type: 'shadow'
					}
				}],
				yAxis: [{
						type: 'value',
						name: '价格',
						min: 0,
						max: 50,
						interval: 10,
						axisLabel: {
							formatter: '元'
						}
					},
					{
						type: 'value',
						name: '价格',
						min: 0,
						max: 25,
						interval: 5,
						axisLabel: {
							formatter: '元'
						}
					}
				],
				series: [
					{
						name: 'shirt',
						type: 'bar',
						tooltip: {
							valueFormatter: function(value) {
								return value + ' 元';
							}
						},
						data: [
							5, 6, 12, 20, 21, 21, 15, 17, 8, 7, 22, 12

						]
					},
					{
						name: 'cardigan',
						type: 'bar',
						tooltip: {
							valueFormatter: function(value) {
								return value + ' 元';
							}
						},
						data: [
							20, 18, 30, 22, 22, 24, 9, 12, 21, 24, 22, 12

						]
					},
					{
						name: 'Chiffon shirt',
						type: 'bar',
						tooltip: {
							valueFormatter: function(value) {
								return value + ' 元';
							}
						},
						data: [
							36, 20, 20, 23, 28, 21, 13, 16, 12, 28, 21, 22

						]
					},
					{
						name: 'trousers',
						type: 'bar',
						tooltip: {
							valueFormatter: function(value) {
								return value + ' 元';
							}
						},
						data: [
							10, 12, 18, 21, 25, 22, 12, 14, 32, 21, 18, 21


						]
					},
					{
						name: 'high-heeled shoes',
						type: 'bar',
						tooltip: {
							valueFormatter: function(value) {
								return value + ' 元';
							}
						},
						data: [
							10, 11, 17, 18, 13, 12, 14, 21, 12, 31, 21, 18

						]
					},
					{
						name: 'Socks',
						type: 'bar',
						tooltip: {
							valueFormatter: function(value) {
								return value + ' 元';
							}
						},
						data: [
							20, 19, 22, 21, 23, 21, 19, 24, 32, 21, 24, 21

						]
					},
				]
			};

			// 使用刚指定的配置项和数据显示图表。
			myChart.setOption(option);
		</script>
	</body>
</html>

运行结果:

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值