-
Notifications
You must be signed in to change notification settings - Fork 649
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: xuying.xu <[email protected]>
- Loading branch information
1 parent
d6801f4
commit 80b827e
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters