|
|
@ -59,12 +59,12 @@ export class ChartwerkBarPod extends ChartwerkPod<BarSerie, BarOptions> { |
|
|
|
.data(data) |
|
|
|
.data(data) |
|
|
|
.enter().append('g') |
|
|
|
.enter().append('g') |
|
|
|
.attr('class', 'rects-container') |
|
|
|
.attr('class', 'rects-container') |
|
|
|
.each((d: RowValues, i: number, nodes: any) => { |
|
|
|
.each((d: RowValues, rowIndex: number, nodes: any) => { |
|
|
|
const container = d3.select(nodes[i]); |
|
|
|
const container = d3.select(nodes[rowIndex]); |
|
|
|
container.selectAll('rect') |
|
|
|
container.selectAll('rect') |
|
|
|
.data(d.values) |
|
|
|
.data(d.values) |
|
|
|
.enter().append('rect') |
|
|
|
.enter().append('rect') |
|
|
|
.style('fill', (val, i) => d.colors[i]) |
|
|
|
.style('fill', (val, idx) => this.getBarColor(d, val, idx, rowIndex)) |
|
|
|
.attr('opacity', () => this.getBarOpacity(d)) |
|
|
|
.attr('opacity', () => this.getBarOpacity(d)) |
|
|
|
.attr('x', (val: number, idx: number) => { |
|
|
|
.attr('x', (val: number, idx: number) => { |
|
|
|
return this.getBarPositionX(d.key, idx); |
|
|
|
return this.getBarPositionX(d.key, idx); |
|
|
@ -150,6 +150,13 @@ export class ChartwerkBarPod extends ChartwerkPod<BarSerie, BarOptions> { |
|
|
|
return this.options.barOptions.opacityFormatter(rowValues); |
|
|
|
return this.options.barOptions.opacityFormatter(rowValues); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getBarColor(rowValues: RowValues, val: number, i: number, rowIndex: number): string { |
|
|
|
|
|
|
|
if(_.isFunction(rowValues.colors[i])) { |
|
|
|
|
|
|
|
return (rowValues.colors[i] as Function)({ rowData: rowValues, val, stackedIndex: i, rowIndex }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return (rowValues.colors[i] as string); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
mergeMacthedSeriesAndSort(matchedSeries: any[]) { |
|
|
|
mergeMacthedSeriesAndSort(matchedSeries: any[]) { |
|
|
|
// TODO: refactor
|
|
|
|
// TODO: refactor
|
|
|
|
if(matchedSeries.length === 0) { |
|
|
|
if(matchedSeries.length === 0) { |
|
|
@ -197,7 +204,7 @@ export class ChartwerkBarPod extends ChartwerkPod<BarSerie, BarOptions> { |
|
|
|
const additionalValuesColumns = _.map(series, serie => _.map(serie.datapoints, row => row[2] !== undefined ? row[2] : null)); |
|
|
|
const additionalValuesColumns = _.map(series, serie => _.map(serie.datapoints, row => row[2] !== undefined ? row[2] : null)); |
|
|
|
const zippedAdditionalValuesColumn = _.zip(...additionalValuesColumns); |
|
|
|
const zippedAdditionalValuesColumn = _.zip(...additionalValuesColumns); |
|
|
|
const zippedValuesColumn = _.zip(...valuesColumns); |
|
|
|
const zippedValuesColumn = _.zip(...valuesColumns); |
|
|
|
const colors = _.map(series, serie => serie.color); |
|
|
|
const colors = _.map(series, serie => serie.colorFormatter || serie.color); |
|
|
|
const tagrets = _.map(series, serie => serie.target); |
|
|
|
const tagrets = _.map(series, serie => serie.target); |
|
|
|
const zippedData = _.zip(keysColumn, zippedValuesColumn, zippedAdditionalValuesColumn, tagrets); |
|
|
|
const zippedData = _.zip(keysColumn, zippedValuesColumn, zippedAdditionalValuesColumn, tagrets); |
|
|
|
const data = _.map(zippedData, row => { return { key: row[0], values: row[1], additionalValues: row[2], colors, serieTarget: tagrets } }); |
|
|
|
const data = _.map(zippedData, row => { return { key: row[0], values: row[1], additionalValues: row[2], colors, serieTarget: tagrets } }); |
|
|
|