Code Monkey home page Code Monkey logo

echarts_elastic's Introduction

echarts_elastic

一个echarts.js图表放大缩小插件

采用typescript开发

源码和已转js的文件已上传

面向对象编程

index.html

<!doctype html>
<html>
	<head>
		<title>vue+chart</title>
		<script src="js/echarts.min.js"></script><!-- 引入echarts.js-->
		<script src="js/echarts_elastic.js"></script><!-- 引入echarts_elastic插件-->
		<style>
			.chart{
				margin:0 auto;
			}
			#but{
				width:310px;
				margin:0 auto;
			}
			.block{
				width:400px;
				margin:0 auto;
			}
		</style>

	</head>

	<body>
		<div id="panel">
				<div id="main" style="width:400px;height:400px"></div>
		</div>
		<button onclick='add()'>放大</button>
		<button onclick='red()'>缩小</button>
		<script src="js/script.js"></script>
	</body>
</html>

script.js文件

    var myChart = echarts.init(document.getElementById('main'));
        var option/*这里只能使用option*/= {
            title: {
                text: 'ECharts 入门教程'
            },
            tooltip: {},
            legend: {
                data:['销量']
            },
            xAxis: {
                data: ["衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"]
            },
            yAxis: {},
            series: [{
                name: '销量',
                type: 'bar',
                data: [5, 20, 36, 10, 10, 20]
            }]
        };
		//echarts 
        myChart.setOption(option);
		//new Elastic对象
		var els= new Elastic('main','panel');
		function add(){
			//调用放大方法
		els.enlarge();
		//渲染图表
		};
		function red(){
			//调用缩小方法
		els.narrow();
		//渲染图表
		}

echarts_elastic's People

Contributors

qiuquanwu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.