Incubator-echarts: 折线图label因为showSymbol属性设置为false显示不出来bug

Created on 16 Aug 2018  ·  3Comments  ·  Source: apache/incubator-echarts

One-line summary [问题简述]

折线图label因为showSymbol属性设置为false显示不出来bug

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]:
  • Browser version [浏览器类型和版本]:
  • OS Version [操作系统类型和版本]:
    echarts:4.1.0
    chrome:版本 68.0.3440.84(正式版本) (64 位)
    W7

Expected behaviour [期望结果]

设置了折线图 label.show 为true,该折线图就应该显示出来

ECharts option [ECharts配置项]


option ={
  "xAxis": {
    "show": true,
    "name": "",
    "type": "category"
  },
  "yAxis": {
    "show": true,
    "name": "",
    "type": "value"
  },
  "series": [
    {
      "type": "line",
      "showSymbol": false,
      "itemStyle": {
        "color": "#4191FA"
      },
      "lineStyle": {
        "color": "#4191FA",
        "width": 2,
        "type": "solid"
      },
      "label": {
        "show": true,
        "fontSize": 12,
        "color": "#999999",
        "offset": [
          0,
          0
        ]
      },
      "encode": {
        "x": "x_idata",
        "y": "s_idata"
      }
    }
  ],
  "dataset": {
    "source": [
      [
        "2010/01/01 00:00:00",
        100
      ],
      [
        "2010/01/02 00:00:00",
        160
      ],
      [
        "2010/01/03 00:00:00",
        100
      ],
      [
        "2010/01/04 00:00:00",
        16
      ],
      [
        "2010/01/05 00:00:00",
        100
      ],
      [
        "2010/01/06 00:00:00",
        10
      ]
    ],
    "dimensions": [
      "x_idata",
      "s_idata"
    ]
  }
}

Other comments [其他信息]


bug

Most helpful comment

@shentao1
I checked the code, label is connected with symbol. If showSymbol = false, it won't draw label.
And if you want to show label without symbol, you need to set symbol: 'none' instead of showSymbol: false.
image
However, when I set symbol: 'none', it still doesn't draw label.
I checked the code again, and found a function symbolNeedsDraw.
image
so when symbol: 'none' , this function will return false, it won't draw symbol, neither label.
I think maybe the developer doesn't want to show label without symbol, so I'm not sure whether it is a bug or not.
And I tested, if the condition data.getItemVisual(idx, 'symbol') !== 'none' is removed, we can draw the line chart like this.
image
Hope it helps.

All 3 comments

@shentao1
I checked the code, label is connected with symbol. If showSymbol = false, it won't draw label.
And if you want to show label without symbol, you need to set symbol: 'none' instead of showSymbol: false.
image
However, when I set symbol: 'none', it still doesn't draw label.
I checked the code again, and found a function symbolNeedsDraw.
image
so when symbol: 'none' , this function will return false, it won't draw symbol, neither label.
I think maybe the developer doesn't want to show label without symbol, so I'm not sure whether it is a bug or not.
And I tested, if the condition data.getItemVisual(idx, 'symbol') !== 'none' is removed, we can draw the line chart like this.
image
Hope it helps.

It makes sense to be able to have a label without a symbol, so it's definitely a bug, but this would be a breaking change, is there a long-term plan? Maybe this could be tagged to be implemented for a future major release with a proper CHANGELOG entry.

The case when "showSymbol = false" and "label.show=true" is not handled. So I think we can add a judgment to deal with this case. The way consists of the following steps:

  1. In the function render of line
    9ab9209d3e0959f2bde8e696c
  1. In the function symbolProto.updateData
    3ee35cffc4d0c30849f5d811a

We can draw the line chart like this.
a03102b97758d534de9ea447d

Hope it helps.

Was this page helpful?
0 / 5 - 0 ratings