Skip to content

Commit ffdd907

Browse files
tianmei.wutianmei.wu
tianmei.wu
authored and
tianmei.wu
committed
feat:搭建ing
1 parent b1bf496 commit ffdd907

File tree

14 files changed

+12570
-222
lines changed

14 files changed

+12570
-222
lines changed

.babelrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"presets": ["@babel/preset-env", "module:metro-react-native-babel-preset"],
3+
"plugins": [
4+
"transform-remove-strict-mode",
5+
"@babel/plugin-transform-react-jsx-source",
6+
["@babel/plugin-proposal-decorators", { "legacy": true }],
7+
[
8+
"import",
9+
{
10+
"libraryName": "@ant-design/react-native"
11+
}
12+
]
13+
]
14+
}

.eslintrc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"root": true,
3+
"extends": ["standard", "react-app", "prettier/react", "@react-native-community", "plugin:jest/recommended"],
4+
"plugins": ["flowtype", "prettier", "react", "jest"],
5+
"env": {
6+
"jest/globals": true,
7+
"browser": true,
8+
"es6": true
9+
},
10+
"rules": {
11+
"no-undef": 0,
12+
"no-useless-constructor": 0,
13+
"no-unused-vars": 1,
14+
"quotes": [
15+
"error",
16+
"double",
17+
{
18+
"avoidEscape": true,
19+
"allowTemplateLiterals": true
20+
}
21+
],
22+
"semi": ["error", "never"],
23+
"object-curly-spacing": ["error", "always"]
24+
}
25+
}

.eslintrc.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

App.js

Lines changed: 92 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,100 @@
1-
/**
2-
* Sample React Native App
3-
* https://github.com/facebook/react-native
4-
*
5-
* @format
6-
* @flow
1+
/*
2+
* @Author: tianmei.wu
3+
* @Date: 2019-08-15 17:03:51
4+
* @Description:
75
*/
6+
import React, { Component } from "react"
7+
import { StyleSheet, Text, View, Dimensions } from "react-native"
8+
import Canvas from "react-native-canvas"
9+
import { Provider } from "@ant-design/react-native"
10+
const F2 = require("@antv/f2/lib/core") // 引入核心包
11+
12+
require("@antv/f2/lib/geom/") // 几何标记对象
13+
require("@antv/f2/lib/geom/adjust/") // 数据调整
814

9-
import React, {Fragment} from 'react';
10-
import {
11-
SafeAreaView,
12-
StyleSheet,
13-
ScrollView,
14-
View,
15-
Text,
16-
StatusBar,
17-
} from 'react-native';
15+
require("@antv/f2/lib/coord/polar") // 极坐标系
16+
require("@antv/f2/lib/component/axis/circle") // 极坐标系下的弧长坐标轴
1817

19-
import {
20-
Header,
21-
LearnMoreLinks,
22-
Colors,
23-
DebugInstructions,
24-
ReloadInstructions,
25-
} from 'react-native/Libraries/NewAppScreen';
18+
require("@antv/f2/lib/scale/time-cat") // timeCat 类型的度量
2619

