mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-09 18:39:41 +02:00
Added review changes
This commit is contained in:
@@ -15,7 +15,7 @@ describe('XY Chart', () => {
|
|||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
xychart-beta
|
xychart-beta
|
||||||
title "Sales Revene"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
||||||
@@ -89,7 +89,7 @@ describe('XY Chart', () => {
|
|||||||
);
|
);
|
||||||
cy.get('svg');
|
cy.get('svg');
|
||||||
});
|
});
|
||||||
it('Decimals and -ve no are supported', () => {
|
it('Decimals and negative numbers are supported', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`
|
`
|
||||||
xychart-beta
|
xychart-beta
|
||||||
@@ -150,7 +150,7 @@ config:
|
|||||||
`
|
`
|
||||||
%%{init: {"xyChart": {"width": 1000, "height": 600, "titlePadding": 5, "titleFontSize": 10, "xAxis": {"labelFontSize": "20", "labelPadding": 10, "titleFontSize": 30, "titlePadding": 20, "tickLength": 10, "tickWidth": 5}, "yAxis": {"labelFontSize": "20", "labelPadding": 10, "titleFontSize": 30, "titlePadding": 20, "tickLength": 10, "tickWidth": 5}, "plotBorderWidth": 5, "chartOrientation": "horizontal", "plotReservedSpacePercent": 60 }}}%%
|
%%{init: {"xyChart": {"width": 1000, "height": 600, "titlePadding": 5, "titleFontSize": 10, "xAxis": {"labelFontSize": "20", "labelPadding": 10, "titleFontSize": 30, "titlePadding": 20, "tickLength": 10, "tickWidth": 5}, "yAxis": {"labelFontSize": "20", "labelPadding": 10, "titleFontSize": 30, "titlePadding": 20, "tickLength": 10, "tickWidth": 5}, "plotBorderWidth": 5, "chartOrientation": "horizontal", "plotReservedSpacePercent": 60 }}}%%
|
||||||
xychart-beta
|
xychart-beta
|
||||||
title "Sales Revene"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
||||||
@@ -191,7 +191,7 @@ config:
|
|||||||
plotReservedSpacePercent: 60
|
plotReservedSpacePercent: 60
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart-beta
|
||||||
title "Sales Revene"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
||||||
@@ -213,7 +213,7 @@ config:
|
|||||||
showTitle: false
|
showTitle: false
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart-beta
|
||||||
title "Sales Revene"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
||||||
@@ -235,7 +235,7 @@ config:
|
|||||||
showLabel: false
|
showLabel: false
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart-beta
|
||||||
title "Sales Revene"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
||||||
@@ -257,7 +257,7 @@ config:
|
|||||||
showTick: false
|
showTick: false
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart-beta
|
||||||
title "Sales Revene"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
||||||
@@ -279,7 +279,7 @@ config:
|
|||||||
showAxisLine: false
|
showAxisLine: false
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart-beta
|
||||||
title "Sales Revene"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
||||||
@@ -309,7 +309,7 @@ config:
|
|||||||
plotColorPalette: "#008000, #faba63"
|
plotColorPalette: "#008000, #faba63"
|
||||||
---
|
---
|
||||||
xychart-beta
|
xychart-beta
|
||||||
title "Sales Revene"
|
title "Sales Revenue"
|
||||||
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
|
||||||
y-axis "Revenue (in $)" 4000 --> 11000
|
y-axis "Revenue (in $)" 4000 --> 11000
|
||||||
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
|
||||||
|
@@ -33,7 +33,7 @@ xychart-beta
|
|||||||
## Syntax
|
## Syntax
|
||||||
|
|
||||||
> **Note**
|
> **Note**
|
||||||
> all text values can be single word without ", if multiple line required we have to use ".
|
> All text values that contain only one word can be written without `"`. If a text value has many words in it, specifically if it contains spaces, enclose the value in `"`
|
||||||
|
|
||||||
### Orientations
|
### Orientations
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ The title is a short description of the chart and it will always render on top o
|
|||||||
#### Example
|
#### Example
|
||||||
|
|
||||||
xychart-beta
|
xychart-beta
|
||||||
title "This is a sample example"
|
title "This is a simple example"
|
||||||
...
|
...
|
||||||
|
|
||||||
> **Note**
|
> **Note**
|
||||||
|
@@ -51,6 +51,7 @@ export abstract class BaseAxis implements Axis {
|
|||||||
|
|
||||||
setAxisPosition(axisPosition: AxisPosition): void {
|
setAxisPosition(axisPosition: AxisPosition): void {
|
||||||
this.axisPosition = axisPosition;
|
this.axisPosition = axisPosition;
|
||||||
|
this.setRange(this.range);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract getScaleValue(value: number | string): number;
|
abstract getScaleValue(value: number | string): number;
|
||||||
@@ -174,7 +175,7 @@ export abstract class BaseAxis implements Axis {
|
|||||||
this.boundingRect.y = point.y;
|
this.boundingRect.y = point.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getDrawaableElementsForLeftAxis(): DrawableElem[] {
|
private getDrawableElementsForLeftAxis(): DrawableElem[] {
|
||||||
const drawableElement: DrawableElem[] = [];
|
const drawableElement: DrawableElem[] = [];
|
||||||
if (this.showAxisLine) {
|
if (this.showAxisLine) {
|
||||||
const x = this.boundingRect.x + this.boundingRect.width - this.axisConfig.axisLineWidth / 2;
|
const x = this.boundingRect.x + this.boundingRect.width - this.axisConfig.axisLineWidth / 2;
|
||||||
@@ -250,7 +251,7 @@ export abstract class BaseAxis implements Axis {
|
|||||||
}
|
}
|
||||||
return drawableElement;
|
return drawableElement;
|
||||||
}
|
}
|
||||||
private getDrawaableElementsForBottomAxis(): DrawableElem[] {
|
private getDrawableElementsForBottomAxis(): DrawableElem[] {
|
||||||
const drawableElement: DrawableElem[] = [];
|
const drawableElement: DrawableElem[] = [];
|
||||||
if (this.showAxisLine) {
|
if (this.showAxisLine) {
|
||||||
const y = this.boundingRect.y + this.axisConfig.axisLineWidth / 2;
|
const y = this.boundingRect.y + this.axisConfig.axisLineWidth / 2;
|
||||||
@@ -326,7 +327,7 @@ export abstract class BaseAxis implements Axis {
|
|||||||
}
|
}
|
||||||
return drawableElement;
|
return drawableElement;
|
||||||
}
|
}
|
||||||
private getDrawaableElementsForTopAxis(): DrawableElem[] {
|
private getDrawableElementsForTopAxis(): DrawableElem[] {
|
||||||
const drawableElement: DrawableElem[] = [];
|
const drawableElement: DrawableElem[] = [];
|
||||||
if (this.showAxisLine) {
|
if (this.showAxisLine) {
|
||||||
const y = this.boundingRect.y + this.boundingRect.height - this.axisConfig.axisLineWidth / 2;
|
const y = this.boundingRect.y + this.boundingRect.height - this.axisConfig.axisLineWidth / 2;
|
||||||
@@ -405,16 +406,16 @@ export abstract class BaseAxis implements Axis {
|
|||||||
|
|
||||||
getDrawableElements(): DrawableElem[] {
|
getDrawableElements(): DrawableElem[] {
|
||||||
if (this.axisPosition === 'left') {
|
if (this.axisPosition === 'left') {
|
||||||
return this.getDrawaableElementsForLeftAxis();
|
return this.getDrawableElementsForLeftAxis();
|
||||||
}
|
}
|
||||||
if (this.axisPosition === 'right') {
|
if (this.axisPosition === 'right') {
|
||||||
throw Error('Drawing of right axis is not implemented');
|
throw Error('Drawing of right axis is not implemented');
|
||||||
}
|
}
|
||||||
if (this.axisPosition === 'bottom') {
|
if (this.axisPosition === 'bottom') {
|
||||||
return this.getDrawaableElementsForBottomAxis();
|
return this.getDrawableElementsForBottomAxis();
|
||||||
}
|
}
|
||||||
if (this.axisPosition === 'top') {
|
if (this.axisPosition === 'top') {
|
||||||
return this.getDrawaableElementsForTopAxis();
|
return this.getDrawableElementsForTopAxis();
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,7 @@ let tmpSVGGElem: SVGGType;
|
|||||||
|
|
||||||
let xyChartConfig: XYChartConfig = getChartDefaultConfig();
|
let xyChartConfig: XYChartConfig = getChartDefaultConfig();
|
||||||
let xyChartThemeConfig: XYChartThemeConfig = getChartDefaultThemeConfig();
|
let xyChartThemeConfig: XYChartThemeConfig = getChartDefaultThemeConfig();
|
||||||
let xyChartData: XYChartData = getChartDefalutData();
|
let xyChartData: XYChartData = getChartDefaultData();
|
||||||
let plotColorPalette = xyChartThemeConfig.plotColorPalette.split(',').map((color) => color.trim());
|
let plotColorPalette = xyChartThemeConfig.plotColorPalette.split(',').map((color) => color.trim());
|
||||||
let hasSetXAxis = false;
|
let hasSetXAxis = false;
|
||||||
let hasSetYAxis = false;
|
let hasSetYAxis = false;
|
||||||
@@ -54,7 +54,7 @@ function getChartDefaultConfig(): XYChartConfig {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getChartDefalutData(): XYChartData {
|
function getChartDefaultData(): XYChartData {
|
||||||
return {
|
return {
|
||||||
yAxis: {
|
yAxis: {
|
||||||
type: 'linear',
|
type: 'linear',
|
||||||
@@ -201,7 +201,7 @@ const clear = function () {
|
|||||||
commonClear();
|
commonClear();
|
||||||
plotIndex = 0;
|
plotIndex = 0;
|
||||||
xyChartConfig = getChartDefaultConfig();
|
xyChartConfig = getChartDefaultConfig();
|
||||||
xyChartData = getChartDefalutData();
|
xyChartData = getChartDefaultData();
|
||||||
xyChartThemeConfig = getChartDefaultThemeConfig();
|
xyChartThemeConfig = getChartDefaultThemeConfig();
|
||||||
plotColorPalette = xyChartThemeConfig.plotColorPalette.split(',').map((color) => color.trim());
|
plotColorPalette = xyChartThemeConfig.plotColorPalette.split(',').map((color) => color.trim());
|
||||||
hasSetXAxis = false;
|
hasSetXAxis = false;
|
||||||
|
@@ -18,7 +18,7 @@ xychart-beta
|
|||||||
## Syntax
|
## Syntax
|
||||||
|
|
||||||
```note
|
```note
|
||||||
all text values can be single word without ", if multiple line required we have to use ".
|
All text values that contain only one word can be written without `"`. If a text value has many words in it, specifically if it contains spaces, enclose the value in `"`
|
||||||
```
|
```
|
||||||
|
|
||||||
### Orientations
|
### Orientations
|
||||||
@@ -38,7 +38,7 @@ The title is a short description of the chart and it will always render on top o
|
|||||||
|
|
||||||
```
|
```
|
||||||
xychart-beta
|
xychart-beta
|
||||||
title "This is a sample example"
|
title "This is a simple example"
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user