如何将垂直规则添加为新图层和相同的x轴?

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

enter image description here

[将条带添加为新层时(在2层图表中,停止工作:没有可视化,并且“ WARN无法在没有字段的编码通道” y“上投影选择”] >。

当只有两行时,前两个图层定义下面的工作正常。

vglSpec.push(['#vis2a',{
    $schema: vglVers,
    data: {"url":"MyDataset1"},
    // old "encoding": { x: {"field": "instant", "type": "temporal"} }
    width:680,
    layer: [
        {
            "mark": {"stroke": "#68C", "type": "line", "point": true},
            "encoding": { x: {"field": "instant", "type": "temporal"}, "y": {
                "field": "n_count", 
                "type": "quantitative"
            }},
            "selection": {"grid": {"type":"interval", "bind":"scales"}}   //zoom
        },
        {
            "mark": {"stroke": "red", "type": "line", "strokeOpacity": 0.4},
            "encoding": { x: {"field": "instant", "type": "temporal"}, "y": {
                "field": "instant_totmin", 
                "type": "quantitative"
            }}
        },
        {
            "mark": "rule",
            "data": {"url":"MyDataset2"}, // little subset of instant of Dataset1
            "encoding": {
              "x": { "field": "instant", "type": "temporal"},
              "color": {"value": "yellow"},
              "size": {"value": 5}
            },
            //resolve:? x is same axis and the only visualization field
        }
    ],
    resolve: {"scale": {"y": "independent"}}
}]);

PS:仅删除名称和标题,所有真实脚本。


使用伪数据进行仿真:工作正常!

请单击rule guide的第三个示例...,然后将其替换或改编为该VEGA-lite脚本:

rule

[将条带添加为新层时(在2层图表中),停止工作:没有可视化,并且“ WARN无法在没有字段的编码通道” y“上投影选择”。第一个...

data-visualization vega-lite
1个回答
0
投票

您使用的是独立的y比例,并且没有y编码的规则标记的y比例定义不正确。解决此问题的最佳方法可能是将规则标记与其他图层之一组合在一起,因此可以使用y比例尺:

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