20+
require("@antv/f2/lib/component/guide") // 加载 guide 组件
21+
const Guide = require("@antv/f2/lib/plugin/guide") // Guide 插件
22+
const Legend = require("@antv/f2/lib/plugin/legend") // Legend 插件
23+
F2.Chart.plugins.register([Legend, Guide]) // 注册以上插件
24+
const { width } = Dimensions.get("window")
25+
/**
26+
* Provider 必须在 app 入口指定,不然部分组件用不了(因为现在支持多个 Modal 以及在 Modal 上面显示 Toast)
27+
*/
2728
const App = () => {
28-
return (
29-
<Fragment>
30-
<StatusBar barStyle="dark-content" />
31-
<SafeAreaView>
32-
<ScrollView
33-
contentInsetAdjustmentBehavior="automatic"
34-
style={styles.scrollView}>
35-
<Header />
36-
{global.HermesInternal == null ? null : (
37-
<View style={styles.engine}>
38-
<Text style={styles.footer}>Engine: Hermes</Text>
39-
</View>
40-
)}
41-
<View style={styles.body}>
42-
<View style={styles.sectionContainer}>
43-
<Text style={styles.sectionTitle}>Step One</Text>
44-
<Text style={styles.sectionDescription}>
45-
Edit <Text style={styles.highlight}>App.js</Text> to change this
46-
screen and then come back to see your edits.
47-
</Text>
48-
</View>
49-
<View style={styles.sectionContainer}>
50-
<Text style={styles.sectionTitle}>See Your Changes</Text>
51-
<Text style={styles.sectionDescription}>
52-
<ReloadInstructions />
53-
</Text>
54-
</View>
55-
<View style={styles.sectionContainer}>
56-
<Text style={styles.sectionTitle}>Debug</Text>
57-
<Text style={styles.sectionDescription}>
58-
<DebugInstructions />
59-
</Text>
60-
</View>
61-
<View style={styles.sectionContainer}>
62-
<Text style={styles.sectionTitle}>Learn More</Text>
63-
<Text style={styles.sectionDescription}>
64-
Read the docs to discover what to do next:
65-
</Text>
66-
</View>
67-
<LearnMoreLinks />
68-
</View>
69-
</ScrollView>
70-
</SafeAreaView>
71-
</Fragment>
72-
);
73-
};
29+
state = {
30+
width: 0,
31+
height: 0
32+
}
33+
handleCanvas = canvas => {
34+
canvas.width = width
35+
canvas.height = width
36+
const data = [
37+
{ name: "芳华", percent: 0.4, a: "1" },
38+
{ name: "妖猫传", percent: 0.2, a: "1" },
39+
{ name: "机器之血", percent: 0.18, a: "1" },
40+
{ name: "心理罪", percent: 0.15, a: "1" },
41+
{ name: "寻梦环游记", percent: 0.05, a: "1" },
42+
{ name: "其他", percent: 0.02, a: "1" }
43+
]
44+
this.setState({
45+
height: canvas.height
46+
})
47+
const chart = new F2.Chart({
48+
el: canvas,
49+
width: width,
50+
height: width,
51+
padding: [0, "auto", "auto"]
52+
})
53+
chart.source(data, {
54+
percent: {
55+
formatter(val) {
56+
return val * 100 + "%"
57+
}
58+
}
59+
})
60+
chart.legend({
61+
position: "right"
62+
})
63+
chart.coord("polar", {
64+
transposed: true,
65+
radius: 0.85
66+
})
67+
chart.axis(false)
68+
chart
69+
.interval()
70+
.position("a*percent")
71+
.color("name", ["#1890FF", "#13C2C2", "#2FC25B", "#FACC14", "#F04864", "#8543E0"])
72+
.adjust("stack")
73+
.style({
74+
lineWidth: 1,
75+
stroke: "#fff",
76+
lineJoin: "round",
77+
lineCap: "round"
78+
})
7479

80+
chart.render()
81+
}
82+
return (
83+
<Provider>
84+
<View style={styles.container}>
85+
<Text>饼图</Text>
86+
<Canvas ref={this.handleCanvas}></Canvas>
87+
</View>
88+
</Provider>
89+
)
90+
}
7591
const styles = StyleSheet.create({
76-
scrollView: {
77-
backgroundColor: Colors.lighter,
78-
},
79-
engine: {
80-
position: 'absolute',
81-
right: 0,
82-
},
83-
body: {
84-
backgroundColor: Colors.white,
85-
},
86-
sectionContainer: {
87-
marginTop: 32,
88-
paddingHorizontal: 24,
89-
},
90-
sectionTitle: {
91-
fontSize: 24,
92-
fontWeight: '600',
93-
color: Colors.black,
94-
},
95-
sectionDescription: {
96-
marginTop: 8,
97-
fontSize: 18,
98-
fontWeight: '400',
99-
color: Colors.dark,
100-
},
101-
highlight: {
102-
fontWeight: '700',
103-
},
104-
footer: {
105-
color: Colors.dark,
106-
fontSize: 12,
107-
fontWeight: '600',
108-
padding: 4,
109-
paddingRight: 12,
110-
textAlign: 'right',
111-
},
112-
});
92+
container: {
93+
flex: 1,
94+
backgroundColor: "#fff",
95+
alignItems: "center",
96+
justifyContent: "center"
97+
}
98+
})
11399

