This article mainly introduces the basic usage of Echarts, and introduces the basic usage and examples of Echarts in detail. If you are interested, you can learn more
echarts is so perfect:
1, open source software, selflessly provides us with a beautiful graphical interface;
2, easy to use, silently encapsulates important js for us , as long as you can quote, you will use echarts;
3, there are many types, echarts provides us with various icons, the most symbolic of which is the map;
4. Good compatibility, excellent animation rendering based on html5.
echarts official website provides source code and documentation. To use echarts, you need to first go to the official website to download the required js source files.
The demo on the official website contains many things that we don’t need. If you want to use the pie chart, you have to remove the unused ones from the demo, leaving only the most original function implementation. . After all, this is more time-consuming, so I will summarize it in the cut code. So the new usage tutorial is as follows:
echarts pie chart implementation steps:
1, introduce js files into simple html
<head> <meta charset="utf-8"> <title>Charts demo</title> <script src="js/esl.js"></script> </head> <body> </body>
2, prepare containers for graphics
<head> <meta charset="utf-8"> <title>Charts demo</title> <script src="js/esl.js"></script> </head> <body> <p id="picturePlace"></p> </body>
Just add a p with a given id in the html, and the chart will be displayed in p.
3, module import js
<head> <meta charset="utf-8"> <title>Charts demo</title> <script src="js/esl.js"></script> </head> <body> <p id="picturePlace"></p> <script type="text/javascript"> // 路径配置 require.config({ paths:{ 'echarts' : 'js/echarts', 'echarts/chart/pie' : 'js/echarts' } }); </script> </body>
4, add display data
<head> <meta charset="utf-8"> <title>Charts demo</title> <script src="js/esl.js"></script> </head> <body> <p id="picturePlace"></p> <script type="text/javascript"> // 路径配置 requireconfig({ paths:{ 'echarts' : 'js/echarts', 'echarts/chart/pie' : 'js/echarts' } }); // 使用 require( [ 'echarts', 'echarts/chart/pie' // 使用柱状图就加载bar模块,按需加载 ], function (ec) { // 基于准备好的dom,初始化echarts图表 var myChart = ec.init(document.getElementById('picturePlace')); option = { title : { text: '某站点用户访问来源', subtext: '纯属虚构', x:'center' }, tooltip : { trigger: 'item', formatter: "{a} {b} : {c} ({d}%)" }, legend: { orient : 'vertical', x : 'left', data:['直接访问','邮件营销','联盟广告','视频广告','搜索引擎'] }, toolbox: { show : true, feature : { mark : {show: true}, dataView : {show: true, readOnly: false}, restore : {show: true}, saveAsImage : {show: true} } }, calculable : true, series : [ { name:'访问来源', type:'pie', radius : '55%', center: ['50%', '60%'], data:[ {value:335, name:'直接访问'}, {value:310, name:'邮件营销'}, {value:234, name:'联盟广告'}, {value:135, name:'视频广告'}, {value:1548, name:'搜索引擎'} ] } ] }; // 为echarts对象加载数据 myChart.setOption(option); } ); </script> </body>
5, run the program to display the result
The above are the steps to implement the pie chart. The histogram scatter chart is similar to this. When referencing js, the pie chart is pie and the histogram is bar. The corresponding The data in the option is different, but the program frame is the same.
The above is the detailed content of Detailed introduction to Echarts usage. For more information, please follow other related articles on the PHP Chinese website!

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version
Chinese version, very easy to use