![](/img/trans.png)
[英]How do you set tooltip labels for multiple series using Apache Echarts?
[英]How to properly format multiple rectangle graphics in apache echarts?
我無法找出使用 Apache Echarts 將靜態形狀添加到圖表背景的最佳方法。 我有一個具有多個線系列的圖表,我想提供透明的背景形狀,以便查看者能夠看到數據如何隨着時間的推移落入各種閾值。
我已經想出了如何將形狀添加到圖表中,但是我遇到了兩件事:
我對如何實現這一目標有點茫然。 下面列出的是我用來生成此圖的代碼。 這是我使用的 apache 上的編輯器的鏈接,代碼也應該在那里。
option = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
grid: {
left: '10%',
right: '10%',
top: 60,
bottom: 60
},
graphic: [
{
type: 'group',
left: '10%',
right: '10%',
bottom: 60,
top: 60,
children: [
{
type: 'rect',
shape: {
y: 450,
width: 1000,
height: 200,
},
style: {
fill: 'rgba(0, 255, 0, 0.2)'
}
},
{
type: 'rect',
shape: {
y: 200,
width: 400,
height: 250,
},
style: {
fill: 'rgba(255, 255, 0, 0.2)'
}
},
{
type: 'rect',
shape: {
y: 0,
width: 400,
height: 200,
},
style: {
fill: 'rgba(255, 0, 0, 0.2)'
}
}
]
}
],
series: [
{
data: [150, 230, 224, 218, 135, 147, 260],
type: 'line'
},
{
data: [100, 225, 275, 268, 354, 287, 301],
type: 'line'
}
]
};
我最終找到了一個相當不錯的解決方案。 添加填充區域的無數據系列效果很好,並且很容易實現。
這是代碼:
option = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [
{
data: [150, 230, 224, 218, 135, 147, 260],
type: 'line'
},
{
data: [100, 225, 275, 268, 354, 287, 301],
type: 'line'
},
{
type: 'line',
markArea: {
itemStyle: {
color: 'rgba(0, 255, 0, 0.2)'
},
data: [
[
{
coord: [, 125]
},
{
coord: [, 0]
}
]
]
}
},
{
type: 'line',
markArea: {
itemStyle: {
color: 'rgba(255, 255, 0, 0.2)'
},
data: [
[
{
coord: [, 275]
},
{
coord: [, 125]
}
]
]
}
},
{
type: 'line',
markArea: {
itemStyle: {
color: 'rgba(255, 0, 0, 0.2)'
},
data: [
[
{
coord: [, 275]
},
{
coord: [, ]
}
]
]
}
}
]
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.