mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Updates dc.js type definitions to latest
This commit is contained in:
parent
633d578646
commit
bb626a5db1
411
dcjs/dc-tests.ts
411
dcjs/dc-tests.ts
@ -3,240 +3,221 @@
|
||||
///<reference path="dc.d.ts" />
|
||||
|
||||
interface IYelpData {
|
||||
city: string;
|
||||
review_count: number;
|
||||
name: string;
|
||||
neighborhoods: string[];
|
||||
type: string;
|
||||
business_id: string;
|
||||
full_address: string;
|
||||
state: string;
|
||||
longitude: number;
|
||||
stars: number;
|
||||
latitude: number;
|
||||
open: boolean;
|
||||
categories: string[]
|
||||
city: string;
|
||||
review_count: number;
|
||||
name: string;
|
||||
neighborhoods: string[];
|
||||
type: string;
|
||||
business_id: string;
|
||||
full_address: string;
|
||||
state: string;
|
||||
longitude: number;
|
||||
stars: number;
|
||||
latitude: number;
|
||||
open: boolean;
|
||||
categories: string[]
|
||||
}
|
||||
|
||||
interface IYelpDataExtended {
|
||||
count: number;
|
||||
review_sum: number;
|
||||
star_sum: number;
|
||||
review_avg: number;
|
||||
star_avg: number;
|
||||
count: number;
|
||||
review_sum: number;
|
||||
star_sum: number;
|
||||
review_avg: number;
|
||||
star_avg: number;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************
|
||||
* *
|
||||
* dj.js example using Yelp Kaggle Test Dataset *
|
||||
* Eamonn O'Loughlin 9th May 2013 *
|
||||
* *
|
||||
********************************************************/
|
||||
* *
|
||||
* dj.js example using Yelp Kaggle Test Dataset *
|
||||
* Eamonn O'Loughlin 9th May 2013 *
|
||||
* *
|
||||
********************************************************/
|
||||
|
||||
/********************************************************
|
||||
* *
|
||||
* Step0: Load data from json file *
|
||||
* *
|
||||
********************************************************/
|
||||
d3.json("data/yelp_test_set_business.json", function (yelp_data:IYelpData[]) {
|
||||
|
||||
/********************************************************
|
||||
* *
|
||||
* Step1: Create the dc.js chart objects & ling to div *
|
||||
* *
|
||||
********************************************************/
|
||||
var bubbleChart = dc.bubbleChart("#dc-bubble-graph");
|
||||
var pieChart = dc.pieChart("#dc-pie-graph");
|
||||
var volumeChart = dc.barChart("#dc-volume-chart");
|
||||
var lineChart = dc.lineChart("#dc-line-chart");
|
||||
var dataTable = dc.dataTable("#dc-table-graph");
|
||||
var rowChart = dc.rowChart("#dc-row-graph");
|
||||
* *
|
||||
* Step0: Load data from json file *
|
||||
* *
|
||||
********************************************************/
|
||||
d3.json("data/yelp_test_set_business.json", (yelp_data:IYelpData[]) => {
|
||||
|
||||
/********************************************************
|
||||
* *
|
||||
* Step2: Run data through crossfilter *
|
||||
* *
|
||||
********************************************************/
|
||||
var ndx = crossfilter(yelp_data);
|
||||
|
||||
/********************************************************
|
||||
* *
|
||||
* Step3: Create Dimension that we'll need *
|
||||
* *
|
||||
********************************************************/
|
||||
/********************************************************
|
||||
* *
|
||||
* Step1: Create the dc.js chart objects & ling to div *
|
||||
* *
|
||||
********************************************************/
|
||||
var bubbleChart: DC.BubbleChart = dc.bubbleChart("#dc-bubble-graph");
|
||||
var pieChart: DC.PieChart = dc.pieChart("#dc-pie-graph");
|
||||
var volumeChart: DC.BarChart = dc.barChart("#dc-volume-chart");
|
||||
var lineChart: DC.LineChart = dc.lineChart("#dc-line-chart");
|
||||
var dataTable: DC.DataTableWidget = dc.dataTable("#dc-table-graph");
|
||||
var rowChart: DC.RowChart = dc.rowChart("#dc-row-graph");
|
||||
|
||||
// for volumechart
|
||||
var cityDimension = ndx.dimension(function (d) { return d.city; });
|
||||
var cityGroup = cityDimension.group();
|
||||
var cityDimensionGroup = cityDimension.group().reduce(
|
||||
//add
|
||||
function(p: IYelpDataExtended,v:IYelpData){
|
||||
++p.count;
|
||||
p.review_sum += v.review_count;
|
||||
p.star_sum += v.stars;
|
||||
p.review_avg = p.review_sum / p.count;
|
||||
p.star_avg = p.star_sum / p.count;
|
||||
return p;
|
||||
},
|
||||
//remove
|
||||
function(p: IYelpDataExtended,v:IYelpData){
|
||||
--p.count;
|
||||
p.review_sum -= v.review_count;
|
||||
p.star_sum -= v.stars;
|
||||
p.review_avg = p.review_sum / p.count;
|
||||
p.star_avg = p.star_sum / p.count;
|
||||
return p;
|
||||
},
|
||||
//init
|
||||
function(){
|
||||
return {count:0, review_sum: 0, star_sum: 0, review_avg: 0, star_avg: 0};
|
||||
}
|
||||
);
|
||||
/********************************************************
|
||||
* *
|
||||
* Step2: Run data through crossfilter *
|
||||
* *
|
||||
********************************************************/
|
||||
var ndx: CrossFilter.CrossFilter<IYelpData> = crossfilter(yelp_data);
|
||||
|
||||
// for pieChart
|
||||
var startValue = ndx.dimension(function (d) {
|
||||
return d.stars*1.0;
|
||||
});
|
||||
var startValueGroup = startValue.group();
|
||||
/********************************************************
|
||||
* *
|
||||
* Step3: Create Dimension that we'll need *
|
||||
* *
|
||||
********************************************************/
|
||||
|
||||
// For datatable
|
||||
var businessDimension = ndx.dimension(function (d) { return d.business_id; });
|
||||
/********************************************************
|
||||
* *
|
||||
* Step4: Create the Visualisations *
|
||||
* *
|
||||
********************************************************/
|
||||
|
||||
bubbleChart.width(650)
|
||||
.height(300)
|
||||
.dimension(cityDimension)
|
||||
.group(cityDimensionGroup)
|
||||
.transitionDuration(1500)
|
||||
.colors(["#a60000","#ff0000", "#ff4040","#ff7373","#67e667","#39e639","#00cc00"])
|
||||
.colorDomain([-12000, 12000])
|
||||
|
||||
.x(d3.scale.linear().domain([0, 5.5]))
|
||||
.y(d3.scale.linear().domain([0, 5.5]))
|
||||
.r(d3.scale.linear().domain([0, 2500]))
|
||||
.keyAccessor(function (p) {
|
||||
return p.value.star_avg;
|
||||
})
|
||||
.valueAccessor(function (p) {
|
||||
return p.value.review_avg;
|
||||
})
|
||||
.radiusValueAccessor(function (p) {
|
||||
return p.value.count;
|
||||
})
|
||||
.transitionDuration(1500)
|
||||
.elasticY(true)
|
||||
.yAxisPadding(1)
|
||||
.xAxisPadding(1)
|
||||
.label(function (p) {
|
||||
return p.key;
|
||||
})
|
||||
.renderLabel(true)
|
||||
.renderlet(function (chart) {
|
||||
rowChart.filter(chart.filter());
|
||||
})
|
||||
.on("postRedraw", function (chart) {
|
||||
dc.events.trigger(function () {
|
||||
rowChart.filter(chart.filter());
|
||||
});
|
||||
});
|
||||
;
|
||||
// for volumechart
|
||||
var cityDimension: CrossFilter.Dimension<IYelpData, string> = ndx.dimension((d: IYelpData) => d.city);
|
||||
var cityGroup: CrossFilter.Group<IYelpData, string, string> = cityDimension.group();
|
||||
var cityDimensionGroup: CrossFilter.Group<IYelpData, string, IYelpDataExtended> = cityDimension.group().reduce(
|
||||
//add
|
||||
(p: IYelpDataExtended, v:IYelpData) => {
|
||||
++p.count;
|
||||
p.review_sum += v.review_count;
|
||||
p.star_sum += v.stars;
|
||||
p.review_avg = p.review_sum / p.count;
|
||||
p.star_avg = p.star_sum / p.count;
|
||||
return p;
|
||||
},
|
||||
//remove
|
||||
(p: IYelpDataExtended, v:IYelpData) => {
|
||||
--p.count;
|
||||
p.review_sum -= v.review_count;
|
||||
p.star_sum -= v.stars;
|
||||
p.review_avg = p.review_sum / p.count;
|
||||
p.star_avg = p.star_sum / p.count;
|
||||
return p;
|
||||
},
|
||||
//init
|
||||
() => {
|
||||
return {count: 0, review_sum: 0, star_sum: 0, review_avg: 0, star_avg: 0};
|
||||
}
|
||||
);
|
||||
|
||||
// for pieChart
|
||||
var startValue: CrossFilter.Dimension<IYelpData, number> = ndx.dimension((d: IYelpData) => d.stars * 1.0);
|
||||
var startValueGroup: CrossFilter.Group<IYelpData, number, number> = startValue.group();
|
||||
|
||||
pieChart.width(200)
|
||||
.height(200)
|
||||
.transitionDuration(1500)
|
||||
.dimension(startValue)
|
||||
.group(startValueGroup)
|
||||
.radius(90)
|
||||
.minAngleForLabel(0)
|
||||
.label(function(d) { return d.data.key; })
|
||||
.on("filtered", function (chart) {
|
||||
dc.events.trigger(function () {
|
||||
if(chart.filter()) {
|
||||
console.log(chart.filter());
|
||||
volumeChart.filter([chart.filter()-.25,chart.filter()-(-0.25)]);
|
||||
}
|
||||
else volumeChart.filterAll();
|
||||
});
|
||||
});
|
||||
// For datatable
|
||||
var businessDimension: CrossFilter.Dimension<IYelpData, string> = ndx.dimension((d: IYelpData) => d.business_id);
|
||||
/********************************************************
|
||||
* *
|
||||
* Step4: Create the Visualisations *
|
||||
* *
|
||||
********************************************************/
|
||||
|
||||
volumeChart.width(230)
|
||||
.height(200)
|
||||
.dimension(startValue)
|
||||
.group(startValueGroup)
|
||||
.transitionDuration(1500)
|
||||
.centerBar(true)
|
||||
.gap(17)
|
||||
.x(d3.scale.linear().domain([0.5, 5.5]))
|
||||
.elasticY(true)
|
||||
.on("filtered", function (chart) {
|
||||
dc.events.trigger(function () {
|
||||
if(chart.filter()) {
|
||||
console.log(chart.filter());
|
||||
lineChart.filter(chart.filter());
|
||||
}
|
||||
else
|
||||
{lineChart.filterAll()}
|
||||
});
|
||||
})
|
||||
.xAxis().tickFormat(function(v) {return v;});
|
||||
bubbleChart
|
||||
.width(650)
|
||||
.height(300)
|
||||
.dimension(cityDimension)
|
||||
.group(cityDimensionGroup)
|
||||
.transitionDuration(1500)
|
||||
.colors(["#a60000","#ff0000", "#ff4040","#ff7373","#67e667","#39e639","#00cc00"])
|
||||
.colorDomain([-12000, 12000])
|
||||
.x(d3.scale.linear().domain([0, 5.5]))
|
||||
.y(d3.scale.linear().domain([0, 5.5]))
|
||||
.r(d3.scale.linear().domain([0, 2500]))
|
||||
.keyAccessor((p: any) => p.value.star_avg)
|
||||
.valueAccessor((p: any) => p.value.review_avg)
|
||||
.radiusValueAccessor((p: any) => p.value.count)
|
||||
.transitionDuration(1500)
|
||||
.elasticY(true)
|
||||
.yAxisPadding(1)
|
||||
.xAxisPadding(1)
|
||||
.label((p: any) => p.key)
|
||||
.renderLabel(true)
|
||||
.renderlet((chart: DC.BubbleChart) => rowChart.filter(chart.filter()))
|
||||
.on("postRedraw", (chart: DC.BubbleChart) => dc.events.trigger(() => rowChart.filter(chart.filter())));
|
||||
|
||||
console.log(startValueGroup.top(1)[0].value);
|
||||
pieChart
|
||||
.width(200)
|
||||
.height(200)
|
||||
.transitionDuration(1500)
|
||||
.dimension(startValue)
|
||||
.group(startValueGroup)
|
||||
.radius(90)
|
||||
.minAngleForLabel(0)
|
||||
.label((d: any) => d.data.key)
|
||||
.on("filtered", (chart: DC.PieChart) =>
|
||||
dc.events.trigger(() => {
|
||||
if (chart.filter()) {
|
||||
console.log(chart.filter());
|
||||
volumeChart.filter([chart.filter()-.25,chart.filter()-(-0.25)]);
|
||||
}
|
||||
else volumeChart.filterAll();
|
||||
}));
|
||||
|
||||
lineChart.width(230)
|
||||
.height(200)
|
||||
.dimension(startValue)
|
||||
.group(startValueGroup)
|
||||
.x(d3.scale.linear().domain([0.5, 5.5]))
|
||||
.valueAccessor(function(d) {
|
||||
return d.value;
|
||||
})
|
||||
.renderHorizontalGridLines(true)
|
||||
.elasticY(true)
|
||||
.xAxis().tickFormat(function(v) {return v;}); ;
|
||||
volumeChart
|
||||
.width(230)
|
||||
.height(200)
|
||||
.dimension(startValue)
|
||||
.group(startValueGroup)
|
||||
.transitionDuration(1500)
|
||||
.centerBar(true)
|
||||
.gap(17)
|
||||
.x(d3.scale.linear().domain([0.5, 5.5]))
|
||||
.elasticY(true)
|
||||
.on("filtered", (chart: DC.BarChart) =>
|
||||
dc.events.trigger(() => {
|
||||
if(chart.filter()) {
|
||||
console.log(chart.filter());
|
||||
lineChart.filter(chart.filter());
|
||||
}
|
||||
else {
|
||||
lineChart.filterAll()
|
||||
}
|
||||
}))
|
||||
.xAxis()
|
||||
.tickFormat((v: string) => v);
|
||||
|
||||
rowChart.width(340)
|
||||
.height(850)
|
||||
.dimension(cityDimension)
|
||||
.group(cityGroup)
|
||||
.renderLabel(true)
|
||||
.colors(["#a60000","#ff0000", "#ff4040","#ff7373","#67e667","#39e639","#00cc00"])
|
||||
.colorDomain([0, 0])
|
||||
.renderlet(function (chart) {
|
||||
bubbleChart.filter(chart.filter());
|
||||
})
|
||||
.on("filtered", function (chart) {
|
||||
dc.events.trigger(function () {
|
||||
bubbleChart.filter(chart.filter());
|
||||
});
|
||||
});
|
||||
console.log(startValueGroup.top(1)[0].value);
|
||||
|
||||
lineChart
|
||||
.width(230)
|
||||
.height(200)
|
||||
.dimension(startValue)
|
||||
.group(startValueGroup)
|
||||
.x(d3.scale.linear().domain([0.5, 5.5]))
|
||||
.valueAccessor((d: any) => d.value)
|
||||
.renderHorizontalGridLines(true)
|
||||
.elasticY(true)
|
||||
.xAxis()
|
||||
.tickFormat((v: string) => v);
|
||||
|
||||
dataTable.width(800).height(800)
|
||||
.dimension(businessDimension)
|
||||
.group(function(d:Object) { return "List of all Selected Businesses"
|
||||
})
|
||||
.size(100)
|
||||
.columns([
|
||||
function(d) { return d.name; },
|
||||
function(d) { return d.city; },
|
||||
function(d) { return d.stars; },
|
||||
function(d) { return d.review_count; },
|
||||
function(d) { return '<a href=\"http://maps.google.com/maps?z=12&t=m&q=loc:' + d.latitude + '+' + d.longitude +"\" target=\"_blank\">Map</a>"}
|
||||
])
|
||||
.sortBy(function(d){ return d.stars; })
|
||||
// (optional) sort order, :default ascending
|
||||
.order(d3.ascending);
|
||||
/********************************************************
|
||||
* *
|
||||
* Step6: Render the Charts *
|
||||
* *
|
||||
********************************************************/
|
||||
|
||||
dc.renderAll();
|
||||
rowChart
|
||||
.width(340)
|
||||
.height(850)
|
||||
.dimension(cityDimension)
|
||||
.group(cityGroup)
|
||||
.renderLabel(true)
|
||||
.colors(["#a60000","#ff0000", "#ff4040","#ff7373","#67e667","#39e639","#00cc00"])
|
||||
.colorDomain([0, 0])
|
||||
.renderlet((chart: DC.RowChart) => bubbleChart.filter(chart.filter()))
|
||||
.on("filtered", (chart: DC.RowChart) =>
|
||||
dc.events.trigger(() =>
|
||||
bubbleChart.filter(chart.filter())));
|
||||
|
||||
dataTable
|
||||
.width(800)
|
||||
.height(800)
|
||||
.dimension(businessDimension)
|
||||
.group((d: any) => "List of all Selected Businesses")
|
||||
.size(100)
|
||||
.columns([
|
||||
(d: IYelpData) => d.name,
|
||||
(d: IYelpData) => d.city,
|
||||
(d: IYelpData) => d.stars,
|
||||
(d: IYelpData) => d.review_count,
|
||||
(d: IYelpData) => '<a href=\"http://maps.google.com/maps?z=12&t=m&q=loc:' + d.latitude + '+' + d.longitude +"\" target=\"_blank\">Map</a>"
|
||||
])
|
||||
.sortBy((d: IYelpData) => d.stars)
|
||||
// (optional) sort order, :default ascending
|
||||
.order(d3.ascending);
|
||||
/********************************************************
|
||||
* *
|
||||
* Step6: Render the Charts *
|
||||
* *
|
||||
********************************************************/
|
||||
|
||||
dc.renderAll();
|
||||
});
|
||||
|
||||
433
dcjs/dc.d.ts
vendored
Normal file
433
dcjs/dc.d.ts
vendored
Normal file
@ -0,0 +1,433 @@
|
||||
// Type definitions for DCJS
|
||||
// Project: https://github.com/dc-js/dc.js
|
||||
// Definitions by: hans windhoff <https://github.com/hansrwindhoff>, matt traynham <https://github.com/mtraynham>
|
||||
// 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
|
||||
|
||||
///<reference path="../d3/d3.d.ts" />
|
||||
///<reference path="../crossfilter/crossfilter.d.ts" />
|
||||
|
||||
declare module DC {
|
||||
// helper for get/set situation
|
||||
export interface IGetSet<T, V> {
|
||||
(): T;
|
||||
(t: T): V;
|
||||
}
|
||||
|
||||
export interface IBiGetSet<T, R, V> {
|
||||
(): T;
|
||||
(t: T, r?: R): V;
|
||||
}
|
||||
|
||||
export interface Accessor<T, V> {
|
||||
(datum: T, index?: number): V;
|
||||
}
|
||||
|
||||
export interface UnitFunction {
|
||||
(start: number, end: number, domain?: Array<any>): number|Array<any>;
|
||||
}
|
||||
|
||||
export interface FloatPointUnits {
|
||||
precision(precision: number): UnitFunction;
|
||||
}
|
||||
|
||||
export interface Units {
|
||||
integers: UnitFunction;
|
||||
ordinal: UnitFunction;
|
||||
fp: FloatPointUnits;
|
||||
}
|
||||
|
||||
export interface Events {
|
||||
trigger(fn: () => void, delay?: number): void;
|
||||
}
|
||||
|
||||
export interface Errors {
|
||||
Exception(msg: string): void;
|
||||
InvalidStateException(msg: string): void;
|
||||
}
|
||||
|
||||
export interface Filter {
|
||||
isFiltered(value: any): boolean;
|
||||
}
|
||||
|
||||
export interface Filters {
|
||||
RangedFilter(low: any, high: any): Filter;
|
||||
TwoDimensionalFilter(arr: Array<any>): Filter;
|
||||
RangedTwoDimensionalFilter(arr: Array<any>): Filter;
|
||||
}
|
||||
|
||||
export interface Logger {
|
||||
enableDebugLog: boolean;
|
||||
warn(msg: string): void;
|
||||
debug(msg: string): void;
|
||||
deprecate(fn: Function, msg: string): void;
|
||||
}
|
||||
|
||||
export interface Printers {
|
||||
filters(filters: Array<any>): string;
|
||||
filter(filter: any): string;
|
||||
}
|
||||
|
||||
export interface Round {
|
||||
floor(n: number): number;
|
||||
ceil(n: number): number;
|
||||
round(n: number): number;
|
||||
}
|
||||
|
||||
export interface Utils {
|
||||
printSingleValue(filter: any): string;
|
||||
add(l: any, r: any): any;
|
||||
subtract(l: any, r: any): any;
|
||||
isNumber(n: any): boolean;
|
||||
isFloat(n: any): boolean;
|
||||
isInteger(n: any): boolean;
|
||||
isNegligible(n: any): boolean;
|
||||
clamp(n: number, min: number, max: number): number;
|
||||
uniqueId(): number;
|
||||
nameToId(name: string): string;
|
||||
appendOrSelect(parent: D3.Selection, selector: string, tag: any): D3.Selection;
|
||||
safeNumber(n: any): number;
|
||||
}
|
||||
|
||||
export interface Legend {
|
||||
x: IGetSet<number, number>;
|
||||
y: IGetSet<number, number>;
|
||||
gap: IGetSet<number, number>;
|
||||
itemHeight: IGetSet<number, number>;
|
||||
horizontal: IGetSet<boolean, boolean>;
|
||||
legendWidth: IGetSet<number, number>;
|
||||
itemWidth: IGetSet<number, number>;
|
||||
autoItemWidth: IGetSet<boolean, boolean>;
|
||||
render: () => void;
|
||||
}
|
||||
|
||||
export interface BaseMixin<T> {
|
||||
width: IGetSet<number, T>;
|
||||
height: IGetSet<number, T>;
|
||||
minWidth: IGetSet<number, T>;
|
||||
minHeight: IGetSet<number, T>;
|
||||
dimension: IGetSet<any, T>;
|
||||
data: IGetSet<(group: any) => Array<any>, T>;
|
||||
group: IGetSet<any, T>;
|
||||
ordering: IGetSet<Accessor<any, any>, T>;
|
||||
filterAll(): void;
|
||||
select(selector: D3.Selection|string): D3.Selection;
|
||||
selectAll(selector: D3.Selection|string): D3.Selection;
|
||||
anchor(anchor: BaseMixin<any>|D3.Selection|string, chartGroup?: string): D3.Selection;
|
||||
anchorName(): string;
|
||||
svg: IGetSet<D3.Selection, D3.Selection>;
|
||||
resetSvg(): void;
|
||||
filterPrinter: IGetSet<(filters: Array<any>) => string, T>;
|
||||
turnOnControls(): void;
|
||||
turnOffControls(): void;
|
||||
transitionDuration: IGetSet<number, T>;
|
||||
render(): void;
|
||||
redraw(): void;
|
||||
redrawGroup(): void;
|
||||
hasFilterHandler: IGetSet<(filters: Array<any>, filter: any) => boolean, T>;
|
||||
hasFilter(filter?: any): boolean;
|
||||
removeFilterHandler: IGetSet<(filters: Array<any>) => Array<any>, T>;
|
||||
addFilterHandler: IGetSet<(filters: Array<any>) => Array<any>, T>;
|
||||
resetFilterHandler: IGetSet<(filters: Array<any>) => Array<any>, T>;
|
||||
filter: IGetSet<any, T>;
|
||||
filters(): Array<any>;
|
||||
onClick(datum: any): void;
|
||||
filterHandler: IGetSet<(dimension: any, filter: any) => any, T>;
|
||||
keyAccessor: IGetSet<Accessor<any, any>, T>;
|
||||
valueAccessor: IGetSet<Accessor<any, any>, T>;
|
||||
label: IGetSet<Accessor<any, string>, T>;
|
||||
renderLabel: IGetSet<boolean, T>;
|
||||
title: IGetSet<Accessor<any, string>, T>;
|
||||
renderTitle: IGetSet<boolean, T>;
|
||||
chartGroup: IGetSet<string, T>;
|
||||
expireCache(): T;
|
||||
legend: IGetSet<Legend, T>;
|
||||
options(optionsObject: any): T;
|
||||
renderlet(fn: (chart: T) => any): T;
|
||||
on(event: string, fn: (chart: T) => any): T;
|
||||
}
|
||||
|
||||
export interface Margins {
|
||||
left: number;
|
||||
top: number;
|
||||
right: number;
|
||||
bottom: number;
|
||||
}
|
||||
|
||||
export interface MarginMixin<T> {
|
||||
margins: IGetSet<Margins, T>
|
||||
}
|
||||
|
||||
export interface ColorMixin<T> {
|
||||
colors: IGetSet<D3.Scale.GenericScale<any>|Array<string>, T>;
|
||||
ordinalColors(r: Array<string>): void;
|
||||
linearColors(r: Array<number>): void;
|
||||
colorAccessor: IGetSet<Accessor<any, string>, T>;
|
||||
colorDomain: IGetSet<Array<any>, T>;
|
||||
calculateColorDomain(): void;
|
||||
getColor(datum: any, index?: number): string;
|
||||
colorCalculator: IGetSet<Accessor<any, string>, T>;
|
||||
}
|
||||
|
||||
export interface CoordinateGridMixin<T> extends BaseMixin<T>, MarginMixin<T>, BaseMixin<T> {
|
||||
rangeChart: IGetSet<BaseMixin<any>, T>;
|
||||
zoomScale: IGetSet<Array<any>, T>;
|
||||
zoomOutRestrict: IGetSet<boolean, T>;
|
||||
g: IGetSet<D3.Selection, T>;
|
||||
mouseZoomable: IGetSet<boolean, T>;
|
||||
chartBodyG(): D3.Selection;
|
||||
x: IGetSet<D3.Scale.GenericScale<any>, T>;
|
||||
xUnits: IGetSet<UnitFunction, T>;
|
||||
xAxis: IGetSet<D3.Svg.Axis, T>;
|
||||
elasticX: IGetSet<boolean, T>;
|
||||
xAxisPadding: IGetSet<number, T>;
|
||||
xUnitCount(): number;
|
||||
useRightYAxis: IGetSet<boolean, T>;
|
||||
isOrdinal(): boolean;
|
||||
xAxisLabel: IBiGetSet<string, number, T>;
|
||||
yAxisLabel: IBiGetSet<string, number, T>;
|
||||
y: IGetSet<D3.Scale.GenericQuantitativeScale<any>, T>;
|
||||
yAxis: IGetSet<D3.Svg.Axis, T>;
|
||||
elasticY: IGetSet<boolean, T>;
|
||||
renderHorizontalGridLines: IGetSet<boolean, T>;
|
||||
renderVerticalGridLines: IGetSet<boolean, T>;
|
||||
xAxisMin(): any;
|
||||
xAxisMax(): any;
|
||||
yAxisMin(): any;
|
||||
yAxisMax(): any;
|
||||
yAxisPadding: IGetSet<number, T>;
|
||||
round: IGetSet<(value: any) => any, T>;
|
||||
clipPadding: IGetSet<number, T>;
|
||||
focus(range?: Array<any>): void;
|
||||
brushOn: IGetSet<boolean, T>;
|
||||
}
|
||||
|
||||
export interface StackMixin<T> {
|
||||
stack(group: any, name?: string, accessor?: Accessor<any, any>): void;
|
||||
hidableStacks: IGetSet<boolean, T>;
|
||||
hideStack(name: string): void;
|
||||
showStack(name: string): void;
|
||||
// title(stackName: string, titleFn: Accessor<any, T>);
|
||||
stackLayout: IGetSet<D3.Layout.StackLayout, T>;
|
||||
}
|
||||
|
||||
export interface CapMixin<T> {
|
||||
cap: IGetSet<number, T>;
|
||||
othersLabel: IGetSet<string, T>;
|
||||
othersGrouper: IGetSet<(data: Array<any>) => Array<any>, T>;
|
||||
}
|
||||
|
||||
export interface BubbleMixin<T> extends ColorMixin<T> {
|
||||
r: IGetSet<D3.Scale.GenericQuantitativeScale<any>, T>;
|
||||
radiusValueAccessor: IGetSet<Accessor<any, number>, T>;
|
||||
minRadiusWithLabel: IGetSet<number, T>;
|
||||
maxBubbleRelativeSize: IGetSet<number, T>;
|
||||
}
|
||||
|
||||
export interface PieChart extends CapMixin<PieChart>, ColorMixin<PieChart>, BaseMixin<PieChart> {
|
||||
slicesCap: IGetSet<number, PieChart>;
|
||||
innerRadius: IGetSet<number, PieChart>;
|
||||
radius: IGetSet<number, PieChart>;
|
||||
cx: IGetSet<number, PieChart>;
|
||||
cy: IGetSet<number, PieChart>;
|
||||
minAngleForLabel: IGetSet<number, PieChart>;
|
||||
}
|
||||
|
||||
export interface BarChart extends StackMixin<BarChart>, CoordinateGridMixin<BarChart> {
|
||||
centerBar: IGetSet<boolean, BarChart>;
|
||||
barPadding: IGetSet<number, BarChart>;
|
||||
outerPadding: IGetSet<number, BarChart>;
|
||||
gap: IGetSet<number, BarChart>;
|
||||
alwaysUseRounding: IGetSet<boolean, BarChart>;
|
||||
}
|
||||
|
||||
export interface RenderDataPointOptions {
|
||||
fillOpacity: number;
|
||||
strokeOpacity: number;
|
||||
radius: number;
|
||||
}
|
||||
|
||||
export interface LineChart extends StackMixin<BarChart>, CoordinateGridMixin<BarChart> {
|
||||
interpolate: IGetSet<string, LineChart>;
|
||||
tension: IGetSet<number, LineChart>;
|
||||
defined: IGetSet<Accessor<any, boolean>, LineChart>;
|
||||
dashStyle: IGetSet<Array<number>, LineChart>;
|
||||
renderArea: IGetSet<boolean, LineChart>;
|
||||
dotRadius: IGetSet<number, LineChart>;
|
||||
renderDataPoints: IGetSet<RenderDataPointOptions|any, LineChart>;
|
||||
}
|
||||
|
||||
export interface DataCountWidgetHTML {
|
||||
all: string;
|
||||
some: string;
|
||||
}
|
||||
|
||||
export interface DataCountWidget extends BaseMixin<DataCountWidget> {
|
||||
html: IGetSet<DataCountWidgetHTML, DataCountWidget>;
|
||||
formatNumber: IGetSet<Accessor<number, string>, DataCountWidget>;
|
||||
}
|
||||
|
||||
export interface DataTableWidget extends BaseMixin<DataTableWidget> {
|
||||
size: IGetSet<number, DataTableWidget>;
|
||||
columns: IGetSet<Array<Accessor<any, any>|string|Array<Accessor<any, any>|string>>, DataTableWidget>;
|
||||
sortBy: IGetSet<Accessor<any, any>, DataTableWidget>;
|
||||
order: IGetSet<(a: any, b: any) => number, DataTableWidget>;
|
||||
}
|
||||
|
||||
export interface DataGridWidget extends BaseMixin<DataGridWidget> {
|
||||
size: IGetSet<number, DataTableWidget>;
|
||||
html: IGetSet<Accessor<any, string>, DataTableWidget>;
|
||||
htmlGroup: IGetSet<Accessor<any, string>, DataTableWidget>;
|
||||
sortBy: IGetSet<Accessor<any, any>, DataTableWidget>;
|
||||
order: IGetSet<(a: any, b: any) => number, DataTableWidget>;
|
||||
}
|
||||
|
||||
export interface BubbleChart extends BubbleMixin<BubbleChart>, CoordinateGridMixin<BubbleChart> {
|
||||
elasticRadius: IGetSet<boolean, BubbleChart>;
|
||||
}
|
||||
|
||||
export interface CompositeChart extends CoordinateGridMixin<CompositeChart> {
|
||||
useRightAxisGridLines: IGetSet<boolean, CompositeChart>;
|
||||
childOptions: IGetSet<any, CompositeChart>;
|
||||
rightYAxisLabel: IGetSet<string, CompositeChart>;
|
||||
compose: IGetSet<Array<BaseMixin<any>>, CompositeChart>;
|
||||
children(): Array<BaseMixin<any>>;
|
||||
shareColors: IGetSet<boolean, CompositeChart>;
|
||||
shareTitle: IGetSet<boolean, CompositeChart>;
|
||||
rightY: IGetSet<D3.Scale.GenericQuantitativeScale<any>, CompositeChart>;
|
||||
rightYAxis: IGetSet<D3.Svg.Axis, CompositeChart>;
|
||||
}
|
||||
|
||||
export interface SeriesChart extends CompositeChart {
|
||||
chart: IGetSet<(c: any) => BaseMixin<any>, SeriesChart>;
|
||||
seriesAccessor: IGetSet<Accessor<any, any>, SeriesChart>;
|
||||
seriesSort: IGetSet<(a: any, b: any) => number, SeriesChart>;
|
||||
valueSort: IGetSet<(a: any, b: any) => number, SeriesChart>;
|
||||
}
|
||||
|
||||
export interface GeoChoroplethLayer {
|
||||
name: string;
|
||||
keyAccessor: Accessor<any, any>;
|
||||
data: any;
|
||||
}
|
||||
|
||||
export interface GeoChoroplethChart extends ColorMixin<GeoChoroplethChart>, BaseMixin<GeoChoroplethChart> {
|
||||
overlayGeoJson(json: any, name: string, keyAccessor: Accessor<any, any>): void;
|
||||
projection: IGetSet<D3.Geo.Projection, GeoChoroplethChart>;
|
||||
geoJsons(): Array<GeoChoroplethLayer>;
|
||||
geoPath(): D3.Geo.Path;
|
||||
removeGeoJson(name: string): void;
|
||||
}
|
||||
|
||||
export interface BubbleOverlayChart extends BubbleMixin<BubbleOverlayChart>, BaseMixin<BubbleOverlayChart> {
|
||||
point(name: string, x: number, y: number): void;
|
||||
}
|
||||
|
||||
export interface RowChart extends CapMixin<RowChart>, MarginMixin<RowChart>, ColorMixin<RowChart>, BaseMixin<RowChart> {
|
||||
x: IGetSet<D3.Scale.GenericQuantitativeScale<any>, RowChart>;
|
||||
renderTitleLabel: IGetSet<boolean, RowChart>;
|
||||
xAxis: IGetSet<D3.Svg.Axis, RowChart>;
|
||||
fixedBarHeight: IGetSet<number, RowChart>;
|
||||
gap: IGetSet<number, RowChart>;
|
||||
elasticX: IGetSet<boolean, RowChart>;
|
||||
labelOffsetX: IGetSet<number, RowChart>;
|
||||
labelOffsetY: IGetSet<number, RowChart>;
|
||||
titleLabelOffsetX: IGetSet<number, RowChart>;
|
||||
}
|
||||
|
||||
export interface ScatterPlot extends CoordinateGridMixin<ScatterPlot> {
|
||||
existenceAccessor: IGetSet<Accessor<any, boolean>, ScatterPlot>;
|
||||
symbol: IGetSet<D3.Svg.Symbol, ScatterPlot>;
|
||||
symbolSize: IGetSet<number, ScatterPlot>;
|
||||
highlightedSize: IGetSet<number, ScatterPlot>;
|
||||
hiddenSize: IGetSet<number, ScatterPlot>;
|
||||
}
|
||||
|
||||
export interface NumberDisplayWidgetHTML {
|
||||
one: string;
|
||||
some: string;
|
||||
none: string;
|
||||
}
|
||||
|
||||
export interface NumberDisplayWidget extends BaseMixin<NumberDisplayWidget> {
|
||||
html: IGetSet<NumberDisplayWidgetHTML, NumberDisplayWidget>;
|
||||
value(): string;
|
||||
formatNumber: IGetSet<Accessor<number, string>, NumberDisplayWidget>;
|
||||
}
|
||||
|
||||
export interface HeatMap extends ColorMixin<HeatMap>, MarginMixin<HeatMap>, BaseMixin<HeatMap> {
|
||||
colsLabel: IGetSet<Accessor<any, string>, HeatMap>;
|
||||
rowsLabel: IGetSet<Accessor<any, string>, HeatMap>;
|
||||
rows: IGetSet<Array<any>, HeatMap>;
|
||||
cols: IGetSet<Array<any>, HeatMap>;
|
||||
boxOnClick: IGetSet<(d: any) => void, HeatMap>;
|
||||
xAxisOnClick: IGetSet<(d: any) => void, HeatMap>;
|
||||
yAxisOnClick: IGetSet<(d: any) => void, HeatMap>;
|
||||
}
|
||||
|
||||
export interface BoxPlot extends CoordinateGridMixin<BoxPlot> {
|
||||
boxPadding: IGetSet<number, BoxPlot>;
|
||||
outerPadding: IGetSet<number, BoxPlot>;
|
||||
boxWidth: IGetSet<number, BoxPlot>;
|
||||
tickFormat: IGetSet<Accessor<number, string>, BoxPlot>;
|
||||
}
|
||||
|
||||
export interface ChartRegistry {
|
||||
has(chart: BaseMixin<any>): boolean;
|
||||
register(chart: BaseMixin<any>, group?: string): void;
|
||||
deregister(chart: BaseMixin<any>, group?: string): void;
|
||||
clear(group?: string): void;
|
||||
list(group?: string): Array<BaseMixin<any>>;
|
||||
}
|
||||
|
||||
export interface Base {
|
||||
chartRegistry: ChartRegistry;
|
||||
registerChart(chart: BaseMixin<any>, group?: string): void;
|
||||
deregisterChart(chart: BaseMixin<any>, group?: string): void;
|
||||
hasChart(chart: BaseMixin<any>): boolean;
|
||||
deregisterAllCharts(group?: string): void;
|
||||
filterAll(group?: string): void;
|
||||
refocusAll(group?: string): void;
|
||||
renderAll(group?: string): void;
|
||||
redrawAll(group?: string): void;
|
||||
disableTransitions: boolean;
|
||||
transition(selections: D3.Selection, duration: number, callback: (s: D3.Selection) => void): void;
|
||||
|
||||
units: Units;
|
||||
events: Events;
|
||||
errors: Errors;
|
||||
instanceOfChart(object: any): boolean;
|
||||
logger: Logger;
|
||||
override(object: any, fnName: string, newFn: Function): void;
|
||||
printers: Printers;
|
||||
pluck(n: string, f?: Accessor<any, any>): Accessor<any, any>;
|
||||
round: Round;
|
||||
utils: Utils;
|
||||
|
||||
legend(): Legend;
|
||||
|
||||
pieChart(parent: string, chartGroup?: string): PieChart;
|
||||
barChart(parent: string, chartGroup?: string): BarChart;
|
||||
lineChart(parent: string, chartGroup?: string): LineChart;
|
||||
dataCount(parent: string, chartGroup?: string): DataCountWidget;
|
||||
dataTable(parent: string, chartGroup?: string): DataTableWidget;
|
||||
dataGrid(parent: string, chartGroup?: string): DataGridWidget;
|
||||
bubbleChart(parent: string, chartGroup?: string): BubbleChart;
|
||||
compositeChart(parent: string, chartGroup?: string): CompositeChart;
|
||||
seriesChart(parent: string, chartGroup?: string): SeriesChart;
|
||||
geoChoroplethChart(parent: string, chartGroup?: string): GeoChoroplethChart;
|
||||
bubbleOverlayChart(parent: string, chartGroup?: string): BubbleOverlayChart;
|
||||
rowChart(parent: string, chartGroup?: string): RowChart;
|
||||
scatterPlot(parent: string, chartGroup?: string): ScatterPlot;
|
||||
numberDisplay(parent: string, chartGroup?: string): NumberDisplayWidget;
|
||||
heatMap(parent: string, chartGroup?: string): HeatMap;
|
||||
boxPlot(parent: string, chartGroup?: string): BoxPlot;
|
||||
}
|
||||
}
|
||||
|
||||
declare var dc: DC.Base;
|
||||
|
||||
declare module 'dc' {
|
||||
export = dc;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user