在 V4 中,不再使用 d3.layout.treemap。所以我正在尝试使用分层 API 构建一个包含平面对象数组的树状图。我发现使用对象的平面阵列的实现在这里。
这是我目前正在尝试构建树状图的代码。
var treeData = d3.stratify()
.id(function(d) { return d[relationMap.label]; })
.parentId(function(d) { return d[relationMap.series]; })
(chart.children);
// assign the name to each node
treeData.each(function(d) {
d.name = d[relationMap.label];
});
var treemap = d3.treemap()
.size([container.width, container.height]);
treemap(root);
svg.append("g").attr("class", "treemap");
var node = svg.select(".treemap")
.selectAll("g")
.data(root.leaves())
.enter().append('g')
.attr('transform', function (d) {
return 'translate(0,0)';
});
node.append('rect')
// .call(position)
.attr("x", function (d) {
return d.x0 + "px";
})
.attr("y", function (d) {
return d.y0 + "px"; …Run Code Online (Sandbox Code Playgroud) 我熟悉 Angular,但我才刚刚开始学习 NativeScript。我有一个使用 NativeScript 库中的 Tab 模板的 Tab 界面。我想在我的选项卡被选中时运行一个函数,但我无法弄清楚。
这是 app.component.html:
<TabView [(ngModel)]="tabSelectedIndex" androidTabsPosition="bottom" (selectedIndexChanged)="onSelectedIndexChanged($event)">
<page-router-outlet *tabItem="{title: 'Home', iconSource: getIconSource('home')}" name="homeTab">
</page-router-outlet>
<page-router-outlet *tabItem="{title: 'Away', iconSource: getIconSource('browse')}" name="awayTab">
</page-router-outlet>
<page-router-outlet *tabItem="{title: 'Matchup', iconSource: getIconSource('search')}" name="matchupTab">
</page-router-outlet>
</TabView>
Run Code Online (Sandbox Code Playgroud)
我还没有真正在 matchup.component.ts 中有任何东西,因为我还没有弄清楚这一点。不过这里是:
import { Component, OnInit } from "@angular/core";
import { DataService } from "../core/data.service";
import { ActivatedRoute } from "@angular/router";
@Component({
selector: "Matchup",
moduleId: module.id,
templateUrl: "./matchup.component.html"
})
export class MatchupComponent implements OnInit {
constructor(
private data: DataService,
private route: ActivatedRoute …Run Code Online (Sandbox Code Playgroud)