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

Wrapped customSegmentLabels texts #139

Open
ThomasGil92 opened this issue Feb 17, 2022 · 1 comment
Open

Wrapped customSegmentLabels texts #139

ThomasGil92 opened this issue Feb 17, 2022 · 1 comment

Comments

@ThomasGil92
Copy link

Is there a way to wrap texts in array for "long" strings?image

I found "custom-react-d3-speedometer" but not compatible with react 17

Thanks for your great module by the way

@palerdot
Copy link
Owner

palerdot commented Feb 18, 2022

Is there a way to wrap texts in array for "long" strings?

I don't see a reliable way to achieve this as the segment size can be very small and it could be very difficult to even display small length text.

You can try customSegmentLabels and control the position of the label (INSIDE/OUTSIDE). Something like

<ReactSpeedometer
        width={400}
        height={400}
        paddingHorizontal={50}
        value={777}
        currentValueText="Happiness Level"
        customSegmentLabels={[
          {
            text: "Very Bad",
            position: "INSIDE",
            color: "#555"
          },
          {
            text: "Bad",
            position: "INSIDE",
            color: "#555"
          },
          {
            text: "Ok",
            position: "INSIDE",
            color: "#555",
            fontSize: "19px"
          },
          {
            text: "Good",
            position: "INSIDE",
            color: "#555"
          },
          {
            text: "Very Good and a long text",
            position: "OUTSIDE",
            color: "#555"
          }
        ]}
      />

Codesandbox reference: https://codesandbox.io/s/busy-hamilton-u9kmyc?file=/src/App.js

Live example - https://palerdot.in/react-d3-speedometer/?path=/story/reactspeedometer--custom-segment-labels

Also, I'm open to some better solution/PR for this issue.

@palerdot palerdot changed the title wrapped customSegmentLabels texts Wrapped customSegmentLabels texts Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants