mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Update d3 superformula definition
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
/// <reference path="../d3.d.ts" />
|
||||
/// <reference path="d3.superformula.d.ts" />
|
||||
|
||||
function superformula() {
|
||||
var size = 1000;
|
||||
|
||||
var x = d3.scale.ordinal()
|
||||
.domain(d3.superformulaTypes)
|
||||
.rangePoints([0, 960], 1);
|
||||
|
||||
var svg = d3.select("body").append("svg")
|
||||
.attr("width", 960)
|
||||
.attr("height", 500);
|
||||
|
||||
var small = d3.superformula()
|
||||
.type(function (d) { return d; } )
|
||||
.size(size);
|
||||
|
||||
var big = d3.superformula()
|
||||
.type("square")
|
||||
.size(size * 50)
|
||||
.segments(360);
|
||||
|
||||
svg.selectAll("a")
|
||||
.data(d3.superformulaTypes)
|
||||
.enter().append("a")
|
||||
.attr("xlink:title", String)
|
||||
.attr("transform", function (d, i) { return "translate(" + x(d) + ",40)"; } )
|
||||
.append("path")
|
||||
.attr("class", "small")
|
||||
.attr("d", small)
|
||||
.on("mousedown", function () { d3.select(this).style("fill", "aliceblue"); } )
|
||||
.on("mouseup", function () { d3.select(this).style("fill", null); } )
|
||||
.on("click", function (d) { d3.select(".big").transition().duration(500).attr("d", big.type(d)); } );
|
||||
|
||||
svg.append("path")
|
||||
.attr("class", "big")
|
||||
.attr("transform", "translate(450,250)")
|
||||
.attr("d", big);
|
||||
}
|
||||
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
/// <reference path="../d3.d.ts" />
|
||||
|
||||
|
||||
declare module D3 {
|
||||
interface SuperformulaPath
|
||||
{
|
||||
superformulaPath(params: number[], n: number, diameter: number): Superformula;
|
||||
}
|
||||
|
||||
|
||||
interface SuperformulaType
|
||||
{
|
||||
(any): any;//hans
|
||||
m: number;
|
||||
n1: number;
|
||||
n2: number;
|
||||
n3: number;
|
||||
a: number;
|
||||
b: number;
|
||||
}
|
||||
|
||||
interface Superformula
|
||||
{
|
||||
(): any;
|
||||
type(any): any;
|
||||
param(name: string, value: number): Superformula;
|
||||
size(x: number): Superformula;
|
||||
segments(x: number): Superformula;
|
||||
}
|
||||
|
||||
|
||||
interface Base extends Selectors
|
||||
{
|
||||
superformula: Superformula;
|
||||
superformulaPath: SuperformulaPath;
|
||||
superformulaTypes: SuperformulaType[];
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
|
||||
interface ID3superformulaPath
|
||||
{
|
||||
superformulaPath(params: number[], n: number, diameter: number): ID3superformula;
|
||||
}
|
||||
|
||||
|
||||
interface ID3superformulaType
|
||||
{
|
||||
(any): any;//hans
|
||||
m: number;
|
||||
n1: number;
|
||||
n2: number;
|
||||
n3: number;
|
||||
a: number;
|
||||
b: number;
|
||||
}
|
||||
|
||||
interface ID3superformula
|
||||
{
|
||||
(): any;
|
||||
type(any): any;
|
||||
param(name: string, value: number): ID3superformula;
|
||||
size(x: number): ID3superformula;
|
||||
segments(x: number): ID3superformula;
|
||||
}
|
||||
interface ID3Selectors
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
interface ID3Base extends ID3Selectors
|
||||
{
|
||||
keys: ID3superformulaType[];
|
||||
superformula: ID3superformula;
|
||||
superformulaPath: ID3superformulaPath;
|
||||
superformulaTypes: ID3superformulaType[];
|
||||
}
|
||||
Reference in New Issue
Block a user