Chartwerk Bar Pod
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

51 lines
1.6 KiB

import { Serie, Options } from '@chartwerk/core';
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
}
}
opacityFormatter?: (data: RowValues) => number;
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 = {
key: number,
values: number[],
additionalValues: (null | number)[], // values in datapoints third column
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
}