Skip to content

Commit

Permalink
patterns work
Browse files Browse the repository at this point in the history
  • Loading branch information
xsalonx committed Oct 12, 2024
1 parent 8759e27 commit 38870ea
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const renderDatasetAsBars = (
barPropertiesProvider,
configuration,
) => {
const { fill, stroke } = configuration;
const { fill, stroke, pattern } = configuration;

Check failure on line 37 in lib/public/components/common/chart/rendering/dataset/renderDatasetAsBars.js

View workflow job for this annotation

GitHub Actions / linter

'pattern' is assigned a value but never used

Check warning on line 37 in lib/public/components/common/chart/rendering/dataset/renderDatasetAsBars.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/chart/rendering/dataset/renderDatasetAsBars.js#L37

Added line #L37 was not covered by tests

/**
* Get bar fill
Expand All @@ -52,15 +52,53 @@ export const renderDatasetAsBars = (

const { getWidth, getHeight, getX, getY } = barPropertiesProvider;

Check warning on line 53 in lib/public/components/common/chart/rendering/dataset/renderDatasetAsBars.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/chart/rendering/dataset/renderDatasetAsBars.js#L53

Added line #L53 was not covered by tests

// // Define the pattern in the <defs> section
const defs = select(svg).append('defs');
defs.append('pattern')

Check warning on line 57 in lib/public/components/common/chart/rendering/dataset/renderDatasetAsBars.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/chart/rendering/dataset/renderDatasetAsBars.js#L56-L57

Added lines #L56 - L57 were not covered by tests
.attr('id', 'diagonalStripes') // Give the pattern an ID
.attr('width', 10) // Width of the pattern
.attr('height', 10) // Height of the pattern
.attr('patternUnits', 'userSpaceOnUse') // Makes the pattern scalable
.append('path') // Define the pattern content
.attr('d', 'M 0,10 L 10,0') // Diagonal stripe
.attr('stroke', 'red')
.attr('stroke-width', 2);

// select(svg)

Check failure on line 67 in lib/public/components/common/chart/rendering/dataset/renderDatasetAsBars.js

View workflow job for this annotation

GitHub Actions / linter

Comments should not begin with a lowercase character

Check failure on line 67 in lib/public/components/common/chart/rendering/dataset/renderDatasetAsBars.js

View workflow job for this annotation

GitHub Actions / linter

Expected a block comment instead of consecutive line comments
// .append('g')
// .selectAll('rect')
// .data(bars)
// .join('rect')
// .attr('width', getWidth)
// .attr('height', getHeight)
// .attr('x', getX)
// .attr('y', getY)
// .attr('fill', getFill)
// .attr('stroke', getStroke);

select(svg)
.append('g')
.selectAll('rect')
.data(bars)
.join('rect')
.attr('width', getWidth)
.attr('height', getHeight)
.attr('x', getX)
.attr('y', getY)
.attr('fill', getFill)
.attr('stroke', getStroke);
.enter()
.append('g')
.each(function (d) {
select(this).append('rect')

Check warning on line 86 in lib/public/components/common/chart/rendering/dataset/renderDatasetAsBars.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/chart/rendering/dataset/renderDatasetAsBars.js#L85-L86

Added lines #L85 - L86 were not covered by tests
.attr('width', getWidth)
.attr('height', getHeight)
.attr('x', getX)
.attr('y', getY)
.attr('fill', getFill)
.attr('stroke', getStroke);

if (d.pattern) {
select(this).append('rect')

Check warning on line 95 in lib/public/components/common/chart/rendering/dataset/renderDatasetAsBars.js

View check run for this annotation

Codecov / codecov/patch

lib/public/components/common/chart/rendering/dataset/renderDatasetAsBars.js#L94-L95

Added lines #L94 - L95 were not covered by tests
.attr('width', getWidth)
.attr('height', getHeight)
.attr('x', getX)
.attr('y', getY)
.attr('fill', 'url(#diagonalStripes)')
.attr('stroke', 'none');
}
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@

/**
* @typedef BarPropertiesProvider
* @type {VisualPropertiesProvider}
* @property {BarToProperty} getX function to extract the horizontal coordinate of a given bar
* @property {BarToProperty} getY function to extract the vertical coordinate of a given bar
* @property {BarToProperty} getLength function to extract the length (size along dependent variable axis) of a given bar
* @property {BarToProperty} getWidth function to extract the width (size along independent variable axis) of a given bar
* @property {BarToProperty} getLength function to extract the length (size along y-axis) of a given bar
* @property {BarToProperty} getWidth function to extract the width (size along x-axis) of a given bar
*/

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const qcFlagsChartComponent = (flags, run) => barChartComponent(
y: `${flag.flagType.name} (id:${flag.id})`,
x: [flag.from, flag.to],
fill: flag.flagType.color,
pattern: 'diagonalStripes',
})),
{
placeholder: 'No data',
Expand Down

0 comments on commit 38870ea

Please sign in to comment.