Unable to view chart using D3 version(3.5.17) in ionic 2

#1

HTML file

<ion-header>
<ion-navbar>
<ion-title>
Ionic Blank
</ion-title>
</ion-navbar>
</ion-header>

<ion-content padding>
The world is your oyster.
<p>
If you get lost, the docs will be your guide.
</p>
<div id="graph111"></div>
</ion-content>

TypeScript(.ts) file

import { Component } from ‘@angular/core’;

import { NavController } from ‘ionic-angular’;
import * as d3 from ‘d3’;
//declare var d3: any;
@Component({
selector: ‘page-home’,
templateUrl: ‘home.html’
})
export class HomePage {
treeData;margin;width;height;
constructor(public navCtrl: NavController) {

this.treeData = [
{
“name”: “Top Level”,
“parent”: “null”,
“children”: [
{
“name”: “Level 2: A”,
“parent”: “Top Level”,
“children”: [
{
“name”: “Son of A”,
“parent”: “Level 2: A”
},
{
“name”: “Daughter of A”,
“parent”: “Level 2: A”
}
]
},
{
“name”: “Level 2: B”,
“parent”: “Top Level”
}
]
}
];
this.margin = {top: 40, right: 120, bottom: 20, left: 120},
this.width = 960 - this.margin.right - this.margin.left,
this.height = 500 - this.margin.top - this.margin.bottom;

var i = 0;

var tree = d3.layout.tree()
.size([this.height, this.width]);

var diagonal = d3.svg.diagonal()
.projection(function(d) { return [d.x, d.y]; });

var svg = d3.select("#graph111").append(“svg”)
//var svg = d3.select(“div#graph111”).append(“svg”)
.attr(“width”, this.width + this.margin.right + this.margin.left)
.attr(“height”, this.height + this.margin.top + this.margin.bottom)
.append(“g”)
.attr(“transform”, “translate(” + this.margin.left + “,” + this.margin.top + “)”);

var root = this.treeData[0];

update(root);

function update(source) {

// Compute the new tree layout.
var nodes = tree.nodes(root).reverse(),
links = tree.links(nodes);

// Normalize for fixed-depth.
nodes.forEach(function(d) { d.y = d.depth * 100; });

// Declare the nodes…
var node = svg.selectAll(“g.node”)
.data(nodes, function(d) { return d.id || (d.id = ++i); });

// Enter the nodes.
var nodeEnter = node.enter().append(“g”)
.attr(“class”, “node”)
.attr(“transform”, function(d) {
return “translate(” + d.x + “,” + d.y + “)”; });

nodeEnter.append(“circle”)
.attr(“r”, 10)
.style(“fill”, “#fff”);

nodeEnter.append(“text”)
.attr(“y”, function(d) {
return d.children || d._children ? -18 : 18; })
.attr(“dy”, “.35em”)
.attr(“text-anchor”, “middle”)
.text(function(d) { return d.name; })
.style(“fill-opacity”, 1);

// Declare the links…
var link = svg.selectAll(“path.link”)
.data(links, function(d) { return d.target.id; });

// Enter the links.
link.enter().insert(“path”, “g”)
.attr(“class”, “link”)
.attr(“d”, diagonal);

}

}
}

SCSS file

.node circle {
  fill: #fff;
  stroke: steelblue;
  stroke-width: 3px;
}

.node text { font: 12px sans-serif; }

.link {
  fill: none;
  stroke: #ccc;
  stroke-width: 2px;
}

Hello ionic team and all,

I am trying to use the D3.js for charts the issue is, that i am unable to view the chart in the app,
is there any plugin required for display d3 chart in ionic 2.

I have used following steps to installed plugins,
- npm install d3@v3.5.17
- npm install -g typings
- typings search d3
- typings install d3 --save

D3js import typescript