// Type definitions for DCJS
// Project: https://github.com/dc-js
// Definitions by: hans windhoff
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// this makes only sense together with d3 and crossfilter so you need the d3.d.ts and crossfilter.d.ts files
///
///
declare module dc {
// helper for get/set situation
interface IGetSet {
(): T;
(t:T): V;
}
export interface ILegendwidget {
x: IGetSet;
y: IGetSet;
gap: IGetSet;
itemHeight: IGetSet;
horizontal: IGetSet;
legendWidth: IGetSet;
itemWidth: IGetSet;
}
export interface IBaseChart {
width: IGetSet;
height: IGetSet;
minWidth: IGetSet;
minHeight: IGetSet;
dimension: IGetSet;
group: IGetSet; // not sure here
transitionDuration: IGetSet;
colors: IGetSet;
keyAccessor: IGetSet<(d:any) => number, T>;
valueAccessor: IGetSet<(d:any) => number, T>;
label: IGetSet<(l:any) => string, T>;
renderLabel: IGetSet;
renderlet: (fnctn: (t:T) => void) => T;
title: IGetSet<(t:string) => string, T>;
filter: IGetSet;
filterAll: () => void;
expireCache: () => void;
legend: (l:ILegendwidget) => T;
chartID: () => number;
options: (o:Object)=>void ;
select: (selector: D3.Selection) => D3.Selection;
selectAll: (selector: D3.Selection) => D3.Selection;
}
export interface IEvents {
trigger(fnctn: () => void, delay?: number):void;
}
export var events: IEvents;
export interface IListener {
on: (eventName: string, fnctn: (c:T) => void) => T;
}
export interface ImarginObj {
top: number;
right: number;
bottom: number;
left: number;
}
export interface IMarginable {
margins: IGetSet;
}
// abstract interfaces
export interface IAbstractColorChart {
colorDomain: IGetSet;
}
export interface IAbstractStackableChart {
stack: (group: IChartGroup, name?:string, retriever?: (d:Object)=>number) => T;
}
export interface IAbstractCoordinateGridChart {
x: IGetSet;
y: IGetSet;
elasticY: IGetSet;
xAxis: IGetSet;
yAxis: IGetSet;
yAxisPadding: IGetSet;
xAxisPadding: IGetSet;
renderHorizontalGridLines: IGetSet;
}
export interface IAbstractBubblechart {
r: IGetSet;
radiusValueAccessor: IGetSet<(d:any) => number, T>;
}
// function interfaces
export interface columnFunction {
(rowinfo:any): string;
}
export interface sortbyFunction {
(rowinfo:any): any;
}
export interface orderFunction {
(a: T, b: T): number;
}
// chart interfaces
export interface IBubblechart extends
IBaseChart,
IAbstractColorChart,
IAbstractBubblechart,
IAbstractCoordinateGridChart,
IMarginable,
IListener {
}
export interface IPiechart extends
IBaseChart,
IAbstractColorChart,
IAbstractBubblechart,
IAbstractCoordinateGridChart,
IMarginable,
IListener {
radius: IGetSet;
minAngleForLabel: IGetSet;
}
export interface IBarchart extends
IBaseChart,
IAbstractStackableChart,
IAbstractCoordinateGridChart,
IMarginable,
IListener {
centerBar: (b:boolean) => IBarchart;
gap: (gapBetweenBars: number) => IBarchart;
}
export interface ILinechart extends
IBaseChart,
IAbstractStackableChart,
IAbstractCoordinateGridChart,
IMarginable,
IListener {
}
export interface IDatachart extends
IBaseChart,
IAbstractStackableChart,
IAbstractCoordinateGridChart,
IMarginable,
IListener {
size: IGetSet;
columns: IGetSet;
sortBy: IGetSet;
order: IGetSet;
}
export interface IRowchart extends
IBaseChart,
IAbstractColorChart,
IAbstractStackableChart,
IAbstractCoordinateGridChart,
IMarginable,
IListener {
}
// utilities
export interface IChartGroup { }
export function filterAll(chartGroup?: IChartGroup): void;
export function renderAll(chartGroup?: IChartGroup): void;
export function redrawAll(chartGroup?: IChartGroup): void;
export function bubbleChart(cssSel: string): IBubblechart;
export function pieChart(cssSel: string): IPiechart;
export function barChart(cssSel: string): IBarchart;
export function lineChart(cssSel: string): ILinechart;
export function dataTable(cssSel: string): IDatachart;
export function rowChart(cssSel: string): IRowchart;
}