From b0289ac7a3657dbe8babf7691eabf9f404c832d3 Mon Sep 17 00:00:00 2001 From: Guillaume Mouron Date: Mon, 18 May 2015 12:07:28 +0200 Subject: [PATCH] Insert and append can take functions returning a DOM element This is specified in the d3 documentation : - append : https://github.com/mbostock/d3/wiki/Selections#append - insert : https://github.com/mbostock/d3/wiki/Selections#insert Also visible in the code : https://github.com/mbostock/d3/blob/master/d3.js#L802 and https://github.com/mbostock/d3/blob/master/d3.js#L818 --- d3/d3.d.ts | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index e1d501e0b..0bf3d599d 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -787,8 +787,18 @@ declare module D3 { (valueFunction: (data: T, index: number) => any): _Selection; }; - append: (name: string) => _Selection; - insert: (name: string, before: string) => _Selection; + append: { + (name: string): _Selection; + (elementFunction: (data: T, index: number) => any): _Selection; + } + + insert: { + (name: string, before: string): _Selection; + (insertElementFunction: (data: T, index: number) => any, before: string): _Selection; + (name: string, beforeElementFunction: (data: T, index: number) => any): _Selection; + (insertElementFunction: (data: T, index: number) => any, beforeElementFunction: (data: T, index: number) => any): _Selection; + } + remove: () => _Selection; empty: () => boolean; @@ -874,8 +884,18 @@ declare module D3 { export interface Selection extends _Selection { } export interface _EnterSelection { - append: (name: string) => _Selection; - insert: (name: string, before?: string) => _Selection; + append: { + (name: string): _Selection; + (elementFunction: (data: T, index: number) => any): _Selection; + } + + insert: { + (name: string, before?: string): _Selection; + (insertElementFunction: (data: T, index: number) => any, before?: string): _Selection; + (name: string, beforeElementFunction?: (data: T, index: number) => any): _Selection; + (insertElementFunction: (data: T, index: number) => any, beforeElementFunction?: (data: T, index: number) => any): _Selection; + } + select: (selector: string) => _Selection; empty: () => boolean; node: () => Element;