-
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.
- Loading branch information
Showing
9 changed files
with
193 additions
and
83 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<view class="container"> | ||
<f2 onRender="onRenderChart"></f2> | ||
<f2 onRender="onRenderChart" data="{{chartData}}"></f2> | ||
</view> |
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 |
---|---|---|
@@ -1,21 +1,62 @@ | ||
// 通过 createElement 方式创建 | ||
import { createElement } from '@antv/f2'; | ||
import Chart from './chart'; | ||
import { jsx as _jsx } from "@antv/f2/jsx-runtime"; | ||
const data1 = [{ | ||
genre: 'Sports', | ||
sold: 275 | ||
}, { | ||
genre: 'Strategy', | ||
sold: 115 | ||
}, { | ||
genre: 'Action', | ||
sold: 120 | ||
}, { | ||
genre: 'Shooter', | ||
sold: 350 | ||
}, { | ||
genre: 'Other', | ||
sold: 150 | ||
}]; | ||
const data2 = [{ | ||
genre: 'Sports', | ||
sold: 275 | ||
}, { | ||
genre: 'Strategy', | ||
sold: 115 | ||
}, { | ||
genre: 'Action', | ||
sold: 20 | ||
}, { | ||
genre: 'Shooter', | ||
sold: 50 | ||
}, { | ||
genre: 'Other', | ||
sold: 50 | ||
}]; | ||
Page({ | ||
data: {// chartData: data1, | ||
}, | ||
|
||
const data = [ | ||
{ genre: 'Sports', sold: 275 }, | ||
{ genre: 'Strategy', sold: 115 }, | ||
{ genre: 'Action', sold: 120 }, | ||
{ genre: 'Shooter', sold: 350 }, | ||
{ genre: 'Other', sold: 150 } | ||
]; | ||
onReady() { | ||
this.setData({ | ||
chartData: data1 | ||
}); // 模拟数据更新 | ||
|
||
Page({ | ||
data: { | ||
setTimeout(() => { | ||
this.setData({ | ||
chartData: data2 | ||
}); | ||
}, 2000); | ||
}, | ||
onRenderChart() { | ||
return createElement(Chart, { | ||
|
||
onRenderChart(props) { | ||
const { | ||
data | ||
} = props; | ||
return _jsx(Chart, { | ||
data: data | ||
}); | ||
} | ||
}); | ||
|
||
}); |
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,45 @@ | ||
// 通过 createElement 方式创建 | ||
import { createElement } from '@antv/f2'; | ||
import Chart from './chart'; | ||
|
||
const data1 = [ | ||
{ genre: 'Sports', sold: 275 }, | ||
{ genre: 'Strategy', sold: 115 }, | ||
{ genre: 'Action', sold: 120 }, | ||
{ genre: 'Shooter', sold: 350 }, | ||
{ genre: 'Other', sold: 150 }, | ||
]; | ||
|
||
const data2 = [ | ||
{ genre: 'Sports', sold: 275 }, | ||
{ genre: 'Strategy', sold: 115 }, | ||
{ genre: 'Action', sold: 20 }, | ||
{ genre: 'Shooter', sold: 50 }, | ||
{ genre: 'Other', sold: 50 }, | ||
]; | ||
|
||
Page({ | ||
data: { | ||
// chartData: data1, | ||
}, | ||
onReady() { | ||
this.setData({ | ||
chartData: data1, | ||
}); | ||
// 模拟数据更新 | ||
setTimeout(() => { | ||
this.setData({ | ||
chartData: data2, | ||
}); | ||
}, 2000); | ||
}, | ||
onRenderChart(props) { | ||
const { data } = props; | ||
return <Chart data={data} />; | ||
|
||
// 如果不使用 jsx, 用下面代码效果也是一样的 | ||
// return createElement(Chart, { | ||
// data: data, | ||
// }); | ||
}, | ||
}); |
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
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