Christoph Cullmann 2024-04-28 17:33:09 +02:00
parent 4b35583782
commit e77051ccc4
1987 changed files with 1147290 additions and 5648 deletions

View file

@ -0,0 +1,12 @@
import type { TextDimensionCalculator } from '../../textDimensionCalculator.js';
import { BaseAxis } from './baseAxis.js';
import type { XYChartAxisThemeConfig, XYChartAxisConfig } from '../../interfaces.js';
export declare class BandAxis extends BaseAxis {
private scale;
private categories;
constructor(axisConfig: XYChartAxisConfig, axisThemeConfig: XYChartAxisThemeConfig, categories: string[], title: string, textDimensionCalculator: TextDimensionCalculator);
setRange(range: [number, number]): void;
recalculateScale(): void;
getTickValues(): (string | number)[];
getScaleValue(value: string): number;
}

View file

@ -0,0 +1,38 @@
import type { BoundingRect, Dimension, DrawableElem, Point, XYChartAxisConfig, XYChartAxisThemeConfig } from '../../interfaces.js';
import type { TextDimensionCalculator } from '../../textDimensionCalculator.js';
import type { Axis, AxisPosition } from './index.js';
export declare abstract class BaseAxis implements Axis {
protected axisConfig: XYChartAxisConfig;
protected title: string;
protected textDimensionCalculator: TextDimensionCalculator;
protected axisThemeConfig: XYChartAxisThemeConfig;
protected boundingRect: BoundingRect;
protected axisPosition: AxisPosition;
private range;
protected showTitle: boolean;
protected showLabel: boolean;
protected showTick: boolean;
protected showAxisLine: boolean;
protected outerPadding: number;
protected titleTextHeight: number;
protected labelTextHeight: number;
constructor(axisConfig: XYChartAxisConfig, title: string, textDimensionCalculator: TextDimensionCalculator, axisThemeConfig: XYChartAxisThemeConfig);
setRange(range: [number, number]): void;
getRange(): [number, number];
setAxisPosition(axisPosition: AxisPosition): void;
abstract getScaleValue(value: number | string): number;
abstract recalculateScale(): void;
abstract getTickValues(): Array<string | number>;
getTickDistance(): number;
getAxisOuterPadding(): number;
private getLabelDimension;
recalculateOuterPaddingToDrawBar(): void;
private calculateSpaceIfDrawnHorizontally;
private calculateSpaceIfDrawnVertical;
calculateSpace(availableSpace: Dimension): Dimension;
setBoundingBoxXY(point: Point): void;
private getDrawableElementsForLeftAxis;
private getDrawableElementsForBottomAxis;
private getDrawableElementsForTopAxis;
getDrawableElements(): DrawableElem[];
}

View file

@ -0,0 +1,12 @@
import type { Group } from '../../../../../diagram-api/types.js';
import type { AxisDataType, ChartComponent, XYChartAxisConfig, XYChartAxisThemeConfig } from '../../interfaces.js';
export type AxisPosition = 'left' | 'right' | 'top' | 'bottom';
export interface Axis extends ChartComponent {
getScaleValue(value: string | number): number;
setAxisPosition(axisPosition: AxisPosition): void;
getAxisOuterPadding(): number;
getTickDistance(): number;
recalculateOuterPaddingToDrawBar(): void;
setRange(range: [number, number]): void;
}
export declare function getAxis(data: AxisDataType, axisConfig: XYChartAxisConfig, axisThemeConfig: XYChartAxisThemeConfig, tmpSVGGroup: Group): Axis;

View file

@ -0,0 +1,11 @@
import type { TextDimensionCalculator } from '../../textDimensionCalculator.js';
import { BaseAxis } from './baseAxis.js';
import type { XYChartAxisThemeConfig, XYChartAxisConfig } from '../../interfaces.js';
export declare class LinearAxis extends BaseAxis {
private scale;
private domain;
constructor(axisConfig: XYChartAxisConfig, axisThemeConfig: XYChartAxisThemeConfig, domain: [number, number], title: string, textDimensionCalculator: TextDimensionCalculator);
getTickValues(): (string | number)[];
recalculateScale(): void;
getScaleValue(value: number): number;
}

View file

@ -0,0 +1,16 @@
import type { Group } from '../../../../diagram-api/types.js';
import type { ChartComponent, Dimension, DrawableElem, Point, XYChartData, XYChartThemeConfig, XYChartConfig } from '../interfaces.js';
import type { TextDimensionCalculator } from '../textDimensionCalculator.js';
export declare class ChartTitle implements ChartComponent {
private textDimensionCalculator;
private chartConfig;
private chartData;
private chartThemeConfig;
private boundingRect;
private showChartTitle;
constructor(textDimensionCalculator: TextDimensionCalculator, chartConfig: XYChartConfig, chartData: XYChartData, chartThemeConfig: XYChartThemeConfig);
setBoundingBoxXY(point: Point): void;
calculateSpace(availableSpace: Dimension): Dimension;
getDrawableElements(): DrawableElem[];
}
export declare function getChartTitleComponent(chartConfig: XYChartConfig, chartData: XYChartData, chartThemeConfig: XYChartThemeConfig, tmpSVGGroup: Group): ChartComponent;

