From 59584ea6515f324c67aa653b11a00156041e35e0 Mon Sep 17 00:00:00 2001 From: Jack Tregurtha Date: Fri, 13 Dec 2024 10:36:22 -0500 Subject: [PATCH] Allow simultaneous display of segment and stop labels --- src/core/config/index.js | 4 ++++ src/core/render/index.js | 4 +++- src/index.d.ts | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/core/config/index.js b/src/core/config/index.js index dd25d98..b1a93e8 100644 --- a/src/core/config/index.js +++ b/src/core/config/index.js @@ -32,6 +32,8 @@ export const DEFAULT_PROPS = { // custom segment labels customSegmentLabels: [], + // show custom segment labels and stops + showStopsAndCustomSegmentLabels: false, // color strings needleColor: 'steelblue', @@ -116,6 +118,8 @@ export const getConfig = ({ PROPS, parentWidth, parentHeight }) => { // custom segment labels customSegmentLabels: PROPS.customSegmentLabels, + // show custom segment labels and stops + showStopsAndCustomSegmentLabels: PROPS.showStopsAndCustomSegmentLabels, // max segment labels maxSegmentLabels: calculateSegmentLabelCount({ diff --git a/src/core/render/index.js b/src/core/render/index.js index 4947e51..040d2fc 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -141,7 +141,9 @@ export function _renderLabels({ config, svg, centerTx, r }) { range, }) // do not proceed - return + if (!config.showStopsAndCustomSegmentLabels) { + return + } } // normal label rendering diff --git a/src/index.d.ts b/src/index.d.ts index 7d3b6ec..0854c5e 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -81,6 +81,7 @@ declare module 'react-d3-speedometer' { customSegmentStops?: number[] customSegmentLabels?: CustomSegmentLabel[] + showStopsAndCustomSegmentLabels?: boolean labelFontSize?: string valueTextFontSize?: string