Skip to content

Commit

Permalink
fix: sync changes from v2 to v2-develop (#700)
Browse files Browse the repository at this point in the history
Co-authored-by: mguellsegarra <5711443+mguellsegarra@users.noreply.github.com>
  • Loading branch information
giscegit and mguellsegarra authored Nov 20, 2024
1 parent de342ee commit 2e5a2d7
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ on:
- alpha
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false

jobs:
release:
if: '!contains(github.event.head_commit.message, ''[skip ci]'')'
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gisce/react-ooui",
"version": "2.36.1",
"version": "2.36.2",
"engines": {
"node": "20.5.0"
},
Expand Down
51 changes: 34 additions & 17 deletions src/widgets/views/Graph/GraphChartComp.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import { memo, useCallback, useMemo } from "react";
import { Line, Column, Pie } from "@ant-design/plots";
import GraphDefaults, {
PieLabelOptions,
calculateAdjustedPiePercentages,
} from "./GraphDefaults";
import { Typography } from "antd";
import { useLocale } from "@gisce/react-formiga-components";
import { useCallback, useMemo } from "react";
import { GraphType, YAxisOpts } from "@gisce/ooui";

const { Text } = Typography;

const DEFAULT_HEIGHT = 400;

// Memoize each chart type
const MemoizedLine = memo(Line);
const MemoizedColumn = memo(Column);
const MemoizedPie = memo(Pie);

const types = {
line: Line,
bar: Column,
pie: Pie,
line: MemoizedLine,
bar: MemoizedColumn,
pie: MemoizedPie,
};

export type GraphCompProps = {
Expand Down Expand Up @@ -97,6 +102,30 @@ export const GraphChartComp = ({

const Chart = (types as any)[type!];

const graphProps = useMemo(() => {
return getGraphProps({
type,
data,
isGroup,
numItems,
isStack,
pieItemValueFormatter,
pieLabelFormatter,
yAxisOpts,
fixedHeight,
});
}, [
type,
data,
isGroup,
numItems,
isStack,
pieItemValueFormatter,
pieLabelFormatter,
yAxisOpts,
fixedHeight,
]);

if (!Chart) {
return <>{`Unknown graph type: ${type}`}</>;
}
Expand Down Expand Up @@ -129,19 +158,7 @@ export const GraphChartComp = ({
</div>
)}
<div style={{ width: "100%", height: "100%", overflow: "hidden" }}>
<Chart
{...getGraphProps({
type,
data,
isGroup,
numItems,
isStack,
pieItemValueFormatter,
pieLabelFormatter,
yAxisOpts,
fixedHeight,
})}
/>
<Chart {...graphProps} />
</div>
</div>
);
Expand Down

0 comments on commit 2e5a2d7

Please sign in to comment.