Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new chart xychart #4413

Merged
merged 54 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
14e290b
Added base structure for xychart
subhash-halder May 20, 2023
93697b7
Generated the base architecture
subhash-halder Jun 8, 2023
183bc0a
Rendered axis with basic line chart
subhash-halder Jun 10, 2023
cc1d6af
Added axis tick and plot border
subhash-halder Jun 10, 2023
547a22e
Added support for bar plot
subhash-halder Jun 14, 2023
0a731e1
Added support for horizontal drawing
subhash-halder Jun 22, 2023
29ab2de
Now jison can parse xAxis and yAxis
subhash-halder Jul 1, 2023
d69a8ae
Added full jison for bar and line chart
subhash-halder Jul 1, 2023
1d98ead
Added support for Diagram title
subhash-halder Jul 2, 2023
ebd3291
Able to draw till axis from chart configuration
subhash-halder Jul 2, 2023
597f7a8
Rendering the chart with all the property from chart config
subhash-halder Jul 3, 2023
553be98
Improved space management for text
subhash-halder Jul 4, 2023
355263a
Fixed some issue related to rendering and space management
subhash-halder Jul 4, 2023
89cfa17
Fixed some merge related issue and eslint issue
subhash-halder Jul 4, 2023
1c84974
Fixed prettier issues
subhash-halder Jul 4, 2023
958f63e
Improved parsing to work for minimal configuration possible.
subhash-halder Jul 5, 2023
da1f46a
Blank commit as commit is not reflecting in the main repo
subhash-halder Jul 5, 2023
5fd4ca2
added updated lock file
subhash-halder Jul 19, 2023
c38cdcf
Introduced theme config to configure cosmetics
subhash-halder Jul 19, 2023
6e98759
Improve plot color selection
subhash-halder Jul 21, 2023
6c2faf0
Simplified the jison file
subhash-halder Aug 6, 2023
526de36
Updated code to use latest config system
subhash-halder Aug 13, 2023
6c2bd33
Addressed all requested changes
subhash-halder Aug 20, 2023
5a64cec
Merge branch 'develop' into feature/4269_add_xychart
subhash-halder Aug 20, 2023
2b4c2e4
Fixed lint and used selectSvgElement
subhash-halder Aug 20, 2023
54f2c63
Addressed all the new comment on jison
subhash-halder Sep 1, 2023
b2669aa
Fixed some space management issue
subhash-halder Sep 1, 2023
7bdf4c3
Added themes config to all the themes
subhash-halder Sep 2, 2023
f9a9173
Small minor changes
subhash-halder Sep 2, 2023
f57b527
Merge branch 'develop' into feature/4269_add_xychart
subhash-halder Sep 2, 2023
de2aa9d
Fixed lint issue
subhash-halder Sep 2, 2023
e0418eb
Made the axis title optional
subhash-halder Sep 2, 2023
fc9ff6c
Added documentations
subhash-halder Sep 2, 2023
060d961
Fixed directive related issue
subhash-halder Sep 2, 2023
cc5190c
Fix some space management issue
subhash-halder Sep 3, 2023
c3a9bb9
Fixed more edge cases
subhash-halder Sep 3, 2023
a344eb4
Added cypress test cases
subhash-halder Sep 3, 2023
7c7d588
Fixed all review comment
subhash-halder Sep 7, 2023
9558cb9
Merge branch 'develop' into feature/4269_add_xychart
subhash-halder Sep 7, 2023
fae648c
Added the file name changes
subhash-halder Sep 7, 2023
b98217e
Fix YAML themeVariables config
subhash-halder Sep 7, 2023
6e9eeb7
removed string concat to string builder
subhash-halder Sep 9, 2023
adb3cd1
Merge branch 'develop' into feature/4269_add_xychart
subhash-halder Sep 14, 2023
e061489
Added review changes
subhash-halder Sep 19, 2023
e56effa
Merge branch 'develop' into feature/4269_add_xychart
subhash-halder Sep 19, 2023
f01f2df
Fix formatting in doc file
subhash-halder Sep 19, 2023
f56796c
Fix a review request in the docs
subhash-halder Sep 20, 2023
8b04c2c
Merge branch 'develop' into feature/4269_add_xychart
subhash-halder Sep 29, 2023
0d348b7
Updated code review changes
subhash-halder Sep 29, 2023
42f8990
Changed requested by code review
subhash-halder Oct 2, 2023
0d64d8d
Merge branch 'develop' into feature/4269_add_xychart
subhash-halder Oct 2, 2023
7f9dfa1
Update docs
subhash-halder Oct 2, 2023
3a0ce43
Merge branch 'develop' into feature/4269_add_xychart
nirname Oct 5, 2023
936319b
Merge branch 'develop' into feature/4269_add_xychart
nirname Oct 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .vite/jsonSchemaPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const MERMAID_CONFIG_DIAGRAM_KEYS = [
'er',
'pie',
'quadrantChart',
'xyChart',
'requirement',
'mindmap',
'timeline',
Expand Down
1 change: 1 addition & 0 deletions cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
"vitepress",
"vueuse",
"xlink",
"xychart",
"yash",
"yokozuna",
"zenuml",
Expand Down
322 changes: 322 additions & 0 deletions cypress/integration/rendering/xyChart.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,322 @@
import { imgSnapshotTest, renderGraph } from '../../helpers/util.ts';

describe('XY Chart', () => {
it('should render the simplest possible chart', () => {
imgSnapshotTest(
`
xychart-beta
nirname marked this conversation as resolved.
Show resolved Hide resolved
line [10, 30, 20]
`,
{}
);
cy.get('svg');
});
it('Should render a complete chart', () => {
imgSnapshotTest(
`
xychart-beta
title "Sales Revene"
nirname marked this conversation as resolved.
Show resolved Hide resolved
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
y-axis "Revenue (in $)" 4000 --> 11000
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
`,
{}
);
});
it('Should render a chart without title', () => {
imgSnapshotTest(
`
xychart-beta
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
y-axis "Revenue (in $)" 4000 --> 11000
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
`,
{}
);
cy.get('svg');
});
it('y-axis title not required', () => {
imgSnapshotTest(
`
xychart-beta
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
y-axis 4000 --> 11000
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
`,
{}
);
cy.get('svg');
});
it('Should render a chart without y-axis with different range', () => {
imgSnapshotTest(
`
xychart-beta
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
bar [5000, 6000, 7500, 8200, 9500, 10500, 14000, 3200, 9200, 9900, 3400, 6000]
line [2000, 7000, 6500, 9200, 9500, 7500, 11000, 10200, 3200, 8500, 7000, 8800]
`,
{}
);
cy.get('svg');
});
it('x axis title not required', () => {
imgSnapshotTest(
`
xychart-beta
x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
bar [5000, 6000, 7500, 8200, 9500, 10500, 14000, 3200, 9200, 9900, 3400, 6000]
line [2000, 7000, 6500, 9200, 9500, 7500, 11000, 10200, 3200, 8500, 7000, 8800]
`,
{}
);
cy.get('svg');
});
it('Multiple plots can be rendered', () => {
imgSnapshotTest(
`
xychart-beta
line [23, 46, 77, 34]
line [45, 32, 33, 12]
bar [87, 54, 99, 85]
line [78, 88, 22, 4]
line [22, 29, 75, 33]
bar [52, 96, 35, 10]
`,
{}
);
cy.get('svg');
});
it('Decimals and -ve no are supported', () => {
nirname marked this conversation as resolved.
Show resolved Hide resolved
imgSnapshotTest(
`
xychart-beta
y-axis -2.4 --> 3.5
line [+1.3, .6, 2.4, -.34]
`,
{}
);
cy.get('svg');
});
it('Render spark line with "plotReservedSpacePercent"', () => {
imgSnapshotTest(
`
---
config:
theme: dark
xyChart:
width: 200
height: 20
plotReservedSpacePercent: 100
---
nirname marked this conversation as resolved.
Show resolved Hide resolved
xychart-beta
line [5000, 9000, 7500, 6200, 9500, 5500, 11000, 8200, 9200, 9500, 7000, 8800]
`,
{}
);
cy.get('svg');
});
it('Render spark bar without displaying other property', () => {
imgSnapshotTest(
`
---
config:
theme: dark
xyChart:
width: 200
height: 20
xAxis:
showLabel: false
showTitle: false
showTick: false
showAxisLine: false
yAxis:
showLabel: false
showTitle: false
showTick: false
showAxisLine: false
---
xychart-beta
bar [5000, 9000, 7500, 6200, 9500, 5500, 11000, 8200, 9200, 9500, 7000, 8800]
`,
{}
);
cy.get('svg');
});
it('Should use all the config from directive', () => {
imgSnapshotTest(
`
%%{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
title "Sales Revene"
nirname marked this conversation as resolved.
Show resolved Hide resolved
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
y-axis "Revenue (in $)" 4000 --> 11000
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
`,
{}
);
cy.get('svg');
});
it('Should use all the config from yaml', () => {
imgSnapshotTest(
`
---
config:
theme: forest
xyChart:
width: 1000
height: 600
titlePadding: 5
titleFontSize: 10
xAxis:
labelFontSize: 20
labelPadding: 10
titleFontSize: 30
titlePadding: 20
tickLength: 10
tickWidth: 5
axisLineWidth: 5
yAxis:
labelFontSize: 20
labelPadding: 10
titleFontSize: 30
titlePadding: 20
tickLength: 10
tickWidth: 5
axisLineWidth: 5
chartOrientation: horizontal
plotReservedSpacePercent: 60
---
xychart-beta
title "Sales Revene"
nirname marked this conversation as resolved.
Show resolved Hide resolved
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
y-axis "Revenue (in $)" 4000 --> 11000
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
`,
{}
);
cy.get('svg');
});
it('Render with show axis title false', () => {
imgSnapshotTest(
`
---
config:
xyChart:
xAxis:
showTitle: false
yAxis:
showTitle: false
---
xychart-beta
title "Sales Revene"
nirname marked this conversation as resolved.
Show resolved Hide resolved
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
y-axis "Revenue (in $)" 4000 --> 11000
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
`,
{}
);
cy.get('svg');
});
it('Render with show axis label false', () => {
imgSnapshotTest(
`
---
config:
xyChart:
xAxis:
showLabel: false
yAxis:
showLabel: false
---
xychart-beta
title "Sales Revene"
nirname marked this conversation as resolved.
Show resolved Hide resolved
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
y-axis "Revenue (in $)" 4000 --> 11000
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
`,
{}
);
cy.get('svg');
});
it('Render with show axis tick false', () => {
imgSnapshotTest(
`
---
config:
xyChart:
xAxis:
showTick: false
yAxis:
showTick: false
---
xychart-beta
title "Sales Revene"
nirname marked this conversation as resolved.
Show resolved Hide resolved
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
y-axis "Revenue (in $)" 4000 --> 11000
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
`,
{}
);
cy.get('svg');
});
it('Render with show axis line false', () => {
imgSnapshotTest(
`
---
config:
xyChart:
xAxis:
showAxisLine: false
yAxis:
showAxisLine: false
---
xychart-beta
title "Sales Revene"
nirname marked this conversation as resolved.
Show resolved Hide resolved
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
y-axis "Revenue (in $)" 4000 --> 11000
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
`,
{}
);
cy.get('svg');
});
it('Render all the theme color', () => {
imgSnapshotTest(
`
---
config:
themeVariables:
xyChart:
titleColor: "#ff0000"
backgroundColor: "#f0f8ff"
yAxisLabelColor: "#ee82ee"
yAxisTitleColor: "#7fffd4"
yAxisTickColor: "#87ceeb"
yAxisLineColor: "#ff6347"
xAxisLabelColor: "#7fffd4"
xAxisTitleColor: "#ee82ee"
xAxisTickColor: "#ff6347"
xAxisLineColor: "#87ceeb"
plotColorPalette: "#008000, #faba63"
---
xychart-beta
title "Sales Revene"
nirname marked this conversation as resolved.
Show resolved Hide resolved
x-axis Months [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
y-axis "Revenue (in $)" 4000 --> 11000
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
`,
{}
);
cy.get('svg');
});
});
3 changes: 3 additions & 0 deletions demos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ <h2><a href="./pie.html">Pie</a></h2>
<li>
<h2><a href="./quadrantchart.html">Quadrant charts</a></h2>
</li>
<li>
<h2><a href="./xychart.html">XY charts</a></h2>
</li>
<li>
<h2><a href="./requirements.html">Requirements</a></h2>
</li>
Expand Down