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

Does this support gradients? #101

Open
j4ysen opened this issue Nov 30, 2017 · 2 comments
Open

Does this support gradients? #101

j4ysen opened this issue Nov 30, 2017 · 2 comments

Comments

@j4ysen
Copy link

j4ysen commented Nov 30, 2017

Can't seem to find examples of gradients in the docs. What would be the easiest way to get gradients?

@levid
Copy link

levid commented May 29, 2018

I was able to add gradients like this:

import React from 'react';
import { Sparklines, SparklinesLine, SparklinesSpots } from 'react-sparklines';

const LinearGradientFill = stopColor => {
	return (
		<linearGradient id="gradient" x1="0%" y1="0%" x2="0%" y2="100%">
			<stop offset="0%" stopColor="rgb(26, 135, 255)" stopOpacity="1" />
			<stop offset="100%" stopColor="rgb(26, 135, 255)" stopOpacity="0" />
		</linearGradient>
	);
};

const CoinSparklineChart = props => (
	<Sparklines data={props.closePrice} height={50}>
		<svg>
			<defs>
				<LinearGradientFill />
			</defs>
		</svg>
		<SparklinesLine
			style={{
				strokeWidth: 1,
				fill: 'url(#gradient)'
			}}
			color="rgb(26, 135, 255)"
		/>
	</Sparklines>
);

export default CoinSparklineChart;

@Finesse
Copy link

Finesse commented Jan 18, 2019

It duplicates #87

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

3 participants