Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pie font size #638

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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