mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-16 17:31:24 +01:00
feat(charts): remove shape additional dependency
This commit is contained in:
parent
5992cea360
commit
eaa0a41f36
2 changed files with 9 additions and 18 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import {rollup, rollups} from "../../../utils/functionUtils.js";
|
||||
import {stack} from "https://cdn.skypack.dev/d3-shape@3";
|
||||
import {rollups} from "../../../utils/functionUtils.js";
|
||||
|
||||
const entitiesMap = {
|
||||
states: {
|
||||
|
|
@ -434,16 +433,17 @@ function createStackedBarChart(data, {sorting, colors, tooltip, offset, formatX}
|
|||
const height = yDomain.size * 25 + margin.top + margin.bottom;
|
||||
const yRange = [height - margin.bottom, margin.top];
|
||||
|
||||
const rolled = rollup(...[I, ([i]) => i, i => Y[i], i => Z[i]]);
|
||||
const rolled = rollups(...[I, ([i]) => i, i => Y[i], i => Z[i]]);
|
||||
|
||||
const series = stack()
|
||||
.keys(zDomain)
|
||||
.value(([, I], z) => X[I.get(z)])
|
||||
const series = d3
|
||||
.stack()
|
||||
.keys(groups)
|
||||
.value(([, I], z) => X[new Map(I).get(z)])
|
||||
.order(d3.stackOrderNone)
|
||||
.offset(offset)(rolled)
|
||||
.map(s => {
|
||||
const defined = s.filter(d => !isNaN(d[1]));
|
||||
const data = defined.map(d => Object.assign(d, {i: d.data[1].get(s.key)}));
|
||||
const data = defined.map(d => Object.assign(d, {i: new Map(d.data[1]).get(s.key)}));
|
||||
return {key: s.key, data};
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,5 @@
|
|||
function identity(x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
export function group(values, ...keys) {
|
||||
return nest(values, identity, identity, keys);
|
||||
}
|
||||
|
||||
export function rollup(values, reduce, ...keys) {
|
||||
return nest(values, identity, reduce, keys);
|
||||
}
|
||||
// extracted d3 code to bypass version conflicts
|
||||
// https://github.com/d3/d3-array/blob/main/src/group.js
|
||||
|
||||
export function rollups(values, reduce, ...keys) {
|
||||
return nest(values, Array.from, reduce, keys);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue