Skip to content

Commit

Permalink
Merge branch 'main' into feature/vertical_bar_chart
Browse files Browse the repository at this point in the history
  • Loading branch information
koechkevin committed Aug 6, 2024
2 parents 6fdcb3d + 07435b0 commit 4147a7c
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 272 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Scope } from "@hurumap/core";

import MultiLineChartScope from "./MultiLineChartScope";
import StackedChartScope from "./StackedChartScope";
import TreemapChartScope from "./TreemapChartScope";
import VerticalStackedChartScope from "./VerticalStackedChartScope";

import { hurumapArgs } from "@/climatemappedafrica/config";
Expand All @@ -12,6 +11,7 @@ const {
BarChartScope,
LineChartScope,
DonutChartScope,
TreemapChartScope,
VerticalBarChartScope,
} = Scope;

Expand Down Expand Up @@ -78,7 +78,7 @@ export default function configureScope(
vegaSpec = DonutChartScope(scopeOptions);
break;
case "treemap":
vegaSpec = TreemapChartScope(..._scopeOptions);
vegaSpec = TreemapChartScope(scopeOptions);
break;
case "stacked":
if (isMobile) {
Expand Down
4 changes: 2 additions & 2 deletions apps/pesayetu/src/components/HURUmap/Chart/configureScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Scope } from "@hurumap/core";

import MultiLineChartScope from "./MultiLineChartScope";
import StackedChartScope from "./StackedChartScope";
import TreemapChartScope from "./TreemapChartScope";
import VerticalStackedChartScope from "./VerticalStackedChartScope";

import { hurumapArgs } from "@/pesayetu/config";
Expand All @@ -12,6 +11,7 @@ const {
BarChartScope,
LineChartScope,
DonutChartScope,
TreemapChartScope,
VerticalBarChartScope,
} = Scope;

Expand Down Expand Up @@ -78,7 +78,7 @@ export default function configureScope(
vegaSpec = DonutChartScope(scopeOptions);
break;
case "treemap":
vegaSpec = TreemapChartScope(..._scopeOptions);
vegaSpec = TreemapChartScope(scopeOptions);
break;
case "stacked":
if (isMobile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import merge from "deepmerge";

import Scope from "./Scope";

import theme from "@/pesayetu/theme";

export default function TreemapChartScope(
export default function TreemapChartScope({
primaryData,
metadata,
config,
Expand All @@ -14,39 +12,44 @@ export default function TreemapChartScope(
profileNames,
isCompare,
isMobile,
) {
theme,
args,
}) {
const { primary_group: primaryGroup } = metadata;
const nestedFields = config?.nest_fields ?? [primaryGroup]; // if nest fields are undefined, make use primaryGroup
const transform = [
{
type: "nest",
keys: nestedFields,
},
{
type: "treemap",
field: { signal: "datatype[Units]" },
method: { signal: "layout" },
ratio: { signal: "aspectRatio" },
size: [
{
signal:
"isCompare && data('secondary').length > 1 && !isMobile ? width/2 -30: width",
},
{ signal: "isCompare && isMobile ? height/2 : height" },
],
},
];

return merge(
Scope(
Scope({
primaryData,
metadata,
config,
secondaryData,
primaryParentData,
secondaryParentData,
"treemap",
[
{
type: "nest",
keys: nestedFields,
},
{
type: "treemap",
field: { signal: "datatype[Units]" },
method: { signal: "layout" },
ratio: { signal: "aspectRatio" },
size: [
{
signal:
"isCompare && data('secondary').length > 1 && !isMobile ? width/2 -30: width",
},
{ signal: "isCompare && isMobile ? height/2 : height" },
],
},
],
),
chartType: "treemap",
transform,
theme,
args,
}),
{
height: isMobile && isCompare && secondaryData?.length > 1 ? 760 : 380,
signals: [
Expand Down
2 changes: 2 additions & 0 deletions packages/hurumap-core/src/Scope/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import BarChartScope from "./BarChartScope";
import DonutChartScope from "./DonutChartScope";
import LineChartScope from "./LineChartScope";
import Scope from "./Scope";
import TreemapChartScope from "./TreemapChartScope";
import VerticalBarChartScope from "./VerticalBarChartScope";

export default {
Expand All @@ -10,4 +11,5 @@ export default {
LineChartScope,
DonutChartScope,
VerticalBarChartScope,
TreemapChartScope,
};

0 comments on commit 4147a7c

Please sign in to comment.