无法将符号分配给 Power BI 散点图数据点(类型 'Symbol<{}>' 的参数不能分配给类型 'Primitive'' 的参数)
Cannot Assign Symbols to Power BI Scatterchart Data Points (argument of type 'Symbol<{}>' is not assignable to paramater of type 'Primitive'')
我正在尝试使用 d3 将符号分配给 Power BI 散点图中的数据点。我可以使用以下方法轻松地使它们全部交叉:
.attr("d", d3.svg.symbol().type("cross"))
我想我可以通过使用 "if" 语句基于名为 "component." 的列中的值分配符号来构建它有四个潜在的组件值:OA,OI 、 RA 和 CA。我尝试让组件OA相关的数据点用叉号,其余为圆圈。这是我所做的:
.attr("d", function(d) {
if (d.component === "OA") { return d3.svg.symbol().type("cross") }
else { return d3.svg.symbol().type("circle") };
})
但我收到以下错误。
[ts] Argument of type '(d: ScatterChartDataPoint) => Symbol<{}>' is not assignable to parameter of type '(datum: ScatterChartDataPoint, index: number, outerIndex: number) => Primitive'. Type 'Symbol<{}>' is not assignable to type 'Primitive'. Type 'Symbol<{}>' is not assignable to type 'false.
知道如何解决这个问题吗?我需要一个适用于 d3 v3.5.5 的解决方案。我不能使用 d3 v4.
像这样更改 attr
:
.attr("d", d3.svg.symbol().type((d:any)=> {
if (d.component === "OA") { return "cross";}
else {return "circle";}
})
)
您想要 return d3.svg.symbol
的类型而不是 "d"
属性。所以你的回调是在错误的地方。
我正在尝试使用 d3 将符号分配给 Power BI 散点图中的数据点。我可以使用以下方法轻松地使它们全部交叉:
.attr("d", d3.svg.symbol().type("cross"))
我想我可以通过使用 "if" 语句基于名为 "component." 的列中的值分配符号来构建它有四个潜在的组件值:OA,OI 、 RA 和 CA。我尝试让组件OA相关的数据点用叉号,其余为圆圈。这是我所做的:
.attr("d", function(d) {
if (d.component === "OA") { return d3.svg.symbol().type("cross") }
else { return d3.svg.symbol().type("circle") };
})
但我收到以下错误。
[ts] Argument of type '(d: ScatterChartDataPoint) => Symbol<{}>' is not assignable to parameter of type '(datum: ScatterChartDataPoint, index: number, outerIndex: number) => Primitive'. Type 'Symbol<{}>' is not assignable to type 'Primitive'. Type 'Symbol<{}>' is not assignable to type 'false.
知道如何解决这个问题吗?我需要一个适用于 d3 v3.5.5 的解决方案。我不能使用 d3 v4.
像这样更改 attr
:
.attr("d", d3.svg.symbol().type((d:any)=> {
if (d.component === "OA") { return "cross";}
else {return "circle";}
})
)
您想要 return d3.svg.symbol
的类型而不是 "d"
属性。所以你的回调是在错误的地方。