Skip to content

Commit

Permalink
chore: 补充官网阶梯图demo
Browse files Browse the repository at this point in the history
  • Loading branch information
xuying.xu committed Sep 19, 2024
1 parent e0ccc98 commit d86ee8c
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
6 changes: 6 additions & 0 deletions site/.dumi/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../tsconfig.json",
"include": [
"**/*"
]
}
5 changes: 5 additions & 0 deletions site/examples/line/line/demo/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
"title": "曲线",
"screenshot": "https://gw.alipayobjects.com/mdn/rms_4f0ff1/afts/img/A*LU4qRJrOSQkAAAAAAAAAAABkARQnAQ"
},
{
"filename": "step.jsx",
"title": "阶梯",
"screenshot": "https://gw.alipayobjects.com/zos/finxbff/compress-tinypng/nnBatWjRpi6HtWmjwdPd4/line_test_tsx_zhexiantu_jichuzhexiantu_jietitu_1_snap.png"
},
{
"filename": "pan.jsx",
"title": "折线图平移",
Expand Down
70 changes: 70 additions & 0 deletions site/examples/line/line/demo/step.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { Axis, Canvas, Chart, Line } from '@antv/f2';

const data = [];

[
{
time: '2016-08-01',
tem: 15,
type: 'start',
},
{
time: '2016-08-02',
tem: 22,
type: 'start',
},
{
time: '2016-08-03',
tem: 15,
type: 'start',
},
{
time: '2016-08-04',
tem: 26,
type: 'start',
},
{
time: '2016-08-05',
tem: 20,
type: 'start',
},
{
time: '2016-08-06',
tem: 26,
type: 'start',
},
].map((d) => {
data.push(d);
data.push({ ...d, tem: d.tem + 15, type: 'middle' });
data.push({ ...d, tem: d.tem + 30, type: 'end' });
});

const context = document.getElementById('container').getContext('2d');
const { props } = (
<Canvas context={context}>
<Chart data={data}>
<Axis
field="time"
tickCount={2}
style={{
label: {
align: 'between',
},
}}
/>
<Axis field="tem" tickCount={5} max={60} />
<Line
x="time"
y="tem"
color="type"
shape={{
field: 'type',
range: ['step-start', 'step-middle', 'step-end'],
}}
/>
</Chart>
</Canvas>
);

const canvas = new Canvas(props);
canvas.render();

0 comments on commit d86ee8c

Please sign in to comment.