ECharts 实现3D椭圆柱状图

1 实现代码 (3D椭圆柱状图)

<body>
    <script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
    <!-- 为ECharts准备一个具备大小(宽高)的Dom -->
    <div id="main" style="width: 600px;height:400px;"></div>
    <script type="text/javascript">
        // 基于准备好的dom,初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));
		var xData = ["优良率", "达标率"];
		var yData = [50, 87.3];
		var color="#19dfdd";
		var shadowColor="#0b5767";
		var barWidth=50;
		var option = {
			backgroundColor: '#05233b',
			"grid": {
				"top": "25%",
				"left": "-5%",
				"bottom": "5%",
				"right": "5%",
				"containLabel": true
			},
			animation: false,
			"xAxis": [{
				"type": "category",
				"data": xData,
				"axisTick": {
					"alignWithLabel": true
				},
				"nameTextStyle": {
					"color": "#82b0ec"
				},
				"axisLine": {
					show: false,
					"lineStyle": {
						"color": "#82b0ec"
					}
				},
				"axisLabel": {
					"textStyle": {
						"color": color
					},
					margin: 30
				}
			}],
			"yAxis": [{
				show: false,
				"type": "value",
				"axisLabel": {
					"textStyle": {
						"color": "#fff"
					},
				},
				"splitLine": {
					"lineStyle": {
						"color": "#0c2c5a"
					}
				},
				"axisLine": {
					"show": false
				}
			}],
			"series": [
				{
					"name": "数据上椭圆",
					type: 'pictorialBar',
					symbolSize: [barWidth, 10],
					symbolOffset: [0, -6],
					symbolPosition: 'end',
					z: 12,
					"label": {
						"normal": {
							"show": true,
							"position": "top",
							fontSize: 14,
							color: color,
							formatter:function(params,index){
								return params.value+"%";
							}
						}
					},
					color: "#2DB1EF",
					data: yData
				},
				{
					name: '下椭圆',
					type: 'pictorialBar',
					symbolSize: [barWidth, 10],
					symbolOffset: [0, 7],
					z: 12,
					"color": color,
					"data": yData
				},
				{
					type: 'bar',
					"barWidth": barWidth,
					barGap: '10%', // Make series be overlap
					barCateGoryGap: '10%',
					itemStyle: {
						normal: {
							color: new echarts.graphic.LinearGradient(0, 0, 0, 0.7, [{
									offset: 0,
									color: "rgba(25,223,221,.7)"
								},
								{
									offset: 1,
									color: "rgba(25,223,221,.3)"
								}
							]),
						},
					},
					data: yData
				},
			]
		};
        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    </script>
</body>

 2 最终效果图(3D椭圆柱状图)

  • 7
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 11
    评论
根据提供的引用内容,没有直接提到如何在ECharts柱状图中添加滚动条两端椭圆的信息。不过,我们可以通过ECharts官方文档中的示例来了解如何实现这个功能。 在ECharts官方文档中,有一个名为“堆叠条形图”的示例,该示例中包含了滚动条两端椭圆的效果。具体实现方法如下: 1.在x轴的配置项中,设置type为'value',boundaryGap为false,使得x轴的刻度线与坐标轴两端对齐。 2.在dataZoom的配置项中,设置show、type、start、end、xAxisIndex等属性,使得滚动条出现在图表底部,并且两端显示椭圆。 下面是示例代码: ```javascript option = { xAxis: { type: 'value', boundaryGap: false }, yAxis: { type: 'category', data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'] }, series: [ { name: '邮件营销', type: 'bar', stack: '总量', label: { show: true, position: 'insideRight' }, data: [320, 302, 301, 334, 390, 330, 320] }, { name: '联盟广告', type: 'bar', stack: '总量', label: { show: true, position: 'insideRight' }, data: [120, 132, 101, 134, 90, 230, 210] }, { name: '视频广告', type: 'bar', stack: '总量', label: { show: true, position: 'insideRight' }, data: [220, 182, 191, 234,290, 330, 310] }, { name: '直接访问', type: 'bar', stack: '总量', label: { show: true, position: 'insideRight' }, data: [150, 212, 201, 154, 190, 330, 410] }, { name: '搜索引擎', type: 'bar', stack: '总量', label: { show: true, position: 'insideRight' }, data: [820, 832, 901, 934, 1290, 1330, 1320] } ], dataZoom: [ { show: true, type: 'slider', start: 0, end: 60, xAxisIndex: [0], handleSize: 20, height: 8, bottom: 0, handleStyle: { color: '#fff', borderWidth: 0, borderColor: '#ddd', shadowBlur: 2, background: '#ddd', shadowColor: '#ddd' }, fillerColor: new echarts.graphic.LinearGradient(1, 0, 0, 0, [{ offset: 0, color: '#2378f7' }, { offset: 1, color: '#83bff6' }]), backgroundColor: '#ddd', dataBackground: { areaStyle: { color: '#ddd' }, lineStyle: { opacity: 0.8, color: '#fff' } }, borderColor: '#aaa', textStyle: { color: '#fff' } } ] }; ```

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值