|
|
|
@ -1,28 +1,39 @@
|
|
|
|
|
import { Serie, Options } from '@chartwerk/core'; |
|
|
|
|
|
|
|
|
|
export type BarSerieParams = { |
|
|
|
|
matchedKey: string; |
|
|
|
|
colorFormatter: (serie: BarSerie) => string; |
|
|
|
|
type ValueX = (number | string); |
|
|
|
|
type ValueY = number; |
|
|
|
|
|
|
|
|
|
export type BarSerieAdditionalParams = { |
|
|
|
|
datapoints: [ValueX, ...ValueY[]]; // [x, y, y, y, ..., y], multiple y values as stacked bars
|
|
|
|
|
annotation?: { |
|
|
|
|
color: string; |
|
|
|
|
size: { |
|
|
|
|
max?: number; // type always SizeType.PX
|
|
|
|
|
min?: number; // type always SizeType.PX
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
export type BarSerie = Serie & Partial<BarSerieParams>; |
|
|
|
|
export type BarAdditionalOptions = { |
|
|
|
|
renderBarLabels?: boolean; |
|
|
|
|
stacked?: boolean; |
|
|
|
|
barWidth?: number; // width in x axis unit
|
|
|
|
|
maxBarWidth?: number; // in px
|
|
|
|
|
minBarWidth?: number; // in px
|
|
|
|
|
maxAnnotationSize?: number; // in px TODO: move to annotaions
|
|
|
|
|
minAnnotationSize?: number; // in px
|
|
|
|
|
matching?: boolean; |
|
|
|
|
opacityFormatter?: (data: RowValues) => number; |
|
|
|
|
annotations?: { |
|
|
|
|
key: string, // matchedKey from series
|
|
|
|
|
// TODO: add enum with "triangle" option
|
|
|
|
|
color: string, |
|
|
|
|
}[]; |
|
|
|
|
colorFormatter?: (data: any) => string; |
|
|
|
|
} |
|
|
|
|
export type BarSerie = Serie & BarSerieAdditionalParams; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export type BarAdditionalOptions = { |
|
|
|
|
group: { // for more than 1 serie and discrete.enable == true
|
|
|
|
|
by: { x: ValueX[] }; // union bars as one group, see examples/demo-group-by.html
|
|
|
|
|
size: number; // type always SizeType.PERCENT
|
|
|
|
|
}; |
|
|
|
|
discrete: { |
|
|
|
|
enable: boolean; // if false -> render bars as time chart | group will not work, see examples/demo-non-discrete.html
|
|
|
|
|
barWidth: { |
|
|
|
|
estimated?: { value: number, type?: SizeType }; |
|
|
|
|
max?: number; // type always SizeType.PX
|
|
|
|
|
min?: number; // type always SizeType.PX
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
eventsCallbacks?: { |
|
|
|
|
contextMenu?: (data: any) => void; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
export type BarOptions = Options & Partial<BarAdditionalOptions>; |
|
|
|
|
export type RowValues = { |
|
|
|
@ -32,3 +43,9 @@ export type RowValues = {
|
|
|
|
|
colors: (string | ((data: any) => string))[], |
|
|
|
|
serieTarget: string[], |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export enum SizeType { |
|
|
|
|
UNIT = 'unit', // in units of X or Y values
|
|
|
|
|
PX = 'px', |
|
|
|
|
PERCENT = 'percent', // from 0 to 100
|
|
|
|
|
} |
|
|
|
|