Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/04-line.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ const lineChart = new chartXkcd.Line(svg, {
- `fontFamily`: customize font family used in the chart
- `unxkcdify`: disable xkcd effect (default `false`)
- `strokeColor`: stroke colors (default `black`)
- `backgroundColor`: color for BG (default `white`)
- `backgroundColor`: color for BG (default `white`)
- `heightRatio`: change the aspect ratio of the chart (default `3` results in 4/3 ratio)
1 change: 1 addition & 0 deletions docs/05-XY.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ You can also plot XY line chart by connecting the points.
- `unxkcdify`: disable xkcd effect (default `false`)
- `strokeColor`: stroke colors (default `black`)
- `backgroundColor`: color for BG (default `white`)
- `heightRatio`: change the aspect ratio of the chart (default `3` results in 4/3 ratio)

**Another example of XY chart: XY line chart with `timeFormat`**

Expand Down
3 changes: 2 additions & 1 deletion docs/06-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ const barChart = new chartXkcd.Bar(svg, {
- `fontFamily`: customize font family used in the chart
- `unxkcdify`: disable xkcd effect (default `false`)
- `strokeColor`: stroke colors (default `black`)
- `backgroundColor`: color for BG (default `white`)
- `backgroundColor`: color for BG (default `white`)
- `heightRatio`: change the aspect ratio of the chart (default `3` results in 4/3 ratio)
3 changes: 2 additions & 1 deletion docs/07-stacked-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ new chartXkcd.StackedBar(svg, {
- up left: `chartXkcd.config.positionType.upLeft`
- up right: `chartXkcd.config.positionType.upLeft`
- bottom left: `chartXkcd.config.positionType.downLeft`
- bottom right: `chartXkcd.config.positionType.downRight`
- bottom right: `chartXkcd.config.positionType.downRight`
- `heightRatio`: change the aspect ratio of the chart (default `3` results in 4/3 ratio)
3 changes: 2 additions & 1 deletion docs/08-pie.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ const pieChart = new chartXkcd.Pie(svg, {
- `fontFamily`: customize font family used in the chart
- `unxkcdify`: disable xkcd effect (default `false`)
- `strokeColor`: stroke colors (default `black`)
- `backgroundColor`: color for BG (default `white`)
- `backgroundColor`: color for BG (default `white`)
- `heightRatio`: change the aspect ratio of the chart (default `3` results in 4/3 ratio)
3 changes: 2 additions & 1 deletion docs/09-radar.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ const radar = new chartXkcd.Radar(svg, {
- `fontFamily`: customize font family used in the chart
- `unxkcdify`: disable xkcd effect (default `false`)
- `strokeColor`: stroke colors (default `black`)
- `backgroundColor`: color for BG (default `white`)
- `backgroundColor`: color for BG (default `white`)
- `heightRatio`: change the aspect ratio of the chart (default `3` results in 4/3 ratio)
1 change: 1 addition & 0 deletions examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ new chartXkcd.Line(svgLine, {
}],
},
options: {
// heightRatio: 3,
// unxkcdify: true,
// strokeColor: 'black',
// backgroundColor: 'white',
Expand Down
3 changes: 2 additions & 1 deletion src/Bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Bar {
fontFamily: 'xkcd',
strokeColor: 'black',
backgroundColor: 'white',
heightRatio: 3,
...options,
};
if (title) {
Expand Down Expand Up @@ -56,7 +57,7 @@ class Bar {
.style('font-family', this.fontFamily)
.style('background', this.options.backgroundColor)
.attr('width', svg.parentElement.clientWidth)
.attr('height', Math.min((svg.parentElement.clientWidth * 2) / 3, window.innerHeight));
.attr('height', Math.min((svg.parentElement.clientWidth * 2) / this.options.heightRatio, window.innerHeight));

this.svgEl.selectAll('*').remove();

Expand Down
3 changes: 2 additions & 1 deletion src/Line.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Line {
strokeColor: 'black',
backgroundColor: 'white',
showLegend: true,
heightRatio: 3,
...options,
};
if (title) {
Expand Down Expand Up @@ -61,7 +62,7 @@ class Line {
.style('font-family', this.fontFamily)
.style('background', this.options.backgroundColor)
.attr('width', svg.parentElement.clientWidth)
.attr('height', Math.min((svg.parentElement.clientWidth * 2) / 3, window.innerHeight));
.attr('height', Math.min((svg.parentElement.clientWidth * 2) / this.options.heightRatio, window.innerHeight));
this.svgEl.selectAll('*').remove();

this.chart = this.svgEl.append('g')
Expand Down
3 changes: 2 additions & 1 deletion src/Pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Pie {
strokeColor: 'black',
backgroundColor: 'white',
showLegend: true,
heightRatio: 3,
...options,
};
this.title = title;
Expand All @@ -44,7 +45,7 @@ class Pie {
.style('font-family', this.fontFamily)
.style('background', this.options.backgroundColor)
.attr('width', svg.parentElement.clientWidth)
.attr('height', Math.min((svg.parentElement.clientWidth * 2) / 3, window.innerHeight));
.attr('height', Math.min((svg.parentElement.clientWidth * 2) / this.options.heightRatio, window.innerHeight));
this.svgEl.selectAll('*').remove();

this.width = this.svgEl.attr('width');
Expand Down
3 changes: 2 additions & 1 deletion src/Radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Radar {
dotSize: 1,
strokeColor: 'black',
backgroundColor: 'white',
heightRatio: 3,
...options,
};
this.title = title;
Expand All @@ -50,7 +51,7 @@ class Radar {
.style('font-family', this.fontFamily)
.style('background', this.options.backgroundColor)
.attr('width', svg.parentElement.clientWidth)
.attr('height', Math.min((svg.parentElement.clientWidth * 2) / 3, window.innerHeight));
.attr('height', Math.min((svg.parentElement.clientWidth * 2) / this.options.heightRatio, window.innerHeight));
this.svgEl.selectAll('*').remove();

this.width = this.svgEl.attr('width');
Expand Down
3 changes: 2 additions & 1 deletion src/StackedBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class StackedBar {
backgroundColor: 'white',
legendPosition: config.positionType.upLeft,
showLegend: true,
heightRatio: 3,
...options,
};
if (title) {
Expand Down Expand Up @@ -59,7 +60,7 @@ class StackedBar {
.style('font-family', this.fontFamily)
.style('background', this.options.backgroundColor)
.attr('width', svg.parentElement.clientWidth)
.attr('height', Math.min((svg.parentElement.clientWidth * 2) / 3, window.innerHeight));
.attr('height', Math.min((svg.parentElement.clientWidth * 2) / this.options.heightRatio, window.innerHeight));

this.svgEl.selectAll('*').remove();

Expand Down
3 changes: 2 additions & 1 deletion src/XY.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class XY {
strokeColor: 'black',
backgroundColor: 'white',
showLegend: true,
heightRatio: 3,
...options,
};
// TODO: extract a function?
Expand Down Expand Up @@ -66,7 +67,7 @@ class XY {
.style('font-family', this.fontFamily)
.style('background', this.options.backgroundColor)
.attr('width', svg.parentElement.clientWidth)
.attr('height', Math.min((svg.parentElement.clientWidth * 2) / 3, window.innerHeight));
.attr('height', Math.min((svg.parentElement.clientWidth * 2) / this.options.heightRatio, window.innerHeight));
this.svgEl.selectAll('*').remove();

this.chart = this.svgEl.append('g')
Expand Down