Skip to content

Commit

Permalink
Merge pull request #638 from neo4j-labs/feature/pieFontSize
Browse files Browse the repository at this point in the history
Pie font size
  • Loading branch information
AleSim94 authored Sep 25, 2023
2 parents 187a99e + 2111a27 commit 735f37d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/modules/ROOT/pages/user-guide/reports/pie-chart.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ the pie slices in order of size.
|Show Values in Slices |on/off |off |If enabled, show the category
values inside the pie slices.

|Labels font Size |Number |13 |Define the size of the font for internal and external labels on the pie.

|Show categories next to Slices |on/off |off |If enabled, show the
category values next to the pie slices.

Expand Down
10 changes: 9 additions & 1 deletion src/chart/pie/PieChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ChartProps } from '../Chart';
import { convertRecordObjectToString, recordToNative } from '../ChartUtils';
import { themeNivo } from '../Utils';
import { extensionEnabled } from '../../utils/ReportUtils';
import { objMerge } from '../../utils/ObjectManipulation';

/**
* Embeds a PieChart (from Nivo) into NeoDash.
Expand Down Expand Up @@ -90,6 +91,8 @@ const NeoPieChart = (props: ChartProps) => {
const cornerRadius = settings.cornerRadius ? settings.cornerRadius : 1;
const arcLabelsSkipAngle = settings.arcLabelsSkipAngle ? settings.arcLabelsSkipAngle : 10;

const arcLabelsFontSize = settings.arcLabelsFontSize ? settings.arcLabelsFontSize : 13;

const legend = settings.legend ? settings.legend : false;
const colorScheme = settings.colors ? settings.colors : 'set2';
const styleRules = useStyleRules(
Expand Down Expand Up @@ -131,9 +134,14 @@ const NeoPieChart = (props: ChartProps) => {
return <NoDrawableDataErrorMessage />;
}

const theme = objMerge(themeNivo, {
labels: {
text: { fontSize: arcLabelsFontSize },
},
});
return (
<ResponsivePie
theme={themeNivo}
theme={theme}
data={data}
sortByValue={sortByValue}
enableArcLabels={enableArcLabels}
Expand Down
5 changes: 5 additions & 0 deletions src/config/ReportConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,11 @@ const _REPORT_TYPES = {
type: SELECTION_TYPES.NUMBER,
default: 10,
},
arcLabelsFontSize: {
label: 'Labels font Size',
type: SELECTION_TYPES.NUMBER,
default: 13,
},
enableArcLinkLabels: {
label: 'Show categories next to slices',
type: SELECTION_TYPES.LIST,
Expand Down

0 comments on commit 735f37d

Please sign in to comment.