mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-27 11:40:08 +08:00
Merge pull request #7926 from HPFOD/chartist-typings-update
Update Chartist Typing Definitions
This commit is contained in:
+297
-63
@@ -1,5 +1,15 @@
|
||||
///<reference path="chartist.d.ts" />
|
||||
|
||||
Chartist.escapingMap = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
'\'': ''',
|
||||
};
|
||||
|
||||
Chartist.precision = 8;
|
||||
|
||||
new Chartist.Line('.ct-chart', {
|
||||
labels: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'],
|
||||
series: [
|
||||
@@ -8,26 +18,26 @@ new Chartist.Line('.ct-chart', {
|
||||
[1, 3, 4, 5, 6]
|
||||
]
|
||||
}, {
|
||||
fullWidth: true,
|
||||
chartPadding: {
|
||||
right: 40
|
||||
}
|
||||
});
|
||||
fullWidth: true,
|
||||
chartPadding: {
|
||||
right: 40
|
||||
}
|
||||
});
|
||||
|
||||
var lineChart = new Chartist.Line('.ct-chart', {
|
||||
labels: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],
|
||||
series: [
|
||||
[5, 5, 10, 8, 7, 5, 4, null, null, null, 10, 10, 7, 8, 6, 9],
|
||||
[10, 15, null, 12, null, 10, 12, 15, null, null, 12, null, 14, null, null, null],
|
||||
[null, null, null, null, 3, 4, 1, 3, 4, 6, 7, 9, 5, null, null, null]
|
||||
[null, null, null, null, 3, 4, 1, 3, 4, 6, 7, 9, 5, null, null, null]
|
||||
]
|
||||
}, {
|
||||
fullWidth: true,
|
||||
chartPadding: {
|
||||
right: 10
|
||||
},
|
||||
low: 0
|
||||
});
|
||||
fullWidth: true,
|
||||
chartPadding: {
|
||||
right: 10
|
||||
},
|
||||
low: 0
|
||||
});
|
||||
|
||||
new Chartist.Line('.ct-chart', {
|
||||
labels: ['1', '2', '3', '4', '5', '6'],
|
||||
@@ -47,10 +57,10 @@ var data = {
|
||||
series: [5, 3, 4]
|
||||
};
|
||||
|
||||
var sum = function(a: number, b: number) { return a + b };
|
||||
var sum = (a: number, b: number) => { return a + b };
|
||||
|
||||
new Chartist.Pie('.ct-chart', data, {
|
||||
labelInterpolationFnc: function(value: number) {
|
||||
labelInterpolationFnc: (value: number) => {
|
||||
return Math.round(value / data.series.reduce(sum) * 100) + '%';
|
||||
}
|
||||
});
|
||||
@@ -58,26 +68,24 @@ new Chartist.Pie('.ct-chart', data, {
|
||||
new Chartist.Pie('.ct-chart', {
|
||||
series: [20, 10, 30, 40]
|
||||
}, {
|
||||
donut: true,
|
||||
donutWidth: 60,
|
||||
startAngle: 270,
|
||||
total: 200,
|
||||
showLabel: false
|
||||
});
|
||||
|
||||
donut: true,
|
||||
donutWidth: 60,
|
||||
startAngle: 270,
|
||||
total: 200,
|
||||
showLabel: false
|
||||
});
|
||||
|
||||
// Animation Donut example
|
||||
|
||||
var chart = new Chartist.Pie('.ct-chart', {
|
||||
series: [10, 20, 50, 20, 5, 50, 15],
|
||||
labels: [1, 2, 3, 4, 5, 6, 7]
|
||||
}, {
|
||||
donut: true,
|
||||
showLabel: false
|
||||
});
|
||||
donut: true,
|
||||
showLabel: false
|
||||
});
|
||||
|
||||
chart.on('draw', function(data: any) {
|
||||
if(data.type === 'slice') {
|
||||
chart.on('draw', (data: any) => {
|
||||
if (data.type === 'slice') {
|
||||
// Get the total path length in order to use for dash array animation
|
||||
var pathLength = data.element._node.getTotalLength();
|
||||
|
||||
@@ -87,12 +95,12 @@ chart.on('draw', function(data: any) {
|
||||
});
|
||||
|
||||
// Create animation definition while also assigning an ID to the animation for later sync usage
|
||||
var animationDefinition: any = {
|
||||
var animationDefinition: Chartist.IChartistAnimations = {
|
||||
'stroke-dashoffset': {
|
||||
id: 'anim' + data.index,
|
||||
dur: 1000,
|
||||
from: -pathLength + 'px',
|
||||
to: '0px',
|
||||
to: '0px',
|
||||
easing: Chartist.Svg.Easing.easeOutQuint,
|
||||
// We need to use `fill: 'freeze'` otherwise our animation will fall back to initial (not visible)
|
||||
fill: 'freeze'
|
||||
@@ -100,7 +108,7 @@ chart.on('draw', function(data: any) {
|
||||
};
|
||||
|
||||
// If this was not the first slice, we need to time the animation so that it uses the end sync event of the previous animation
|
||||
if(data.index !== 0) {
|
||||
if (data.index !== 0) {
|
||||
animationDefinition['stroke-dashoffset'].begin = 'anim' + (data.index - 1) + '.end';
|
||||
}
|
||||
|
||||
@@ -119,8 +127,8 @@ new Chartist.Bar('.ct-chart', {
|
||||
labels: ['XS', 'S', 'M', 'L', 'XL', 'XXL', 'XXXL'],
|
||||
series: [20, 60, 120, 200, 180, 20, 10]
|
||||
}, {
|
||||
distributeSeries: true
|
||||
});
|
||||
distributeSeries: true
|
||||
});
|
||||
|
||||
new Chartist.Bar('.ct-chart', {
|
||||
labels: ['Quarter 1', 'Quarter 2', 'Quarter 3', 'Quarter 4'],
|
||||
@@ -132,39 +140,265 @@ new Chartist.Bar('.ct-chart', {
|
||||
[4, 1, 2, 1]
|
||||
]
|
||||
}, {
|
||||
// Default mobile configuration
|
||||
stackBars: true,
|
||||
axisX: {
|
||||
labelInterpolationFnc: function(value: string) {
|
||||
return value.split(/\s+/).map(function(word: string) {
|
||||
return word[0];
|
||||
}).join('');
|
||||
}
|
||||
},
|
||||
axisY: {
|
||||
offset: 20
|
||||
}
|
||||
}, [
|
||||
// Options override for media > 400px
|
||||
['screen and (min-width: 400px)', {
|
||||
reverseData: true,
|
||||
horizontalBars: true,
|
||||
// Default mobile configuration
|
||||
stackBars: true,
|
||||
axisX: {
|
||||
labelInterpolationFnc: Chartist.noop
|
||||
labelInterpolationFnc: (value: string) => {
|
||||
return value.split(/\s+/).map((word: string) => {
|
||||
return word[0];
|
||||
}).join('');
|
||||
}
|
||||
},
|
||||
axisY: {
|
||||
offset: 60
|
||||
offset: 20
|
||||
}
|
||||
}, [
|
||||
// Options override for media > 400px
|
||||
['screen and (min-width: 400px)', {
|
||||
reverseData: true,
|
||||
horizontalBars: true,
|
||||
axisX: {
|
||||
labelInterpolationFnc: Chartist.noop
|
||||
},
|
||||
axisY: {
|
||||
offset: 60
|
||||
}
|
||||
}],
|
||||
// Options override for media > 800px
|
||||
['screen and (min-width: 800px)', {
|
||||
stackBars: false,
|
||||
seriesBarDistance: 10
|
||||
}],
|
||||
// Options override for media > 1000px
|
||||
['screen and (min-width: 1000px)', {
|
||||
reverseData: false,
|
||||
horizontalBars: false,
|
||||
seriesBarDistance: 15
|
||||
}]
|
||||
]);
|
||||
|
||||
new Chartist.Pie('.ct-chart', {
|
||||
series: [{
|
||||
value: 20,
|
||||
name: 'Series 1',
|
||||
className: 'my-custom-class-one',
|
||||
meta: 'Meta One'
|
||||
}, {
|
||||
value: 10,
|
||||
name: 'Series 2',
|
||||
className: 'my-custom-class-two',
|
||||
meta: 'Meta Two'
|
||||
}, {
|
||||
value: 70,
|
||||
name: 'Series 3',
|
||||
className: 'my-custom-class-three',
|
||||
meta: 'Meta Three'
|
||||
}]
|
||||
});
|
||||
|
||||
new Chartist.Bar('.bar-chart', {
|
||||
labels: ['foo', 'bar', 'foobar'],
|
||||
series: [
|
||||
{
|
||||
data: [1],
|
||||
className: 'graph-foo',
|
||||
},
|
||||
{
|
||||
data: [10],
|
||||
className: 'graph-foo',
|
||||
},
|
||||
{
|
||||
data: [12],
|
||||
className: 'graph-foo',
|
||||
}]
|
||||
}, {
|
||||
seriesBarDistance: 30,
|
||||
reverseData: true,
|
||||
horizontalBars: true,
|
||||
height: '115px',
|
||||
axisY: {
|
||||
offset: 70,
|
||||
showGrid: false,
|
||||
},
|
||||
axisX: {
|
||||
scaleMinSpace: 200
|
||||
}
|
||||
});
|
||||
|
||||
new Chartist.Line('.ct-chart', {
|
||||
labels: [1, 2, 3, 4, 5, 6, 7, 8],
|
||||
series: [
|
||||
[5, 9, 7, 8, 5, 3, 5, 4]
|
||||
]
|
||||
}, {
|
||||
ticks: [0, 4],
|
||||
low: 0,
|
||||
showArea: true,
|
||||
axisY: {
|
||||
showLabel: true,
|
||||
showGrid: false,
|
||||
ticks: [1, 4],
|
||||
type: Chartist.FixedScaleAxis
|
||||
}
|
||||
});
|
||||
|
||||
new Chartist.Line('.ct-chart', {
|
||||
labels: [1, 2, 3, 4, 5, 6, 7, 8],
|
||||
series: [
|
||||
[5, 9, 7, 8, 5, 3, 5, 4]
|
||||
]
|
||||
}, {
|
||||
ticks: [0, 4],
|
||||
low: 0,
|
||||
showArea: true,
|
||||
axisX: {
|
||||
showGrid: false
|
||||
},
|
||||
axisY: {
|
||||
showLabel: true,
|
||||
showGrid: false,
|
||||
ticks: [1, 4],
|
||||
type: Chartist.FixedScaleAxis
|
||||
}
|
||||
});
|
||||
|
||||
var chart2 = new Chartist.Line('.ct-chart', {
|
||||
labels: [1, 2, 3, 4, 5],
|
||||
series: [
|
||||
[12, 9, 7, 8, 5]
|
||||
]
|
||||
});
|
||||
|
||||
// Listening for draw events that get emitted by the Chartist chart
|
||||
chart2.on('draw', (data: any) => {
|
||||
// If the draw event was triggered from drawing a point on the line chart
|
||||
if (data.type === 'point') {
|
||||
// We are creating a new path SVG element that draws a triangle around the point coordinates
|
||||
var triangle = new Chartist.Svg('path', {
|
||||
d: ['M',
|
||||
data.x,
|
||||
data.y - 15,
|
||||
'L',
|
||||
data.x - 15,
|
||||
data.y + 8,
|
||||
'L',
|
||||
data.x + 15,
|
||||
data.y + 8,
|
||||
'z'].join(' '),
|
||||
style: 'fill-opacity: 1'
|
||||
}, 'ct-area');
|
||||
|
||||
// With data.element we get the Chartist SVG wrapper and we can replace the original point drawn by Chartist with our newly created triangle
|
||||
data.element.replace(triangle);
|
||||
}
|
||||
});
|
||||
|
||||
// Create a simple bi-polar bar chart
|
||||
var biPolarChart = new Chartist.Bar('.ct-chart', {
|
||||
labels: ['W1', 'W2', 'W3', 'W4', 'W5', 'W6', 'W7', 'W8', 'W9', 'W10'],
|
||||
series: [
|
||||
[1, 2, 4, 8, 6, -2, -1, -4, -6, -2]
|
||||
]
|
||||
}, {
|
||||
high: 10,
|
||||
low: -10,
|
||||
axisX: {
|
||||
labelInterpolationFnc: (value: any, index: number) => {
|
||||
return index % 2 === 0 ? value : null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Listen for draw events on the bar chart
|
||||
biPolarChart.on('draw', (data: any) => {
|
||||
// If this draw event is of type bar we can use the data to create additional content
|
||||
if (data.type === 'bar') {
|
||||
// We use the group element of the current series to append a simple circle with the bar peek coordinates and a circle radius that is depending on the value
|
||||
data.group.append(new Chartist.Svg('circle', {
|
||||
cx: data.x2,
|
||||
cy: data.y2,
|
||||
r: Math.abs(Chartist.getMultiValue(data.value)) * 2 + 5
|
||||
}, 'ct-slice-pie'));
|
||||
}
|
||||
});
|
||||
|
||||
new Chartist.Bar('.ct-chart', {
|
||||
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
||||
series: [
|
||||
[5, 4, 3, 7, 5, 10, 3],
|
||||
[3, 2, 9, 5, 4, 6, 4]
|
||||
]
|
||||
}, {
|
||||
axisX: {
|
||||
// On the x-axis start means top and end means bottom
|
||||
position: 'start'
|
||||
},
|
||||
axisY: {
|
||||
// On the y-axis start means left and end means right
|
||||
position: 'end'
|
||||
}
|
||||
});
|
||||
|
||||
new Chartist.Line('.ct-chart', {
|
||||
labels: [1, 2, 3, 4, 5],
|
||||
series: [[1, 2, 8, 1, 7]]
|
||||
}, {
|
||||
lineSmooth: Chartist.Interpolation.none({
|
||||
fillHoles: false
|
||||
})
|
||||
});
|
||||
|
||||
new Chartist.Line('.ct-chart', {
|
||||
labels: [1, 2, 3, 4, 5],
|
||||
series: [[1, 2, 8, 1, 7]]
|
||||
}, {
|
||||
lineSmooth: Chartist.Interpolation.simple({
|
||||
divisor: 2,
|
||||
fillHoles: false
|
||||
})
|
||||
});
|
||||
|
||||
new Chartist.Line('.ct-chart', {
|
||||
labels: [1, 2, 3, 4, 5],
|
||||
series: [[1, 2, 8, 1, 7]]
|
||||
}, {
|
||||
lineSmooth: Chartist.Interpolation.cardinal({
|
||||
tension: 1,
|
||||
fillHoles: false
|
||||
})
|
||||
});
|
||||
|
||||
new Chartist.Line('.ct-chart', {
|
||||
labels: [1, 2, 3, 4, 5],
|
||||
series: [[1, 2, 8, 1, 7]]
|
||||
}, {
|
||||
lineSmooth: Chartist.Interpolation.step({
|
||||
postpone: true,
|
||||
fillHoles: false
|
||||
})
|
||||
});
|
||||
|
||||
var overlappingBarsData: Chartist.IChartistData = {
|
||||
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
||||
series: [
|
||||
[5, 4, 3, 7, 5, 10, 3, 4, 8, 10, 6, 8],
|
||||
[3, 2, 9, 5, 4, 6, 4, 6, 7, 8, 7, 4]
|
||||
]
|
||||
};
|
||||
|
||||
var overlappingBarsOptions: Chartist.IBarChartOptions = {
|
||||
seriesBarDistance: 10
|
||||
};
|
||||
|
||||
var overlappingBarsResponsiveOptions: Array<Chartist.IResponsiveOptionTuple<Chartist.IBarChartOptions>> = [
|
||||
['screen and (max-width: 640px)', {
|
||||
seriesBarDistance: 5,
|
||||
axisX: {
|
||||
labelInterpolationFnc: (value: any) => {
|
||||
return value[0];
|
||||
}
|
||||
}
|
||||
}],
|
||||
// Options override for media > 800px
|
||||
['screen and (min-width: 800px)', {
|
||||
stackBars: false,
|
||||
seriesBarDistance: 10
|
||||
}],
|
||||
// Options override for media > 1000px
|
||||
['screen and (min-width: 1000px)', {
|
||||
reverseData: false,
|
||||
horizontalBars: false,
|
||||
seriesBarDistance: 15
|
||||
}]
|
||||
]);
|
||||
];
|
||||
|
||||
new Chartist.Bar('.ct-chart', overlappingBarsData, overlappingBarsOptions, overlappingBarsResponsiveOptions);
|
||||
|
||||
Vendored
+305
-14
@@ -1,16 +1,62 @@
|
||||
// Type definitions for Chartist v0.9.4
|
||||
// Type definitions for Chartist v0.9.5
|
||||
// Project: https://github.com/gionkunz/chartist-js
|
||||
// Definitions by: Matt Gibbs <https://github.com/mtgibbs>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module Chartist {
|
||||
|
||||
interface ChartistStatic {
|
||||
|
||||
/**
|
||||
* Precision level used internally in Chartist for rounding. If you require more decimal places you can increase this number.
|
||||
*/
|
||||
precision: number;
|
||||
|
||||
/**
|
||||
* A map with characters to escape for strings to be safely used as attribute values.
|
||||
*/
|
||||
escapingMap: IChartistEscapeMap;
|
||||
|
||||
Pie: IChartistPieChart;
|
||||
Bar: IChartistBarChart;
|
||||
Line: IChartistLineChart;
|
||||
|
||||
Svg: any;
|
||||
FixedScaleAxis: IFixedScaleAxisStatic;
|
||||
AutoScaleAxis: IAutoScaleAxisStatic;
|
||||
StepAxis: IStepAxisStatic;
|
||||
|
||||
Svg: ChartistSvgStatic;
|
||||
Interpolation: ChartistInterpolationStatic;
|
||||
|
||||
noop: Function;
|
||||
|
||||
alphaNumerate(n: number): string;
|
||||
extend(target: Object, ...sources: Object[]): Object;
|
||||
|
||||
replaceAll(str: string, subStr: string, newSubStr: string): string;
|
||||
ensureUnit(value: number, unit: string): string;
|
||||
quantity(input: string | number): Object;
|
||||
|
||||
query(query: Node | string): Node;
|
||||
times(length: number): Array<any>;
|
||||
sum(previous: number, current: number): number;
|
||||
mapMultiply(factor: number): (num: number) => number;
|
||||
mapAdd(addend: number): (num: number) => number;
|
||||
serialMap(arr: Array<any>, cb: Function): Array<any>;
|
||||
roundWithPrecision(value: number, digits?: number): number;
|
||||
|
||||
getMultiValue(value: any, dimension?: any): number; // this method is not documented, but it is used in the examples
|
||||
|
||||
serialize(data: Object | string | number): string;
|
||||
deserialize(data: string): Object | string | number;
|
||||
|
||||
createSvg(container: Node, width: string, height: string, className: string): Object; // TODO: Figure out if this is returning a ChartistSVGWrapper or an actual SVGElement
|
||||
|
||||
plugins: any;
|
||||
}
|
||||
|
||||
interface IChartistEscapeMap {
|
||||
[Key: string]: string;
|
||||
}
|
||||
|
||||
interface IResponsiveOptionTuple<T extends IChartOptions> extends Array<string | T> {
|
||||
@@ -18,9 +64,33 @@ declare module Chartist {
|
||||
1: T;
|
||||
}
|
||||
|
||||
// these have no other purpose than to help define the types that can be placed on
|
||||
// a line chart axisX
|
||||
// in the actual chartist library these are classes that project their options onto
|
||||
// the parent class
|
||||
interface IFixedScaleAxisStatic { }
|
||||
interface IAutoScaleAxisStatic { }
|
||||
interface IStepAxisStatic { }
|
||||
|
||||
// data formats are not well documented on all the ways they can be passed to the constructors
|
||||
// this definition gives some intellisense, but does not protect the user from misuse
|
||||
// TODO: come in and tidy this up and make it fit better
|
||||
interface IChartistData {
|
||||
labels?: Array<string> | Array<number> | Array<Date>;
|
||||
series: Array<IChartistSeriesData> | Array<number> | Array<Array<number>>;
|
||||
}
|
||||
|
||||
interface IChartistSeriesData {
|
||||
name?: string;
|
||||
value?: number;
|
||||
data?: Array<number>;
|
||||
className?: string;
|
||||
meta?: string; // I assume this could probably be a number as well?
|
||||
}
|
||||
|
||||
interface IChartistBase<T extends IChartOptions> {
|
||||
container: any;
|
||||
data: Object;
|
||||
data: IChartistData;
|
||||
defaultOptions: T;
|
||||
options: T;
|
||||
responsiveOptions: Array<IResponsiveOptionTuple<T>>;
|
||||
@@ -32,6 +102,8 @@ declare module Chartist {
|
||||
supportsAnimations: boolean;
|
||||
resizeListener: any;
|
||||
|
||||
plugins?: Array<any>; // all of these plugins seem to be functions with options, but keeping type any for now
|
||||
|
||||
update(data: Object, options?: T, override?: boolean): void;
|
||||
detatch(): void;
|
||||
|
||||
@@ -55,15 +127,15 @@ declare module Chartist {
|
||||
}
|
||||
|
||||
interface IChartistPieChart extends IChartistBase<IPieChartOptions> {
|
||||
new (target: any, data: Object, options?: IPieChartOptions, responsiveOptions?: Array<IResponsiveOptionTuple<IPieChartOptions>>): IChartistPieChart;
|
||||
new (target: any, data: IChartistData, options?: IPieChartOptions, responsiveOptions?: Array<IResponsiveOptionTuple<IPieChartOptions>>): IChartistPieChart;
|
||||
}
|
||||
|
||||
interface IChartistLineChart extends IChartistBase<ILineChartOptions> {
|
||||
new (target: any, data: Object, options?: ILineChartOptions, responsiveOptions?: Array<IResponsiveOptionTuple<ILineChartOptions>>): IChartistLineChart;
|
||||
new (target: any, data: IChartistData, options?: ILineChartOptions, responsiveOptions?: Array<IResponsiveOptionTuple<ILineChartOptions>>): IChartistLineChart;
|
||||
}
|
||||
|
||||
interface IChartistBarChart extends IChartistBase<IBarChartOptions> {
|
||||
new (target: any, data: Object, options?: IBarChartOptions, responsiveOptions?: Array<IResponsiveOptionTuple<IBarChartOptions>>): IChartistBarChart;
|
||||
new (target: any, data: IChartistData, options?: IBarChartOptions, responsiveOptions?: Array<IResponsiveOptionTuple<IBarChartOptions>>): IChartistBarChart;
|
||||
}
|
||||
|
||||
interface IChartOptions {
|
||||
@@ -71,6 +143,8 @@ declare module Chartist {
|
||||
* If true the whole data is reversed including labels, the series order as well as the whole series data arrays.
|
||||
*/
|
||||
reverseData?: boolean;
|
||||
|
||||
plugins?: Array<any>;
|
||||
}
|
||||
|
||||
interface IPieChartOptions extends IChartOptions {
|
||||
@@ -163,6 +237,7 @@ declare module Chartist {
|
||||
height?: number | string;
|
||||
high?: number;
|
||||
low?: number;
|
||||
ticks?: Array<string | number>;
|
||||
onlyInteger?: boolean;
|
||||
chartPadding?: IChartPadding;
|
||||
seriesBarDistance?: number;
|
||||
@@ -206,20 +281,20 @@ declare module Chartist {
|
||||
}
|
||||
|
||||
interface ILineChartOptions extends IChartOptions {
|
||||
axisX?: ILineChartXAxis;
|
||||
axisY?: ILineChartYAxis;
|
||||
axisX?: IChartistStepAxis | IChartistFixedScaleAxis | IChartistAutoScaleAxis;
|
||||
axisY?: IChartistStepAxis | IChartistFixedScaleAxis | IChartistAutoScaleAxis;
|
||||
width?: number | string;
|
||||
height?: number | string;
|
||||
showLine?: boolean;
|
||||
showPoint?: boolean;
|
||||
showArea?: boolean;
|
||||
areaBase?: number;
|
||||
lineSmooth?: boolean;
|
||||
lineSmooth?: Function | boolean;
|
||||
low?: number;
|
||||
high?: number;
|
||||
ticks?: Array<string | number>;
|
||||
chartPadding?: IChartPadding;
|
||||
fullWidth?: boolean;
|
||||
reverseData?: boolean;
|
||||
classNames?: ILineChartClasses;
|
||||
}
|
||||
|
||||
@@ -233,18 +308,31 @@ declare module Chartist {
|
||||
showLabel?: boolean;
|
||||
showGrid?: boolean;
|
||||
labelInterpolationFnc?: Function;
|
||||
type?: any;
|
||||
}
|
||||
|
||||
interface ILineChartXAxis extends ILineChartAxis {
|
||||
interface IChartistStepAxis extends ILineChartAxis {
|
||||
type?: IStepAxisStatic;
|
||||
ticks?: Array<string> | Array<number>;
|
||||
stretch?: boolean;
|
||||
}
|
||||
|
||||
interface ILineChartYAxis extends ILineChartAxis {
|
||||
interface IChartistFixedScaleAxis extends ILineChartAxis {
|
||||
type?: IFixedScaleAxisStatic;
|
||||
high?: number;
|
||||
low?: number;
|
||||
divisor?: number;
|
||||
ticks?: Array<string> | Array<number>;
|
||||
}
|
||||
|
||||
interface IChartistAutoScaleAxis extends ILineChartAxis {
|
||||
high?: number;
|
||||
low?: number;
|
||||
scaleMinSpace?: number;
|
||||
onlyInteger?: boolean;
|
||||
referenceValue?: number;
|
||||
type?: IAutoScaleAxisStatic;
|
||||
}
|
||||
|
||||
// TODO: Finish documenting all of the defaults
|
||||
interface ILineChartClasses {
|
||||
/**
|
||||
* Default is 'ct-chart-line'
|
||||
@@ -263,6 +351,209 @@ declare module Chartist {
|
||||
start?: string;
|
||||
end?: string;
|
||||
}
|
||||
|
||||
interface ChartistSvgStatic {
|
||||
new (name: HTMLElement | string, attributes: Object, className?: string, parent?: Object, insertFirst?: boolean): IChartistSvg;
|
||||
|
||||
Easing: ChartistEasingStatic;
|
||||
|
||||
/**
|
||||
* This method checks for support of a given SVG feature like Extensibility, SVG-animation or the like. Check http://www.w3.org/TR/SVG11/feature for a detailed list.
|
||||
*/
|
||||
isSupported(feature: string): boolean;
|
||||
}
|
||||
|
||||
interface IChartistSvg {
|
||||
|
||||
/**
|
||||
* Set attributes on the current SVG element of the wrapper you're currently working on.
|
||||
*/
|
||||
attr(attributes: Object | string, ns: string): Object | string;
|
||||
|
||||
/**
|
||||
* Create a new SVG element whose wrapper object will be selected for further operations. This way you can also create nested groups easily.
|
||||
*/
|
||||
elem(name: string, attributes?: Object, className?: string, insertFirst?: boolean): IChartistSvg;
|
||||
|
||||
/**
|
||||
* Returns the parent Chartist.SVG wrapper object
|
||||
*/
|
||||
parent(): IChartistSvg;
|
||||
|
||||
/**
|
||||
* This method returns a Chartist.Svg wrapper around the root SVG element of the current tree.
|
||||
*/
|
||||
root(): IChartistSvg;
|
||||
|
||||
/**
|
||||
* Find the first child SVG element of the current element that matches a CSS selector. The returned object is a Chartist.Svg wrapper.
|
||||
*/
|
||||
querySelector(selector: string): IChartistSvg;
|
||||
|
||||
/**
|
||||
* Find the all child SVG elements of the current element that match a CSS selector. The returned object is a Chartist.Svg.List wrapper.
|
||||
*/
|
||||
querySelectorAll(selector: string): any; // this returns an svg wrapper list in the docs, need to see if that's just an array or a special list
|
||||
|
||||
/**
|
||||
* This method creates a foreignObject (see https://developer.mozilla.org/en-US/docs/Web/SVG/Element/foreignObject) that allows to embed HTML content into a SVG graphic. With the help of foreignObjects you can enable the usage of regular HTML elements inside of SVG where they are subject for SVG positioning and transformation but the Browser will use the HTML rendering capabilities for the containing DOM.
|
||||
*/
|
||||
foreignObject(content: any, attributes?: Object, className?: string, insertFirst?: boolean): IChartistSvg;
|
||||
|
||||
/**
|
||||
* This method adds a new text element to the current Chartist.Svg wrapper.
|
||||
*/
|
||||
text(t: string): IChartistSvg;
|
||||
|
||||
/**
|
||||
* This method will clear all child nodes of the current wrapper object.
|
||||
*/
|
||||
empty(): IChartistSvg;
|
||||
|
||||
/**
|
||||
* This method will cause the current wrapper to remove itself from its parent wrapper. Use this method if you'd like to get rid of an element in a given DOM structure.
|
||||
*/
|
||||
remove(): IChartistSvg;
|
||||
|
||||
/**
|
||||
* This method will replace the element with a new element that can be created outside of the current DOM.
|
||||
*/
|
||||
replace(): IChartistSvg;
|
||||
|
||||
/**
|
||||
* This method will append an element to the current element as a child.
|
||||
*/
|
||||
append(): IChartistSvg;
|
||||
|
||||
/**
|
||||
* Returns an array of class names that are attached to the current wrapper element. This method can not be chained further.
|
||||
*/
|
||||
classes(): Array<string>;
|
||||
|
||||
/**
|
||||
* Adds one or a space separated list of classes to the current element and ensures the classes are only existing once.
|
||||
*
|
||||
* @method addClass
|
||||
* @param names {string} A white space separated list of class names
|
||||
*/
|
||||
addClass(names: string): IChartistSvg;
|
||||
|
||||
/**
|
||||
* Removes one or a space separated list of classes from the current element.
|
||||
*
|
||||
* @method removeClass
|
||||
* @param names {string} A white space separated list of class names
|
||||
*/
|
||||
removeClass(names: string): IChartistSvg;
|
||||
|
||||
/**
|
||||
* Removes all classes from the current element.
|
||||
*/
|
||||
removeAllClasses(): IChartistSvg;
|
||||
|
||||
/**
|
||||
* Get element height with fallback to svg BoundingBox or parent container dimensions
|
||||
*/
|
||||
height(): number;
|
||||
|
||||
/**
|
||||
* The animate function lets you animate the current element with SMIL animations. You can add animations for multiple attributes at the same time by using an animation definition object. This object should contain SMIL animation attributes.
|
||||
*/
|
||||
animate(animations: IChartistAnimations, guided: boolean, eventEmitter: Object): IChartistSvg;
|
||||
|
||||
/**
|
||||
* "Safe" way to get property value from svg BoundingBox. This is a workaround. Firefox throws an NS_ERROR_FAILURE error if getBBox() is called on an invisible node.
|
||||
* THIS IS A WORKAROUND
|
||||
*/
|
||||
getBBoxProperty(node: SVGElement, prop: string): string; // TODO: find a good example of this and add it to the tests, it might belong to static
|
||||
}
|
||||
|
||||
interface IChartistAnimations {
|
||||
[Key: string]: IChartistAnimationOptions;
|
||||
}
|
||||
|
||||
interface IChartistAnimationOptions {
|
||||
id?: string;
|
||||
dur: string | number;
|
||||
from: string | number;
|
||||
to: string | number;
|
||||
easing?: IChartistEasingDefinition | string;
|
||||
fill?: string;
|
||||
begin?: string;
|
||||
}
|
||||
|
||||
interface IChartistEasingDefinition {
|
||||
0: number;
|
||||
1: number;
|
||||
2: number;
|
||||
3: number;
|
||||
}
|
||||
|
||||
interface ChartistEasingStatic {
|
||||
easeInSine: IChartistEasingDefinition;
|
||||
easeOutSine: IChartistEasingDefinition;
|
||||
easeInOutSine: IChartistEasingDefinition;
|
||||
easeInQuad: IChartistEasingDefinition;
|
||||
easeOutQuad: IChartistEasingDefinition;
|
||||
easeInOutQuad: IChartistEasingDefinition;
|
||||
easeInCubic: IChartistEasingDefinition;
|
||||
easeOutCubic: IChartistEasingDefinition;
|
||||
easeInOutCubic: IChartistEasingDefinition;
|
||||
easeInQuart: IChartistEasingDefinition;
|
||||
easeOutQuart: IChartistEasingDefinition;
|
||||
easeInOutQuart: IChartistEasingDefinition;
|
||||
easeInQuint: IChartistEasingDefinition;
|
||||
easeOutQuint: IChartistEasingDefinition;
|
||||
easeInOutQuint: IChartistEasingDefinition;
|
||||
easeInExpo: IChartistEasingDefinition;
|
||||
easeOutExpo: IChartistEasingDefinition;
|
||||
easeInOutExpo: IChartistEasingDefinition;
|
||||
easeInCirc: IChartistEasingDefinition;
|
||||
easeOutCirc: IChartistEasingDefinition;
|
||||
easeInOutCirc: IChartistEasingDefinition;
|
||||
easeInBack: IChartistEasingDefinition;
|
||||
easeOutBack: IChartistEasingDefinition;
|
||||
easeInOutBack: IChartistEasingDefinition;
|
||||
}
|
||||
|
||||
interface ChartistInterpolationStatic {
|
||||
|
||||
/**
|
||||
* This interpolation function does not smooth the path and the result is only containing lines and no curves.
|
||||
*/
|
||||
none(options?: IChartistInterpolationOptions): Function;
|
||||
|
||||
/**
|
||||
* Simple smoothing creates horizontal handles that are positioned with a fraction of the length between two data points. You can use the divisor option to specify the amount of smoothing.
|
||||
*/
|
||||
simple(options?: IChartistSimpleInterpolationOptions): Function;
|
||||
|
||||
/**
|
||||
* Cardinal / Catmull-Rome spline interpolation is the default smoothing function in Chartist. It produces nice results where the splines will always meet the points. It produces some artifacts though when data values are increased or decreased rapidly. The line may not follow a very accurate path and if the line should be accurate this smoothing function does not produce the best results.
|
||||
*/
|
||||
cardinal(options?: IChartistCardinalInterpolationOptions): Function;
|
||||
|
||||
/**
|
||||
* Step interpolation will cause the line chart to move in steps rather than diagonal or smoothed lines. This interpolation will create additional points that will also be drawn when the showPoint option is enabled.
|
||||
*/
|
||||
step(options?: IChartistStepInterpolationOptions): Function;
|
||||
}
|
||||
|
||||
interface IChartistInterpolationOptions {
|
||||
fillHoles?: boolean;
|
||||
}
|
||||
|
||||
interface IChartistSimpleInterpolationOptions extends IChartistInterpolationOptions {
|
||||
divisor?: number;
|
||||
}
|
||||
|
||||
interface IChartistCardinalInterpolationOptions extends IChartistInterpolationOptions {
|
||||
tension?: number;
|
||||
}
|
||||
|
||||
interface IChartistStepInterpolationOptions extends IChartistInterpolationOptions {
|
||||
postpone?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare var Chartist: Chartist.ChartistStatic;
|
||||
|
||||
Reference in New Issue
Block a user