View file

@ -0,0 +1,12 @@
import type { BarPlotData, BoundingRect, DrawableElem, XYChartConfig } from '../../interfaces.js';
import type { Axis } from '../axis/index.js';
export declare class BarPlot {
private barData;
private boundingRect;
private xAxis;
private yAxis;
private orientation;
private plotIndex;
constructor(barData: BarPlotData, boundingRect: BoundingRect, xAxis: Axis, yAxis: Axis, orientation: XYChartConfig['chartOrientation'], plotIndex: number);
getDrawableElement(): DrawableElem[];
}

View file

@ -0,0 +1,20 @@
import type { XYChartData, Dimension, DrawableElem, Point, XYChartThemeConfig, XYChartConfig } from '../../interfaces.js';
import type { Axis } from '../axis/index.js';
import type { ChartComponent } from '../../interfaces.js';
export interface Plot extends ChartComponent {
setAxes(xAxis: Axis, yAxis: Axis): void;
}
export declare class BasePlot implements Plot {
private chartConfig;
private chartData;
private chartThemeConfig;
private boundingRect;
private xAxis?;
private yAxis?;
constructor(chartConfig: XYChartConfig, chartData: XYChartData, chartThemeConfig: XYChartThemeConfig);
setAxes(xAxis: Axis, yAxis: Axis): void;
setBoundingBoxXY(point: Point): void;
calculateSpace(availableSpace: Dimension): Dimension;
getDrawableElements(): DrawableElem[];
}
export declare function getPlotComponent(chartConfig: XYChartConfig, chartData: XYChartData, chartThemeConfig: XYChartThemeConfig): Plot;

View file

@ -0,0 +1,11 @@
import type { DrawableElem, LinePlotData, XYChartConfig } from '../../interfaces.js';
import type { Axis } from '../axis/index.js';
export declare class LinePlot {
private plotData;
private xAxis;
private yAxis;
private orientation;
private plotIndex;
constructor(plotData: LinePlotData, xAxis: Axis, yAxis: Axis, orientation: XYChartConfig['chartOrientation'], plotIndex: number);
getDrawableElement(): DrawableElem[];
}

View file

@ -0,0 +1,5 @@
import type { Group } from '../../../diagram-api/types.js';
import type { DrawableElem, XYChartConfig, XYChartData, XYChartThemeConfig } from './interfaces.js';
export declare class XYChartBuilder {
static build(config: XYChartConfig, chartData: XYChartData, chartThemeConfig: XYChartThemeConfig, tmpSVGGroup: Group): DrawableElem[];
}

View file

@ -0,0 +1,132 @@
export interface XYChartAxisThemeConfig {
titleColor: string;
labelColor: string;
tickColor: string;
axisLineColor: string;
}
export interface XYChartThemeConfig {
backgroundColor: string;
titleColor: string;
xAxisLabelColor: string;
xAxisTitleColor: string;
xAxisTickColor: string;
xAxisLineColor: string;
yAxisLabelColor: string;
yAxisTitleColor: string;
yAxisTickColor: string;
yAxisLineColor: string;
plotColorPalette: string;
}
export interface ChartComponent {
calculateSpace(availableSpace: Dimension): Dimension;
setBoundingBoxXY(point: Point): void;
getDrawableElements(): DrawableElem[];
}
export type SimplePlotDataType = [string, number][];
export interface LinePlotData {
type: 'line';
strokeFill: string;
strokeWidth: number;
data: SimplePlotDataType;
}
export interface BarPlotData {
type: 'bar';
fill: string;
data: SimplePlotDataType;
}
export type PlotData = LinePlotData | BarPlotData;
export declare function isBarPlot(data: PlotData): data is BarPlotData;
export interface BandAxisDataType {
type: 'band';
title: string;
categories: string[];
}
export interface LinearAxisDataType {
type: 'linear';
title: string;
min: number;
max: number;
}
export type AxisDataType = LinearAxisDataType | BandAxisDataType;
export declare function isBandAxisData(data: AxisDataType): data is BandAxisDataType;
export declare function isLinearAxisData(data: AxisDataType): data is LinearAxisDataType;
/**
* For now we are keeping this configs as we are removing the required fields while generating the config.type.ts file
* we should remove `XYChartAxisConfig` and `XYChartConfig` after we started using required fields
*/
export interface XYChartAxisConfig {
showLabel: boolean;
labelFontSize: number;
labelPadding: number;
showTitle: boolean;
titleFontSize: number;
titlePadding: number;
showTick: boolean;
tickLength: number;
tickWidth: number;
showAxisLine: boolean;
axisLineWidth: number;
}
export interface XYChartConfig {
width: number;
height: number;
titleFontSize: number;
titlePadding: number;
showTitle: boolean;
xAxis: XYChartAxisConfig;
yAxis: XYChartAxisConfig;
chartOrientation: 'vertical' | 'horizontal';
plotReservedSpacePercent: number;
}
export interface XYChartData {
xAxis: AxisDataType;
yAxis: AxisDataType;
title: string;
plots: PlotData[];
}
export interface Dimension {
width: number;
height: number;
}
export interface BoundingRect extends Point, Dimension {
}
export interface Point {
x: number;
y: number;
}
export type TextHorizontalPos = 'left' | 'center' | 'right';
export type TextVerticalPos = 'top' | 'middle';
export interface RectElem extends Point {
width: number;
height: number;
fill: string;
strokeWidth: number;
strokeFill: string;
}
export interface TextElem extends Point {
text: string;
fill: string;
verticalPos: TextVerticalPos;
horizontalPos: TextHorizontalPos;
fontSize: number;
rotation: number;
}
export interface PathElem {
path: string;
fill?: string;
strokeWidth: number;
strokeFill: string;
}
export type DrawableElem = {
groupTexts: string[];
type: 'rect';
data: RectElem[];
} | {
groupTexts: string[];
type: 'text';
data: TextElem[];
} | {
groupTexts: string[];
type: 'path';
data: PathElem[];
};

