This is an automated email from the ASF dual-hosted git repository.
ovilia pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/echarts-from-mermaid.git
The following commit(s) were added to refs/heads/main by this push:
new 075ac03 test: xychart
075ac03 is described below
commit 075ac03fd9cc6cfdfe6e4ce209fe9b34d3220e21
Author: Ovilia <[email protected]>
AuthorDate: Wed Mar 19 19:37:49 2025 +0800
test: xychart
---
src/__tests__/xychart.test.ts | 135 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 135 insertions(+)
diff --git a/src/__tests__/xychart.test.ts b/src/__tests__/xychart.test.ts
new file mode 100644
index 0000000..439244d
--- /dev/null
+++ b/src/__tests__/xychart.test.ts
@@ -0,0 +1,135 @@
+import { EChartsFromMermaid } from '../index';
+
+const chartTypes = [
+ 'line',
+ // 'bar'
+];
+
+describe('XYChart', () => {
+ for (const chartType of chartTypes) {
+ describe(chartType, () => {
+ describe('orientation', () => {
+ // it('should render vertical chart', () => {
+ // const definition = `
+ // xychart-beta
+ // ${chartType} [1, 4, 3]
+ // `;
+ // const option = EChartsFromMermaid.getOption(definition);
+ // expect(option).toEqual({
+ // xAxis: {
+ // type: 'value',
+ // },
+ // yAxis: {
+ // type: 'value',
+ // },
+ // series: [
+ // {
+ // type: chartType,
+ // data: [
+ // [1, 1],
+ // [2, 4],
+ // [3, 3],
+ // ],
+ // },
+ // ],
+ // });
+ // });
+ // it('should render horizontal chart', () => {
+ // const definition = `
+ // xychart-beta horizontal
+ // ${chartType} [1, 4, 3]
+ // `;
+ // const option = EChartsFromMermaid.getOption(definition);
+ // expect(option).toEqual({
+ // xAxis: { type: 'value' },
+ // yAxis: { type: 'value' },
+ // series: [
+ // {
+ // type: chartType,
+ // data: [
+ // [1, 1],
+ // [4, 2],
+ // [3, 3],
+ // ],
+ // },
+ // ],
+ // });
+ // });
+ });
+
+ const axisTypes = ['x' /*, 'y'*/];
+ for (const axisType of axisTypes) {
+ describe(axisType, () => {
+ const otherAxis = axisType === 'x' ? 'y' : 'x';
+ // it(`should render category ${axisType}Axis`, () => {
+ // const definition = `
+ // xychart-beta
+ // ${axisType}-axis [cat1, "cat2 with space", cat3]
+ // ${chartType} [1, 4, 2]
+ // `;
+ // const option = EChartsFromMermaid.getOption(definition);
+ // expect(option).toEqual({
+ // [axisType + 'Axis']: {
+ // type: 'category',
+ // data: ['cat1', 'cat2 with space', 'cat3'],
+ // },
+ // [otherAxis + 'Axis']: { type: 'value' },
+ // series: [
+ // {
+ // type: chartType,
+ // data: [1, 4, 2],
+ // },
+ // ],
+ // });
+ // });
+
+ it(`should render value ${axisType}Axis with range`, () => {
+ const definition = `
+ xychart-beta
+ ${axisType}-axis 100 --> 200
+ ${chartType} [1, 4, 2]
+ `;
+ const option = EChartsFromMermaid.getOption(definition);
+ expect(option).toEqual({
+ [axisType + 'Axis']: { type: 'value', min: 100, max: 200 },
+ [otherAxis + 'Axis']: { type: 'value' },
+ series: [
+ {
+ type: chartType,
+ data: [
+ [100, 1],
+ [150, 4],
+ [200, 2],
+ ],
+ },
+ ],
+ });
+ });
+
+ // it(`should work with ${axisType}Axis title`, () => {
+ // const definition = `
+ // xychart-beta
+ // ${axisType}-axis "Cats" [cat1, "cat2 with space", cat3]
+ // ${chartType} [1, 4, 2]
+ // `;
+ // const option = EChartsFromMermaid.getOption(definition);
+ // expect(option).toEqual({
+ // [axisType + 'Axis']: {
+ // type: 'category',
+ // name: 'Cats',
+ // value: ['cat1', 'cat2 with space', 'cat3'],
+ // },
+ // [otherAxis + 'Axis']: { type: 'value' },
+ // series: [
+ // {
+ // type: chartType,
+ // data: [1, 4, 2],
+ // },
+ // ],
+ // });
+ // });
+ });
+ }
+ });
+ }
+});
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]