mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41: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 {rollups} from "../../../utils/functionUtils.js";
|
||||||
import {stack} from "https://cdn.skypack.dev/d3-shape@3";
|
|
||||||
|
|
||||||
const entitiesMap = {
|
const entitiesMap = {
|
||||||
states: {
|
states: {
|
||||||
|
|
@ -434,16 +433,17 @@ function createStackedBarChart(data, {sorting, colors, tooltip, offset, formatX}
|
||||||
const height = yDomain.size * 25 + margin.top + margin.bottom;
|
const height = yDomain.size * 25 + margin.top + margin.bottom;
|
||||||
const yRange = [height - margin.bottom, margin.top];
|
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()
|
const series = d3
|
||||||
.keys(zDomain)
|
.stack()
|
||||||
.value(([, I], z) => X[I.get(z)])
|
.keys(groups)
|
||||||
|
.value(([, I], z) => X[new Map(I).get(z)])
|
||||||
.order(d3.stackOrderNone)
|
.order(d3.stackOrderNone)
|
||||||
.offset(offset)(rolled)
|
.offset(offset)(rolled)
|
||||||
.map(s => {
|
.map(s => {
|
||||||
const defined = s.filter(d => !isNaN(d[1]));
|
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};
|
return {key: s.key, data};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,5 @@
|
||||||
function identity(x) {
|
// extracted d3 code to bypass version conflicts
|
||||||
return x;
|
// https://github.com/d3/d3-array/blob/main/src/group.js
|
||||||
}
|
|
||||||
|
|
||||||
export function group(values, ...keys) {
|
|
||||||
return nest(values, identity, identity, keys);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function rollup(values, reduce, ...keys) {
|
|
||||||
return nest(values, identity, reduce, keys);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function rollups(values, reduce, ...keys) {
|
export function rollups(values, reduce, ...keys) {
|
||||||
return nest(values, Array.from, reduce, keys);
|
return nest(values, Array.from, reduce, keys);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue