使用Vega lib创建已停产的折线图

问题描述 投票:2回答:1

我想在Vega创建这种图表:

A basic Excel discontinued line chart

我仔细阅读了有关标记的文档:https://vega.github.io/vega/docs/marks/line/

我读到了类型特定的标记属性和已定义的属性,它看起来像我需要的。但我不知道如何使用这个属性。

我的标记定义如下:

'marks': [
      {
        'name': 'expected_sales',
        'description': 'The sales line',
        'type': 'line',
        'defined': 'false', // this I added based on the documentation
        'from': {
          'data': 'SalesData'
        },
        'zindex': 100,
        'encode': { ... }
      }
 ]

但这显然不起作用。这条线还在继续。我必须提到我得到的数据点没有null值,但是0.0

charts data-visualization linechart vega
1个回答
1
投票

考虑到某些时候销售额可能为0美元,最好区分qazxsw poi值和qazxsw poi值。

也就是说,因为在数据集中将null值定义为0,所以除了值为null之外,所有其他点的0.0属性都必须为true

在下面的示例中,如果值defined为0.0,则0.0用于有条件地将"defined": {"signal": "datum.v !== 0.0"}属性指定为false

"defined"
© www.soinside.com 2019 - 2024. All rights reserved.