|
|
|
@ -72,8 +72,9 @@ export class ChartwerkBarPod extends ChartwerkPod<BarTimeSerie, BarOptions> {
|
|
|
|
|
if(_.isEmpty(this.options.annotations)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
// find all series for single matchedKey
|
|
|
|
|
const series = _.filter(this.series, serie => _.includes(d.serieTarget, serie.target)); |
|
|
|
|
const matchedKeys = _.map(series, serie => serie.matchedKey); |
|
|
|
|
const matchedKeys = _.map(series, serie => serie.matchedKey); // here matchedKeys should be equal
|
|
|
|
|
const key = matchedKeys[0]; |
|
|
|
|
|
|
|
|
|
const lastRect = _.last(container.selectAll('rect')?.nodes()); |
|
|
|
@ -83,16 +84,22 @@ export class ChartwerkBarPod extends ChartwerkPod<BarTimeSerie, BarOptions> {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const rectSelection = d3.select(lastRect); |
|
|
|
|
// render triangle
|
|
|
|
|
container.append('path') |
|
|
|
|
.attr('d', () => { |
|
|
|
|
const x = Math.ceil(_.toNumber(rectSelection.attr('x'))); |
|
|
|
|
const y = Math.max(Math.ceil(_.toNumber(rectSelection.attr('y'))) - this.barWidth, 0); |
|
|
|
|
return `M ${x} ${y} L ${x + this.barWidth } ${y} L ${x + this.barWidth / 2} ${ y + this.barWidth / 2} z`; |
|
|
|
|
return this.getTrianglePath(x, y, this.barWidth); |
|
|
|
|
}) |
|
|
|
|
.attr('fill', annotation.color); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getTrianglePath(x: number, y: number, length: number): string { |
|
|
|
|
// (x, y) - top left corner
|
|
|
|
|
return `M ${x - 2} ${y - 2} L ${x + length + 2} ${y - 2} L ${x + length / 2 } ${y + length - 2} z`; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getBarOpacity(rowValues: RowValues): number { |
|
|
|
|
if(this.options.opacityFormatter === undefined) { |
|
|
|
|
return 1; |
|
|
|
|