Skip to content

Commit

Permalink
fix: 自定义marker (#2021)
Browse files Browse the repository at this point in the history
Co-authored-by: 兵人 <[email protected]>
  • Loading branch information
tangying1027 and 兵人 authored Nov 22, 2024
1 parent d5ecb2e commit a91f1b1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/f2/src/components/legend/legendView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default (props) => {
data-item={item}
onClick={onClick}
>
{Marker({ color: filtered ? '#bfbfbf' : color, type: marker })}
{Marker({ color: filtered ? '#bfbfbf' : color, type: item?.marker || marker })}
{/* <Marker color={filtered ? '#bfbfbf' : color} type={marker} /> */}
<text
attrs={{
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions packages/f2/test/components/legend/legend.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,49 @@ describe('图例', () => {
await delay(1000);
expect(context).toMatchImageSnapshot();
});


it('自定义 items Marker', async () => {
const context = createContext('自定义 items Marker', {
height: '70px',
});
const { props } = (
<Canvas context={context} pixelRatio={1}>
<Chart data={data}>
<Legend
style={{
justifyContent: 'flex-start',
}}
marker="line"
items={[
{
color: 'blue',
name: 'Sports',
value: 0.1,
marker: 'square'
},
{
color: 'red',
name: 'Strategy',
value: 0.2,
},
{
color: 'red',
name: 'Action',
value: 0.3,
},
]}
/>
<Geometry x="genre" y="sold" color="genre" />
</Chart>
</Canvas>
);
const canvas = new Canvas(props);
await canvas.render();

await delay(1000);
expect(context).toMatchImageSnapshot();
});
});

describe('点击交互', () => {
Expand Down

0 comments on commit a91f1b1

Please sign in to comment.