typescript


typescript line chart d3


I am new to d3 and typescript.
I am trying to create a simple line chart by using d3 v4 and typescript.
However, I got a typescript error as in the following image:
What is the problem?
//appending svg to HTML
var canvas = d3.select("body")
.append("svg")
.attr("width", width)
.attr("height", height)
.attr("transform", "translate(" + margin.left + "," + margin.right + ")");
//sample data -- initial scale data
var sampleData = [{
"yData": 202,
"xData": 2000
}, {
"yData": 215,
"xData": 2001
}, {
"yData": 179,
"xData": 2002
}, {
"yData": 199,
"xData": 2003
}, {
"yData": 134,
"xData": 2003
}, {
"yData": 176,
"xData": 2010
}];
var initialXmin = d3.min(sampleData, function (d) { return d.xData; });
var initialXMax = d3.max(sampleData, function (d) { return d.xData; });
var initialYmin = d3.min(sampleData, function (d) { return d.yData; });
var initialYMax = d3.max(sampleData, function (d) { return d.yData; });
var linearXScale = d3.scaleLinear()
.domain([initialXmin, initialXMax])
.range([margin.left, width - margin.right]);
var linearYScale = d3.scaleLinear()
.domain([initialYMax, initialYmin])
.range([margin.top, height - margin.bottom]);
var xAxis = d3.axisBottom(linearXScale);
var yAxis = d3.axisRight(linearYScale);
//create x Axis
canvas.append("g")
.attr("transform", "translate(0," + (height - margin.bottom) + ")")
.call(xAxis);
//create y Axis
canvas.append("g")
.attr("transform", "translate( " + margin.left + " ,0)")
.call(yAxis);
// define the line
var lineGenerator = d3.line()
.x(function (d) {
return this._linearXScale(d['xData']);
//return linearXScale(d["x_value"]);
})
.y(function (d) {
return this._linearXScale(d['yData']);
})
.curve(d3.curveBasis);
//create the line
canvas.append("path")
.attr("d", lineGenerator(sampleData))
.attr('stroke', 'green')
.attr('stroke-width', 2)
.attr('fill', 'none');

Related Links

Typescript abstract class static method not enforced
Typescript timestamp get milliseconds
Using tabindex between forms with typescript
How to type a variable to a module in Typescript?
How do I typecast when object property name is different from json name in typescript?
Can I declare modules as globally available with Typescript?
Configuring IntelliJ IDEA 2016 so that the braces of object literals in Typescript are on a new line but not indented
Declare a type in TypeScript that denotes the empty set
How do I upgrade typescript in Visual Studio Code version 1.9.1
Difference between default and regular typescript exports?
what is decorators in typescript, Why it is used? need real time example using typescript
reflect-metadata and querying the object for decorators
Complex object in typescript
Including typescript code from what file in another file
TypeScript - Include all files automatically in the right order using tsconfig.json
Global types in typescript

Categories

HOME
azure
performance
document
sqlite
applet
typeahead.js
classloader
clion
wav
superfish
hyperion
sql-server-express
proftpd
session-cookies
sparkpost
git-svn
orchardcms-1.10
jgit
libssh
flow
countdown
snort
mouseevent
polynomials
vnc
angular-services
pvs-studio
flatbuffers
arduino-esp8266
temp
expression-trees
ocean
ruamel.yaml
svn2git
panel-data
stackexchange.exceptional
imagemapster
deep-copy
json-rpc
solid-principles
joe-editor
signing
extjs4
procobol
angular2-seed
android-studio-2.1
keyboard-maestro
slt
zuul
sql-insert
psycopg2
soql
typesetting
a-star
graph-traversal
swift-package-manager
zenity
perspective
statistics-bootstrap
insert-update
webpack-hmr
id3
pakyow
hl7-v2
occam-pi
tag-helpers
uac
openejb
symbian
pyenchant
realm-list
cbc-mode
java-client
scribe
modern-ui
repaint
opensc
publish-actions
nine-patch
wmv
grunt-contrib-copy
declspec
data-dictionary
blueprint
git-gui
nsmanagedobjectmodel
angularjs-module
arbtt
pixelsense
file-structure
blackberry-cascades
cocosbuilder
hpple
j#
c++builder-xe2
cellphone
jscience
websolr
replay
etrade-api
nstreecontroller
android-3.1
cassandra-0.7
queryanalyzer
reference-library

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App