Slides: bit.ly/ng2-data-stories
By Mike Bostock
var p = d3.select("body").append('p').data([42, 34, 54, 65, 75]);
p.text(function(d){ return 'hello ' + d;})
Fiddle
var p = d3.select("body").append('p').data([42, 34, 54, 65, 75]);
p.enter().append()
.text(function(d){ return 'hello ' + d;})
Fiddle
var els = d3.select("body")
.selectAll("p")
.data(data, function(d) { return d; });// UPDATE
var updating = els.style("color", "red");
var entering = els.enter().append("p")// ENTER
.text(String)
.style("color", "blue")
var exiting = els.exit().style("color", "lightgrey");//EXIT
var merged = els.merge(entering)// ENTER + UPDATE
.style("color", "green");
Fiddle
var exiting = els.exit()
.transition()
.duration(750)
.ease(d3.easeLinear)
.style("color", "lightgrey");//EXIT
Fiddle
x = d3.scaleLinear()
.range([0, width])
x = d3.scaleLinear()
.range([0, width])
.domain([0, 100]);
Fiddle
var xAxis = d3.axisBottom(x).ticks(12);
var xAxis = d3.axisBottom(x).ticks(12);
svg.append("g")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
render() {
setup();
populate();
}
function setUp() {
var margin = {top: 20, right: 20,bottom: 30,left: 50};
width = 800 - margin.left - margin.right,
height = 400 - margin.top - margin.bottom;
var x = d3.scaleLinear()
.range([0, width]);
var y = d3.scaleLinear()
.range([height, 0]);
}
Demo
npm install --global angular-cli
ng new myAppName
ng serve
ng g module myModule
ng g component myComponent
ng g service myService
ng g module myModule
ng g component myComponent
ng g service myService
ng build
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-test',
templateUrl: './test.component.html',
styleUrls: ['./test.component.sass']
})
export class TestComponent implements OnInit {
constructor() { }
ngOnInit() {
}
}
import { Component, OnInit, Input } from '@angular/core';
@Component({
selector: 'app-test',
templateUrl: './test.component.html',
styleUrls: ['./test.component.sass']
})
export class TestComponent implements OnInit {
@Input() data: any;
constructor() { }
ngOnInit() {
}
}
import { Component, OnInit, Output, Input } from '@angular/core';
@Component({
selector: 'app-test',
templateUrl: './test.component.html',
styleUrls: ['./test.component.sass']
})
export class TestComponent implements OnInit {
@Input() data: any;
@Output() myEvent = new EventEmitter();
constructor() { }
ngOnInit() {
}
}
@Component({
selector: 'app-test',
animations: [
trigger('buttonState', [
state('inactive', style({
backgroundColor: '#eee',
transform: 'scale(1)'
})),
state('active', style({
backgroundColor: '#cfd8dc',
transform: 'scale(1.1)'
})),
transition('inactive => active', animate('100ms ease-in')),
transition('active => inactive', animate('100ms ease-out'))
])
]
})
export class TestComponent implements OnInit {
...
}
Thank you for you attention!
- @AysegulYonet
- Code
- Slides