Skip to content

Commit

Permalink
chore: 增加官网polylineGuide例子
Browse files Browse the repository at this point in the history
  • Loading branch information
xuying.xu committed Nov 20, 2024
1 parent cb5c2df commit 1ba1725
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions site/.dumirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,5 @@ export default defineConfig({
'https://polyfill.alicdn.com/v3/polyfill.js?features=Intl.RelativeTimeFormat,Intl.RelativeTimeFormat.~locale.en',
],
legacy: {},
mako: {},
});
57 changes: 57 additions & 0 deletions site/examples/component/guide/demo/linestep.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/** @jsx jsx */
import { Canvas, Chart, Interval, jsx, PolylineGuide } from '@antv/f2';

const context = document.getElementById('container').getContext('2d');

const data = [
{ genre: 'Sports', sold: 275, type: 'a' },
{ genre: 'Strategy', sold: 115, type: 'a' },
{ genre: 'Action', sold: 120, type: 'a' },
{ genre: 'Shooter', sold: 350, type: 'a' },
{ genre: 'Other', sold: 150, type: 'a' },
];

const goal = [
{ genre: 'min', sold: 225 },
{ genre: 'Sports', sold: 225 },
{ genre: 'Strategy', sold: 85 },
{ genre: 'Action', sold: 100 },
{ genre: 'Shooter', sold: 250 },
{ genre: 'Other', sold: 120 },
{ genre: 'max', sold: 120 },
];

const { props } = (
<Canvas context={context} pixelRatio={window.devicePixelRatio}>
<Chart data={data}>
<Interval x="genre" y="sold" color="#FA8416" />
<PolylineGuide
records={[
{ genre: 'min', sold: 0 },
...goal,
{
genre: 'max',
sold: 0,
},
]}
style={{
step: 'middle',
fill: 'rgba(255,253,251,0.6)',
}}
/>
<PolylineGuide
records={goal}
style={{
step: 'middle',
fill: 'none',
stroke: 'rgba(250,132,22,0.8)',
lineDash: ['5px', '5px'],
lineWidth: '2px',
}}
/>
</Chart>
</Canvas>
);

const chart = new Canvas(props);
chart.render();
5 changes: 5 additions & 0 deletions site/examples/component/guide/demo/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
"title": "lottie标注",
"screenshot": "https://mdn.alipayobjects.com/huamei_khb4xj/afts/img/A*T8H2SICWEy0AAAAAAAAAAAAADq2NAQ/original"
},
{
"filename": "linestep.jsx",
"title": "Polyline标注",
"screenshot": "https://gw.alipayobjects.com/zos/finxbff/compress-tinypng/Db3kGGhW89ADbLVyjW6Tz/7DEB9227_1F17_4254_8B81_629805F52B98.png"
},
{
"filename": "custom.jsx",
"title": "自定义",
Expand Down

0 comments on commit 1ba1725

Please # to comment.