View file

@ -0,0 +1,12 @@
import type { DrawableElem, XYChartConfig, XYChartData, XYChartThemeConfig } from './interfaces.js';
import type { Group } from '../../../diagram-api/types.js';
export declare class Orchestrator {
private chartConfig;
private chartData;
private componentStore;
constructor(chartConfig: XYChartConfig, chartData: XYChartData, chartThemeConfig: XYChartThemeConfig, tmpSVGGroup: Group);
private calculateVerticalSpace;
private calculateHorizontalSpace;
private calculateSpace;
getDrawableElement(): DrawableElem[];
}

View file

@ -0,0 +1,10 @@
import type { Dimension } from './interfaces.js';
import type { Group } from '../../../diagram-api/types.js';
export interface TextDimensionCalculator {
getMaxDimension(texts: string[], fontSize: number): Dimension;
}
export declare class TextDimensionCalculatorWithFont implements TextDimensionCalculator {
private parentGroup;
constructor(parentGroup: Group);
getMaxDimension(texts: string[], fontSize: number): Dimension;
}

View file

@ -0,0 +1 @@
export {};

View file

@ -0,0 +1,40 @@
import type { DrawableElem, XYChartConfig, XYChartThemeConfig } from './chartBuilder/interfaces.js';
import type { Group } from '../../diagram-api/types.js';
interface NormalTextType {
type: 'text';
text: string;
}
declare function setTmpSVGG(SVGG: Group): void;
declare function setOrientation(orientation: string): void;
declare function setXAxisTitle(title: NormalTextType): void;
declare function setXAxisRangeData(min: number, max: number): void;
declare function setXAxisBand(categories: NormalTextType[]): void;
declare function setYAxisTitle(title: NormalTextType): void;
declare function setYAxisRangeData(min: number, max: number): void;
declare function setLineData(title: NormalTextType, data: number[]): void;
declare function setBarData(title: NormalTextType, data: number[]): void;
declare function getDrawableElem(): DrawableElem[];
declare function getChartThemeConfig(): XYChartThemeConfig;
declare function getChartConfig(): XYChartConfig;
declare const _default: {
getDrawableElem: typeof getDrawableElem;
clear: () => void;
setAccTitle: (txt: string) => void;
getAccTitle: () => string;
setDiagramTitle: (txt: string) => void;
getDiagramTitle: () => string;
getAccDescription: () => string;
setAccDescription: (txt: string) => void;
setOrientation: typeof setOrientation;
setXAxisTitle: typeof setXAxisTitle;
setXAxisRangeData: typeof setXAxisRangeData;
setXAxisBand: typeof setXAxisBand;
setYAxisTitle: typeof setYAxisTitle;
setYAxisRangeData: typeof setYAxisRangeData;
setLineData: typeof setLineData;
setBarData: typeof setBarData;
setTmpSVGG: typeof setTmpSVGG;
getChartThemeConfig: typeof getChartThemeConfig;
getChartConfig: typeof getChartConfig;
};
export default _default;

View file

@ -0,0 +1,3 @@
import type { ExternalDiagramDefinition } from '../../diagram-api/types.js';
declare const plugin: ExternalDiagramDefinition;
export default plugin;

View file

@ -0,0 +1,2 @@
import type { DiagramDefinition } from '../../diagram-api/types.js';
export declare const diagram: DiagramDefinition;

View file

@ -0,0 +1,6 @@
import type { Diagram } from '../../Diagram.js';
export declare const draw: (txt: string, id: string, _version: string, diagObj: Diagram) => void;
declare const _default: {
draw: (txt: string, id: string, _version: string, diagObj: Diagram) => void;
};
export default _default;