Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
radubrehar committed May 16, 2024
1 parent 5ff4769 commit dd3a41d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions www/content/docs/learn/examples/using-sparklines.page.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ For this demo, we're using the [`react-sparklines`](https://www.npmjs.com/packag

The most important part is the <PropLink name="columns.renderValue" /> property, which allows you to render a custom React component for the cell value.

```tsx {11-23} title="Using column.renderValue to render a sparkline"
```tsx {11-26} title="Using column.renderValue to render a sparkline"
const columns = {
// ... other columns
id: {
Expand All @@ -18,7 +18,11 @@ const columns = {
field: 'bugFixes',
header: 'Bug Fixes',
defaultWidth: 300,
renderValue: ({ value }) => {
renderValue: ({ value, data }) => {
const color =
data?.department === 'IT' || data?.department === 'Management'
? 'tomato'
: '#253e56';
return (
<Sparklines
data={value}
Expand All @@ -27,7 +31,7 @@ const columns = {
}}
height={30}
>
<SparklinesLine color="#253e56" />
<SparklinesLine color={color} />
</Sparklines>
);
},
Expand Down

0 comments on commit dd3a41d

Please sign in to comment.