簡體   English   中英

帶有堆疊系列的 Echarts markLine

[英]Echarts markLine with stacked series

我正在嘗試使用 markLine 選項用兩條線系列標記圖表的頂部。 這些線系列是堆疊的,但是當我嘗試使用選項type: max頂部圖形的標記線顯示在圖形下方,因為該值低於顯示的值(我附上圖像以更清晰地顯示)。

如何將 markLine 放在圖表頂部? 我已經看到了y參數,但我必須把它放在我認為不可能的像素中。

這是我對兩個 markLines 的配置:

// First markLine
const markLineAhorro = {
    data: [
      {
        type: 'max',
        label: {
          position: 'middle',
          formatter: params => {
            return `Sólo tienes que invertir: ${params.value.format()} €`
          }
        },
        lineStyle: {
          color: '#212529'
        }
      },
    ]
}

// Second markLine (the one on the top)
const markLineRentabilidad = {
    data: [
      {
        type: 'max',
        label: {
          position: 'middle',
          formatter: params => {
            return `Con tu inversión obtienes: ${params.value.format()} €`
          }
        },
        lineStyle: {
          color: '#212529'
        }
      }
    ]
}

在此處輸入圖像描述

我找到的解決方案是使用coord參數來手動設置我想要的起點和終點的標記。 我使用xAxis參數來設置 markLine 的起點和終點以及我想要設置yAxis的最大值。

然后我調整value參數以顯示我想要的值。

const markLineRentabilidad = {
    data: [
      [
        {
          // Use the same y coord with starting and ending point
          coord: [0, patrimonioMaximo.toString()],
          value: rentabilidad[rentabilidad.length - 1],
        },
        {
          coord: [añosGrafica.length - 1, patrimonioMaximo.toString()],
        }
      ]
    ]
  }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM