mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
Fixed some merge related issue and eslint issue
This commit is contained in:
parent
355263a4fb
commit
89cfa17b07
@ -82,7 +82,7 @@ export const addDiagrams = () => {
|
||||
state,
|
||||
journey,
|
||||
quadrantChart,
|
||||
sankey
|
||||
sankey,
|
||||
xychart
|
||||
);
|
||||
};
|
||||
|
@ -1,8 +1,3 @@
|
||||
export enum ChartPlotEnum {
|
||||
LINE = 'line',
|
||||
BAR = 'bar',
|
||||
}
|
||||
|
||||
export interface ChartComponent {
|
||||
calculateSpace(availableSpace: Dimension): Dimension;
|
||||
setBoundingBoxXY(point: Point): void;
|
||||
@ -12,14 +7,14 @@ export interface ChartComponent {
|
||||
export type SimplePlotDataType = [string | number, number][];
|
||||
|
||||
export interface LinePlotData {
|
||||
type: ChartPlotEnum.LINE;
|
||||
type: 'line';
|
||||
strokeFill: string,
|
||||
strokeWidth: number,
|
||||
data: SimplePlotDataType;
|
||||
}
|
||||
|
||||
export interface BarPlotData {
|
||||
type: ChartPlotEnum.BAR;
|
||||
type: 'bar'
|
||||
fill: string,
|
||||
data: SimplePlotDataType;
|
||||
}
|
||||
@ -27,7 +22,7 @@ export interface BarPlotData {
|
||||
export type PlotData = LinePlotData | BarPlotData;
|
||||
|
||||
export function isBarPlot(data: PlotData): data is BarPlotData {
|
||||
return data.type === ChartPlotEnum.BAR;
|
||||
return data.type === 'line';
|
||||
}
|
||||
|
||||
export interface BandAxisDataType {
|
||||
|
@ -87,7 +87,7 @@ export class Orchestrator {
|
||||
this.componentStore.xAxis.setBoundingBoxXY({ x: chartX, y: chartY + chartHeight });
|
||||
this.componentStore.yAxis.setRange([chartY, chartY + chartHeight]);
|
||||
this.componentStore.yAxis.setBoundingBoxXY({ x: 0, y: chartY });
|
||||
if(this.chartData.plots.find(p => isBarPlot(p))) {
|
||||
if (this.chartData.plots.some((p) => isBarPlot(p))) {
|
||||
this.componentStore.xAxis.recalculateOuterPaddingToDrawBar();
|
||||
}
|
||||
}
|
||||
@ -159,7 +159,7 @@ export class Orchestrator {
|
||||
this.componentStore.yAxis.setBoundingBoxXY({ x: chartX, y: titleYEnd });
|
||||
this.componentStore.xAxis.setRange([chartY, chartY + chartHeight]);
|
||||
this.componentStore.xAxis.setBoundingBoxXY({ x: 0, y: chartY });
|
||||
if(this.chartData.plots.find(p => isBarPlot(p))) {
|
||||
if (this.chartData.plots.some((p) => isBarPlot(p))) {
|
||||
this.componentStore.xAxis.recalculateOuterPaddingToDrawBar();
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ export interface ITextDimensionCalculator {
|
||||
}
|
||||
|
||||
export class TextDimensionCalculator implements ITextDimensionCalculator {
|
||||
constructor() {}
|
||||
getDimension(texts: string[], fontSize: number): Dimension {
|
||||
return {
|
||||
width: texts.reduce((acc, cur) => Math.max(cur.length, acc), 0) * fontSize,
|
||||
@ -58,7 +57,7 @@ export class TextDimensionCalculatorWithFont implements ITextDimensionCalculator
|
||||
|
||||
this.container.style.fontSize = `${fontSize}px`;
|
||||
|
||||
for (let t of texts) {
|
||||
for (const t of texts) {
|
||||
this.container.innerHTML = t;
|
||||
const bbox = this.container.getBoundingClientRect();
|
||||
dimension.width = Math.max(dimension.width, bbox.width);
|
||||
|
@ -24,9 +24,9 @@ export class LinearAxis extends BaseAxis {
|
||||
}
|
||||
|
||||
recalculateScale(): void {
|
||||
const domain = [...this.domain]; // copy the array so if reverse is called twise it shouldnot cancel the reverse effect
|
||||
const domain = [...this.domain]; // copy the array so if reverse is called two times it should not cancel the reverse effect
|
||||
if (this.axisPosition === 'left') {
|
||||
domain.reverse(); // since yaxis in svg start from top
|
||||
domain.reverse(); // since y-axis in svg start from top
|
||||
}
|
||||
this.scale = scaleLinear().domain(domain).range(this.getRange());
|
||||
log.trace('Linear axis final domain, range: ', this.domain, this.getRange());
|
||||
|
@ -4,7 +4,6 @@ import {
|
||||
BoundingRect,
|
||||
DrawableElem,
|
||||
Point,
|
||||
ChartPlotEnum,
|
||||
} from '../../Interfaces.js';
|
||||
import { IAxis } from '../axis/index.js';
|
||||
import { ChartComponent } from '../../Interfaces.js';
|
||||
@ -60,12 +59,12 @@ export class Plot implements IPlot {
|
||||
];
|
||||
for(const plot of this.chartData.plots) {
|
||||
switch(plot.type) {
|
||||
case ChartPlotEnum.LINE: {
|
||||
case 'line': {
|
||||
const linePlot = new LinePlot(plot, this.xAxis, this.yAxis, this.chartConfig.chartOrientation);
|
||||
drawableElem.push(...linePlot.getDrawableElement())
|
||||
}
|
||||
break;
|
||||
case ChartPlotEnum.BAR: {
|
||||
case 'bar': {
|
||||
const barPlot = new BarPlot(plot, this.boundingRect, this.xAxis, this.yAxis, this.chartConfig.chartOrientation)
|
||||
drawableElem.push(...barPlot.getDrawableElement());
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import {
|
||||
} from '../../commonDb.js';
|
||||
import { XYChartBuilder } from './chartBuilder/index.js';
|
||||
import {
|
||||
ChartPlotEnum,
|
||||
DrawableElem,
|
||||
XYChartData,
|
||||
isBandAxisData,
|
||||
@ -21,9 +20,6 @@ import {
|
||||
import { XYChartConfig } from '../../config.type.js';
|
||||
|
||||
const config = configApi.getConfig();
|
||||
let chartWidth = 600;
|
||||
let chartHeight = 500;
|
||||
|
||||
function getChartDefaultConfig(): XYChartConfig {
|
||||
return config.xyChart
|
||||
? { ...config.xyChart, yAxis: { ...config.xyChart.yAxis }, xAxis: { ...config.xyChart.xAxis } }
|
||||
@ -125,7 +121,7 @@ function setYAxisRangeData(min: number, max: number) {
|
||||
function setLineData(title: string, data: number[]) {
|
||||
if (isBandAxisData(xyChartData.xAxis)) {
|
||||
xyChartData.plots.push({
|
||||
type: ChartPlotEnum.LINE,
|
||||
type: 'line',
|
||||
strokeFill: '#00ff00',
|
||||
strokeWidth: 2,
|
||||
data: xyChartData.xAxis.categories.map((c, i) => [c, data[i]]),
|
||||
@ -135,7 +131,7 @@ function setLineData(title: string, data: number[]) {
|
||||
function setBarData(title: string, data: number[]) {
|
||||
if (isBandAxisData(xyChartData.xAxis)) {
|
||||
xyChartData.plots.push({
|
||||
type: ChartPlotEnum.BAR,
|
||||
type: 'bar',
|
||||
fill: '#0000bb',
|
||||
data: xyChartData.xAxis.categories.map((c, i) => [c, data[i]]),
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { select, Selection } from 'd3';
|
||||
import { select } from 'd3';
|
||||
import { Diagram } from '../../Diagram.js';
|
||||
import * as configApi from '../../config.js';
|
||||
import { log } from '../../logger.js';
|
||||
@ -59,7 +59,7 @@ export const draw = (txt: string, id: string, _version: string, diagObj: Diagram
|
||||
function getGroup(gList: string[]) {
|
||||
let elem = group;
|
||||
let prefix = '';
|
||||
for (let i = 0; i < gList.length; i++) {
|
||||
for (const [i, _] of gList.entries()) {
|
||||
let parent = group;
|
||||
if (i > 0 && groups[prefix]) {
|
||||
parent = groups[prefix];
|
||||
|
939
pnpm-lock.yaml
generated
939
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user