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

Multicolor Line Graph Line #79

Open
beeboopx opened this issue Jun 16, 2023 · 2 comments
Open

Multicolor Line Graph Line #79

beeboopx opened this issue Jun 16, 2023 · 2 comments
Labels
feature-request New feature requested by the community

Comments

@beeboopx
Copy link

How might i go about creating a multicolor line with this library? Like this:

Screenshot 2023-06-16 at 3 40 26 AM

Thanks

@Montchy Montchy added the feature-request New feature requested by the community label Aug 14, 2023
@Lexical-Luke
Copy link

+1

@mikewheaton
Copy link

mikewheaton commented Jan 5, 2024

Looks like the line's gradient is set on AnimatedLineGraph.tsx:282 with an array of 5 colors:

  const gradientColors = useMemo(() => {
    if (enableFadeInMask) {
      return [
        `${getSixDigitHex(color)}00`,
        `${getSixDigitHex(color)}ff`,
        `${getSixDigitHex(color)}ff`,
        `${getSixDigitHex(color)}33`,
        `${getSixDigitHex(color)}33`,
      ]
    }
    return [
      color,
      color,
      color,
      `${getSixDigitHex(color)}33`,
      `${getSixDigitHex(color)}33`,
    ]
  }, [color, enableFadeInMask])

It appears that first 3 colors define a gradient for before the selection point (when enablePanGesture is true), and the last 2 colors are the gradient of the line after the selection point.

For example, if we change the array to:

    return [
      'red',
      'yellow',
      'red',
      'blue',
      'black',
    ]

We get this result (note that I've changed the default dot to a line):

Jan-05-2024 14-48-04

I have a related request to this, where I'd like to prevent it from using a gradient at all, so the line remains the same color regardless of the pan state:

image

I'm brand new to this library and not sure if this has come up before (I searched the issues but didn't see anything else) so am not sure exactly how this would best be implemented. But I'd be happy to make a PR if we can land on a plan first that's likely to be accepted. It seems like we need another prop for lineFillColors (similar to gradientFillColors) to provide more control over this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature requested by the community
Projects
None yet
Development

No branches or pull requests

4 participants