### Providing an Example Link in Doc
Source: https://github.com/apache/echarts-doc/blob/master/README.md
Create direct links to ECharts examples using the `${galleryEditorPath}` variable. This allows users to view and edit examples.
```markdown
[vertically scrollable legend](${galleryEditorPath}pie-legend&edit=1&reset=1)
[aria pie](${galleryEditorPath}doc-example/aria-pie&edit=1&reset=1)
```
--------------------------------
### Start Development Server
Source: https://github.com/apache/echarts-doc/blob/master/README.md
Run this command to start a static server for local development. It will watch for changes in the doc site source and markdown files, rebuilding as needed.
```shell
npm run dev
```
--------------------------------
### Install ECharts using npm
Source: https://github.com/apache/echarts-doc/blob/master/en/tutorial/getting-started.md
Instructions on how to install the ECharts library using the Node Package Manager (npm). This command adds ECharts as a dependency to your project, allowing you to use it in your web applications.
```bash
npm install echarts --save
```
--------------------------------
### Environment Map Configuration Examples
Source: https://github.com/apache/echarts-doc/blob/master/zh/option-gl/partial/environment.md
Demonstrates configuring the environment map with an image URL, a solid color, or a linear gradient. The gradient example shows a sky-to-ground effect.
```typescript
// 配置为全景贴图
environment: 'asset/starfield.jpg'
// 配置为纯黑色的背景
environment: '#000'
// 配置为垂直渐变的背景
environment: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0, color: '#00aaff' // 天空颜色
}, {
offset: 0.7, color: '#998866' // 地面颜色
}, {
offset: 1, color: '#998866' // 地面颜色
}], false)
```
--------------------------------
### Complete ECharts example with custom tooltip, draggable points, and responsive graphics (HTML/JavaScript)
Source: https://github.com/apache/echarts-doc/blob/master/en/tutorial/drag-example.md
This comprehensive HTML example demonstrates an ECharts line chart with several advanced features. It includes custom tooltip behavior triggered by graphic elements, draggable data points that update the chart in real-time, and responsive graphic element positioning on window resize. The setup covers ECharts initialization, data definition, chart options, and event handlers for interaction.
```html
```
--------------------------------
### Initialize ECharts and draw a basic bar chart in HTML
Source: https://github.com/apache/echarts-doc/blob/master/en/tutorial/getting-started.md
Provides a complete HTML document demonstrating how to initialize an ECharts instance on a prepared DOM element and configure a simple bar chart. It defines chart title, tooltip, legend, axes, and series data, then renders the chart using the setOption method.
```html
ECharts
```
--------------------------------
### Toolbox Configuration Example
Source: https://github.com/apache/echarts-doc/blob/master/en/option/component/toolbox.md
Basic configuration for the toolbox component, showing its visibility and background color.
```javascript
option = {
toolbox: {
show: true,
backgroundColor: 'transparent'
}
};
```
--------------------------------
### Create Scatter Chart with ECharts
Source: https://github.com/apache/echarts-doc/blob/master/asset-src/basic-concepts-overview/make-img.html
Initializes a simple scatter plot chart using ECharts with custom color configuration and data points. Demonstrates basic scatter chart setup with coordinate system axes and direct data array specification.
```JavaScript
var dom0 = document.getElementById('coord-sys0');
var chart0 = echarts.init(dom0, 'vintage');
var option = {
color: ['blue'],
backgroundColor: '#fff',
xAxis: {},
yAxis: {},
series: {
type: 'scatter',
data: [
[13, 44],
[51, 51],
[51, 32],
[67, 19],
[19, 33]
]
}
};
chart0.setOption(option);
```
--------------------------------
### Pictorial Bar Chart Example
Source: https://github.com/apache/echarts-doc/blob/master/en/option/series/pictorialBar.md
A basic example demonstrating the usage of a pictorial bar chart.
```javascript
option = {
series: [{
type: 'pictorialBar',
// ... other options
}]
};
```
--------------------------------
### Matrix dimension structure example
Source: https://github.com/apache/echarts-doc/blob/master/zh/option/partial/matrix-body-corner.md
Example matrix configuration with x and y dimensions containing hierarchical headers. Used to illustrate cell positioning rules and coordinate system.
```javascript
matrix: {
x: [{ value: 'Xa0', children: ['Xb0', 'Xb1'] }, 'Xa1'],
y: [{ value: 'Ya0', children: ['Yb0', 'Yb1'] }],
}
```
--------------------------------
### Embedding ECharts Example in Doc
Source: https://github.com/apache/echarts-doc/blob/master/README.md
Embed ECharts examples directly into documentation using an iframe. Use the `${galleryViewPath}` variable for the example URL. Avoid overuse to maintain performance.
```markdown
~[700X300](${galleryViewPath}pie-legend&edit=1&reset=1)
~[700x300](${galleryViewPath}doc-example/aria-pie&edit=1&reset=1)
```
--------------------------------
### Gauge Detail Formatter Example
Source: https://github.com/apache/echarts-doc/blob/master/en/option/series/gauge.md
Example of using a formatter function to customize the display of the detail value in a gauge chart.
```javascript
formatter: function (value) {
return value.toFixed(0);
}
```
--------------------------------
### Graphic Element Configuration Example
Source: https://github.com/apache/echarts-doc/blob/master/zh/option/component/graphic.md
Configuration for rectangle and text elements including positioning and visual styles.
```javascript
type: 'rect',
left: 'center', // 相对父元素居中
top: 'middle', // 相对父元素居中
shape: {
width: 190,
height: 90
},
style: {
fill: '#fff',
stroke: '#999',
lineWidth: 2,
shadowBlur: 8,
shadowOffsetX: 3,
shadowOffsetY: 3,
shadowColor: 'rgba(0,0,0,0.3)'
}
},
{
type: 'text',
left: 'center', // 相对父元素居中
top: 'middle', // 相对父元素居中
style: {
fill: '#777',
text: [
'This is text',
'这是一段文字',
'Print some text'
].join('\n'),
font: '14px Microsoft YaHei'
}
}
]
}
```
--------------------------------
### Configure Multiple Grids and Subplots with Dataset
Source: https://github.com/apache/echarts-doc/blob/master/asset-src/basic-concepts-overview/make-img.html
This example shows how to define multiple grid components within a single chart instance to create subplots. It utilizes the dataset property for centralized data management and assigns series to specific grids using gridIndex and axisIndex.
```javascript
var dom0 = document.getElementById('coord-sys2');
var chart0 = echarts.init(dom0, 'vintage');
var option = {
dataset: {
source: [
['Jan', 25, 54, 24],
['Feb', 22, 64, 14],
['Mar', 62, 43, 39],
['Apr', 45, 74, 50],
['May', 34, 94, 25],
['Jun', 43, 64, 23],
['Jul', 33, 44, 23],
['Aug', 23, 30, 13],
['Sep', 43, 21, 20],
['Oct', 33, 28, 24],
['Nov', 39, 34, 33],
['Dec', 45, 44, 39]
]
},
grid: [
{ top: 40, bottom: '58%', borderColor: '#ccc', borderWidth: 1, show: true },
{ top: '58%', bottom: 40, borderColor: '#ccc', borderWidth: 1, show: true }
],
xAxis: [
{ type: 'category', splitLine: {show: false}, gridIndex: 0 },
{ type: 'category', splitLine: {show: false}, gridIndex: 1 }
],
yAxis: [
{ splitLine: {show: false}, gridIndex: 0 },
{ splitLine: {show: false}, gridIndex: 1 }
],
series: [
{ type: 'line', xAxisIndex: 0, yAxisIndex: 0 },
{ type: 'line', xAxisIndex: 1, yAxisIndex: 1 },
{ type: 'bar', xAxisIndex: 1, yAxisIndex: 1 }
]
};
chart0.setOption(option);
```
--------------------------------
### Web Audio API Setup and Initialization
Source: https://github.com/apache/echarts-doc/blob/master/slides/custom/asset/ec-demo/audio.html
Loads an MP3 file, decodes it using Web Audio API, creates analyzer and gain nodes, and initiates the visualization loop. Must be called after user interaction for audio playback.
```JavaScript
var UPDATE_DURATION = 100;
window.AudioContext = window.AudioContext || window.webkitAudioContext;
var audioContext = new AudioContext();
var oReq = new XMLHttpRequest();
oReq.open('GET', '../data/music.mp3', true);
oReq.responseType = 'arraybuffer';
oReq.onload = function(e) {
audioContext.decodeAudioData(oReq.response, initVisualizer);
};
oReq.send();
```
--------------------------------
### Configure Calendar Day Label First Day of Week in ECharts
Source: https://github.com/apache/echarts-doc/blob/master/en/option/component/calendar.md
Example of setting the `firstDay` property for the `dayLabel` in the ECharts calendar component, allowing the week to start on a day other than Sunday (e.g., Monday).
```ts
calendar: [{
dayLabel: {
firstDay: 1 // start on Monday
}
}]
```
--------------------------------
### Prepare HTML DOM container for ECharts chart
Source: https://github.com/apache/echarts-doc/blob/master/en/tutorial/getting-started.md
Shows how to create a element in the HTML body with specified width and height. This
serves as the canvas where ECharts will render the chart, and it must be present before initializing an ECharts instance.
```html
```
--------------------------------
### Include ECharts JavaScript library in HTML
Source: https://github.com/apache/echarts-doc/blob/master/en/tutorial/getting-started.md
Demonstrates how to include the ECharts library in an HTML document using a