Skip to content
This repository has been archived by the owner on Nov 25, 2021. It is now read-only.

Commit

Permalink
Merge pull request #72 from datavisyn/release-2.3.0
Browse files Browse the repository at this point in the history
Release 2.3.0
  • Loading branch information
thinkh authored Feb 28, 2020
2 parents 9a3ee5c + 4b920cc commit 324631c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @dg-datavisyn
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ interface IBaseStyling {
*/
outlierColor: string;

/**
* to fill color below the median line of the box
* @default see rectangle.lowerColor
* @scriptable
* @indexable
*/
lowerColor: string;

/**
* radius used to render items
* @default 0 so disabled
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"name": "chartjs-chart-box-and-violin-plot",
"description": "Chart.js module for charting boxplots",
"version": "2.2.1",
"version": "2.3.0",
"author": {
"name": "datavisyn",
"email": "[email protected]",
"url": "https://www.datavisyn.io"
},
"contributors": [
{
"contributors": [{
"name": "Samuel Gratzl",
"email": "[email protected]",
"url": "https://www.sgratzl.com"
Expand Down
6 changes: 4 additions & 2 deletions samples/vertical.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@
borderColor: window.chartColors.red,
borderWidth: 1,
data: samples.boxplots({count: 7, random: random}),
outlierColor: '#999999'
outlierColor: '#999999',
lowerColor: '#461e7d'
}, {
label: 'Dataset 2',
backgroundColor: color(window.chartColors.blue).alpha(0.5).rgbString(),
borderColor: window.chartColors.blue,
borderWidth: 1,
data: samples.boxplotsArray({count: 7, random: random}),
outlierColor: '#999999'
outlierColor: '#999999',
lowerColor: '#461e7d'
}]

};
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export function toFixed(value) {
return Number.parseFloat(value).toFixed(decimals);
}

const configKeys = ['outlierRadius', 'itemRadius', 'itemStyle', 'itemBackgroundColor', 'itemBorderColor', 'outlierColor', 'medianColor', 'hitPadding', 'outlierHitRadius'];
const configKeyIsColor = [false, false, false, true, true, true, true, false, false];
const configKeys = ['outlierRadius', 'itemRadius', 'itemStyle', 'itemBackgroundColor', 'itemBorderColor', 'outlierColor', 'medianColor', 'hitPadding', 'outlierHitRadius', 'lowerColor'];
const configKeyIsColor = [false, false, false, true, true, true, true, false, false, true];

const array = {
_elementOptions() {
Expand Down
1 change: 1 addition & 0 deletions src/elements/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const defaults = {
borderWidth: 1,
outlierRadius: 2,
outlierColor: Chart.defaults.global.elements.rectangle.backgroundColor,
lowerColor: Chart.defaults.global.elements.rectangle.lowerColor,
medianColor: null,
itemRadius: 0,
itemStyle: 'circle',
Expand Down
11 changes: 11 additions & 0 deletions src/elements/boxandwhiskers.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ const BoxAndWiskers = Chart.elements.BoxAndWhiskers = ArrayElementBase.extend({
ctx.beginPath();
ctx.moveTo(x0, boxplot.median);
ctx.lineTo(x0 + width, boxplot.median);

// fill the part below the median with lowerColor
if (vm.lowerColor) {
ctx.fillStyle = vm.lowerColor;
if (boxplot.q3 > boxplot.q1) {
ctx.fillRect(x0, boxplot.median, width, boxplot.q3 - boxplot.median);
} else {
ctx.fillRect(x0, boxplot.median, width, boxplot.q1 - boxplot.median);
}
}

ctx.closePath();
ctx.stroke();
ctx.restore();
Expand Down

0 comments on commit 324631c

Please sign in to comment.