echarts折线图展示负值
时间: 2023-09-21 21:09:49 浏览: 173
要在echarts折线图中展示负值,可以使用areaStyle属性来实现。在series数组中的对应折线图对象中,设置areaStyle属性的origin属性值为'start'即可。例如,使用以下代码可以展示负值的折线图:
```javascript
option = {
xAxis: {
type: 'category',
boundaryGap: false,
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [
{
data: [-820, -932, 901, 934, -1290, 1330, 1320],
type: 'line',
areaStyle: {
origin: 'start'
}
}
]
};
```
通过设置areaStyle的origin为'start',areaStyle会一直位于折线图下方,即使数值为负数也会正确显示。<span class="em">1</span>
#### 引用[.reference_title]
- *1* [echarts折线图负值时areaStyle区域色始终在折线下方(负值时会自动在上方)](https://blog.csdn.net/qq_42611074/article/details/128949214)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文