114-
export default App;
100+
export default App
46 KB
Binary file not shown.
Binary file not shown.

babel.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
/*
2+
* @Author: tianmei.wu
3+
* @Date: 2019-08-15 17:03:51
4+
* @Description:
5+
*/
16
/**
27
* @format
38
*/
49

10+
import React from 'react';
511
import {AppRegistry} from 'react-native';
612
import App from './App';
713
import {name as appName} from './app.json';
8-
9-
AppRegistry.registerComponent(appName, () => App);
14+
AppRegistry.registerComponent(appName, () =>App );

ios/Podfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ PODS:
5656
- React-cxxreact (= 0.60.5)
5757
- React-jsi (= 0.60.5)
5858
- React-jsinspector (0.60.5)
59+
- react-native-webview (6.9.0):
60+
- React
5961
- React-RCTActionSheet (0.60.5):
6062
- React-Core (= 0.60.5)
6163
- React-RCTAnimation (0.60.5):
@@ -92,6 +94,7 @@ DEPENDENCIES:
9294
- React-jsi (from `../node_modules/react-native/ReactCommon/jsi`)
9395
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
9496
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
97+
- react-native-webview (from `../node_modules/react-native-webview`)
9598
- React-RCTActionSheet (from `../node_modules/react-native/Libraries/ActionSheetIOS`)
9699
- React-RCTAnimation (from `../node_modules/react-native/Libraries/NativeAnimation`)
97100
- React-RCTBlob (from `../node_modules/react-native/Libraries/Blob`)
@@ -129,6 +132,8 @@ EXTERNAL SOURCES:
129132
:path: "../node_modules/react-native/ReactCommon/jsiexecutor"
130133
React-jsinspector:
131134
:path: "../node_modules/react-native/ReactCommon/jsinspector"
135+
react-native-webview:
136+
:path: "../node_modules/react-native-webview"
132137
React-RCTActionSheet:
133138
:path: "../node_modules/react-native/Libraries/ActionSheetIOS"
134139
React-RCTAnimation:
@@ -164,6 +169,7 @@ SPEC CHECKSUMS:
164169
React-jsi: 4d8c9efb6312a9725b18d6fc818ffc103f60fec2
165170
React-jsiexecutor: 90ad2f9db09513fc763bc757fdc3c4ff8bde2a30
166171
React-jsinspector: e08662d1bf5b129a3d556eb9ea343a3f40353ae4
172+
react-native-webview: 2d8de2be422f0f8b9ba38db3f013f9ebfdb9b78f
167173
React-RCTActionSheet: b0f1ea83f4bf75fb966eae9bfc47b78c8d3efd90
168174
React-RCTAnimation: 359ba1b5690b1e87cc173558a78e82d35919333e
169175
React-RCTBlob: 5e2b55f76e9a1c7ae52b826923502ddc3238df24

ios/graph.xcodeproj/project.pbxproj

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
};
66
objectVersion = 46;
77
objects = {
8-
98
/* Begin PBXBuildFile section */
109
00E356F31AD99517003FC87E /* graphTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* graphTests.m */; };
1110
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
@@ -20,6 +19,8 @@
2019
65CE94D957E5BA72D690AF3F /* libPods-graph-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B007CAE7FBD09F65BD998645 /* libPods-graph-tvOS.a */; };
2120
7CE42CABA32EEAAC2CDD8BBA /* libPods-graph.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6172F4417F5484121B7DB991 /* libPods-graph.a */; };
2221
C55935B94914E837E4672934 /* libPods-graph-tvOSTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 62282C651D88027727E81C50 /* libPods-graph-tvOSTests.a */; };
22+
57BE2D3C57A341DB8CE5B253 /* antfill.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 91A000ACBB3C4A0480E3DFE4 /* antfill.ttf */; };
23+
56E64FF1CE9B4402B4612C3B /* antoutline.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 0D71111841634E6C8442681A /* antoutline.ttf */; };
2324
/* End PBXBuildFile section */
2425

2526
/* Begin PBXContainerItemProxy section */
@@ -67,6 +68,8 @@
6768
ED2971642150620600B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; };
6869
F56E0C692C3EA1933C0AA27E /* Pods-graph-tvOSTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-graph-tvOSTests.debug.xcconfig"; path = "Target Support Files/Pods-graph-tvOSTests/Pods-graph-tvOSTests.debug.xcconfig"; sourceTree = "<group>"; };
6970
FF2DFF1B38D23CB4827C4F14 /* Pods-graph-tvOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-graph-tvOS.debug.xcconfig"; path = "Target Support Files/Pods-graph-tvOS/Pods-graph-tvOS.debug.xcconfig"; sourceTree = "<group>"; };
71+
91A000ACBB3C4A0480E3DFE4 /* antfill.ttf */ = {isa = PBXFileReference; name = "antfill.ttf"; path = "../node_modules/@ant-design/icons-react-native/fonts/antfill.ttf"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
72+
0D71111841634E6C8442681A /* antoutline.ttf */ = {isa = PBXFileReference; name = "antoutline.ttf"; path = "../node_modules/@ant-design/icons-react-native/fonts/antoutline.ttf"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
7073
/* End PBXFileReference section */
7174

7275
/* Begin PBXFrameworksBuildPhase section */
@@ -165,6 +168,7 @@
165168
83CBBA001A601CBA00E9B192 /* Products */,
166169
2D16E6871FA4F8E400B85C8A /* Frameworks */,
167170
8477ABAFBCF1C27188CB68D4 /* Pods */,
171+
69C2C729439E47C5ADFDBC64 /* Resources */,
168172
);
169173
indentWidth = 2;
170174
sourceTree = "<group>";
@@ -198,6 +202,16 @@
198202
path = Pods;
199203
sourceTree = "<group>";
200204
};
205+
69C2C729439E47C5ADFDBC64 /* Resources */ = {
206+
isa = "PBXGroup";
207+
children = (
208+
91A000ACBB3C4A0480E3DFE4 /* antfill.ttf */,
209+
0D71111841634E6C8442681A /* antoutline.ttf */,
210+
);
211+
name = Resources;
212+
sourceTree = "<group>";
213+
path = "";
214+
};
201215
/* End PBXGroup section */
202216

203217
/* Begin PBXNativeTarget section */
@@ -285,7 +299,7 @@
285299
83CBB9F71A601CBA00E9B192 /* Project object */ = {
286300
isa = PBXProject;
287301
attributes = {
288-
LastUpgradeCheck = 0940;
302+
LastUpgradeCheck = 940;
289303
ORGANIZATIONNAME = Facebook;
290304
TargetAttributes = {
291305
00E356ED1AD99517003FC87E = {
@@ -338,6 +352,8 @@
338352
files = (
339353
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
340354
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
355+
57BE2D3C57A341DB8CE5B253 /* antfill.ttf in Resources */,
356+
56E64FF1CE9B4402B4612C3B /* antoutline.ttf in Resources */,
341357
);
342358
runOnlyForDeploymentPostprocessing = 0;
343359
};

ios/graph/Info.plist

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</dict>
3939
</dict>
4040
<key>NSLocationWhenInUseUsageDescription</key>
41-
<string></string>
41+
<string/>
4242
<key>UILaunchStoryboardName</key>
4343
<string>LaunchScreen</string>
4444
<key>UIRequiredDeviceCapabilities</key>
@@ -53,5 +53,10 @@
5353
</array>
5454
<key>UIViewControllerBasedStatusBarAppearance</key>
5555
<false/>
56+
<key>UIAppFonts</key>
57+
<array>
58+
<string>antfill.ttf</string>
59+
<string>antoutline.ttf</string>
60+
</array>
5661
</dict>
5762
</plist>

0 commit comments

Comments
 (0)