Skip to content

Commit f436c7f

Browse files
committed
fix styling
1 parent bc6e212 commit f436c7f

5 files changed

Lines changed: 187 additions & 96 deletions

File tree

demo/app/(tabs)/index.tsx

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { useEffect, useRef, useState, useMemo } from 'react';
2-
import { Platform, StyleSheet, SafeAreaView, Text } from 'react-native';
2+
import {
3+
Platform,
4+
StyleSheet,
5+
SafeAreaView,
6+
Text,
7+
Dimensions,
8+
} from 'react-native';
39

410
import ChartUPlot from 'uplot-react-native';
511

@@ -21,41 +27,37 @@ var data2 = makeData(n);
2127
var data3 = makeData(n);
2228
var count = n * 3;
2329

24-
var options = {
25-
id: 'chart',
26-
width: 300,
27-
height: 150,
28-
scales: { x: { time: false } },
29-
series: [{ label: 'Time' }, { label: 'Value', stroke: 'blue', width: 2 }],
30-
axes: [{ scale: 'x' }, {}],
31-
};
32-
var style = {
33-
width: 400,
34-
height: 150,
35-
};
36-
3730
export default function HomeScreen() {
3831
// create ref for chart
3932
const chartRef1 = useRef(null);
4033
const chartRef2 = useRef(null);
4134
const chartRef3 = useRef(null);
4235
const [nDataPoint, setNDataPoint] = useState(1);
4336

37+
var { width, height } = Dimensions.get('window');
38+
4439
useEffect(() => {
45-
setTimeout(() => {
46-
setInterval(() => {
47-
chartRef1.current?.pushData([n, Math.random() * 100]);
48-
chartRef2.current?.pushData([n, Math.random() * 100]);
49-
chartRef3.current?.pushData([n, Math.random() * 100]);
50-
count = count + 3;
51-
n = n + 1;
52-
}, 10);
53-
}, 10000);
40+
setInterval(() => {
41+
chartRef1.current?.pushData([n, Math.random() * 100]);
42+
// chartRef2.current?.pushData([n, Math.random() * 100]);
43+
// chartRef3.current?.pushData([n, Math.random() * 100]);
44+
count = count + 3;
45+
n = n + 1;
46+
}, 1000);
5447
setInterval(() => {
5548
setNDataPoint(count);
5649
}, 1000);
5750
}, []);
5851

52+
var options = {
53+
id: 'chart',
54+
width: width,
55+
height: height * 0.7,
56+
scales: { x: { time: false } },
57+
series: [{ label: 'Time' }, { label: 'Value', stroke: 'blue', width: 2 }],
58+
axes: [{ scale: 'x' }, {}],
59+
};
60+
5961
return (
6062
<SafeAreaView
6163
style={{
@@ -81,10 +83,13 @@ export default function HomeScreen() {
8183
<ChartUPlot
8284
data={data1}
8385
options={options}
84-
style={style}
86+
style={{
87+
width: width,
88+
height: height * 0.7,
89+
}}
8590
ref={chartRef1}
8691
/>
87-
<ChartUPlot
92+
{/* <ChartUPlot
8893
data={data2}
8994
options={options}
9095
style={style}
@@ -95,7 +100,7 @@ export default function HomeScreen() {
95100
options={options}
96101
style={style}
97102
ref={chartRef3}
98-
/>
103+
/> */}
99104
</SafeAreaView>
100105
);
101106
}

demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"react-native-screens": "~4.11.1",
3939
"react-native-web": "~0.20.0",
4040
"react-native-webview": "13.13.5",
41-
"uplot-react-native": "0.1.3"
41+
"uplot-react-native": "0.1.4"
4242
},
4343
"devDependencies": {
4444
"@babel/core": "^7.25.2",

demo/yarn.lock

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -833,10 +833,10 @@
833833
dependencies:
834834
"@types/json-schema" "^7.0.15"
835835

836-
"@eslint/core@^0.15.0":
837-
version "0.15.0"
838-
resolved "https://registry.yarnpkg.com/@eslint/core/-/core-0.15.0.tgz#8fc04709a7b9a179d9f7d93068fc000cb8c5603d"
839-
integrity sha512-b7ePw78tEWWkpgZCDYkbqDOP8dmM6qe+AOC6iuJqlq1R/0ahMAeH3qynpnqKFGkMltrp44ohV4ubGyvLX28tzw==
836+
"@eslint/core@^0.15.1":
837+
version "0.15.1"
838+
resolved "https://registry.yarnpkg.com/@eslint/core/-/core-0.15.1.tgz#d530d44209cbfe2f82ef86d6ba08760196dd3b60"
839+
integrity sha512-bkOp+iumZCCbt1K1CmWf0R9pM5yKpDv+ZXtvSyQpudrI9kuFLp+bM2WOPXImuD/ceQuaa8f5pj93Y7zyECIGNA==
840840
dependencies:
841841
"@types/json-schema" "^7.0.15"
842842

@@ -866,11 +866,11 @@
866866
integrity sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA==
867867

868868
"@eslint/plugin-kit@^0.3.1":
869-
version "0.3.2"
870-
resolved "https://registry.yarnpkg.com/@eslint/plugin-kit/-/plugin-kit-0.3.2.tgz#0cad96b134d23a653348e3342f485636b5ef4732"
871-
integrity sha512-4SaFZCNfJqvk/kenHpI8xvN42DMaoycy4PzKc5otHxRswww1kAt82OlBuwRVLofCACCTZEcla2Ydxv8scMXaTg==
869+
version "0.3.3"
870+
resolved "https://registry.yarnpkg.com/@eslint/plugin-kit/-/plugin-kit-0.3.3.tgz#32926b59bd407d58d817941e48b2a7049359b1fd"
871+
integrity sha512-1+WqvgNMhmlAambTvT3KPtCl/Ibr68VldY2XY40SL1CE0ZXiakFR/cbTspaF5HsnpDMvcYYoJHfl4980NBjGag==
872872
dependencies:
873-
"@eslint/core" "^0.15.0"
873+
"@eslint/core" "^0.15.1"
874874
levn "^0.4.1"
875875

876876
"@expo/cli@0.24.15":
@@ -2422,12 +2422,12 @@ braces@^3.0.3:
24222422
fill-range "^7.1.1"
24232423

24242424
browserslist@^4.24.0, browserslist@^4.25.0:
2425-
version "4.25.0"
2426-
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.25.0.tgz#986aa9c6d87916885da2b50d8eb577ac8d133b2c"
2427-
integrity sha512-PJ8gYKeS5e/whHBh8xrwYK+dAvEj7JXtz6uTucnMRB8OiGTsKccFekoRrjajPBHV8oOY+2tI4uxeceSimKwMFA==
2425+
version "4.25.1"
2426+
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.25.1.tgz#ba9e8e6f298a1d86f829c9b975e07948967bb111"
2427+
integrity sha512-KGj0KoOMXLpSNkkEI6Z6mShmQy0bc1I+T7K9N81k4WWMrfz+6fQ6es80B/YLAeRoKvjYE1YSHHOW1qe9xIVzHw==
24282428
dependencies:
2429-
caniuse-lite "^1.0.30001718"
2430-
electron-to-chromium "^1.5.160"
2429+
caniuse-lite "^1.0.30001726"
2430+
electron-to-chromium "^1.5.173"
24312431
node-releases "^2.0.19"
24322432
update-browserslist-db "^1.1.3"
24332433

@@ -2516,10 +2516,10 @@ camelcase@^6.2.0:
25162516
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a"
25172517
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==
25182518

2519-
caniuse-lite@^1.0.30001718:
2520-
version "1.0.30001724"
2521-
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001724.tgz#312e163553dd70d2c0fb603d74810c85d8ed94a0"
2522-
integrity sha512-WqJo7p0TbHDOythNTqYujmaJTvtYRZrjpP8TCvH6Vb9CYJerJNKamKzIWOM4BkQatWj9H2lYulpdAQNBe7QhNA==
2519+
caniuse-lite@^1.0.30001726:
2520+
version "1.0.30001726"
2521+
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001726.tgz#a15bd87d5a4bf01f6b6f70ae7c97fdfd28b5ae47"
2522+
integrity sha512-VQAUIUzBiZ/UnlM28fSp2CRF3ivUn1BWEvxMcVTNwpw91Py1pGbPIyIKtd+tzct9C3ouceCVdGAXxZOpZAsgdw==
25232523

25242524
chalk@^2.0.1, chalk@^2.4.2:
25252525
version "2.4.2"
@@ -2912,10 +2912,10 @@ ee-first@1.1.1:
29122912
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
29132913
integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==
29142914

2915-
electron-to-chromium@^1.5.160:
2916-
version "1.5.173"
2917-
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.173.tgz#1aeba57204fe19425921a29946ef543653f5e896"
2918-
integrity sha512-2bFhXP2zqSfQHugjqJIDFVwa+qIxyNApenmXTp9EjaKtdPrES5Qcn9/aSFy/NaP2E+fWG/zxKu/LBvY36p5VNQ==
2915+
electron-to-chromium@^1.5.173:
2916+
version "1.5.174"
2917+
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.174.tgz#c7d273755d4dc9bc4f1d192f6f2092bee42771f3"
2918+
integrity sha512-HE43yYdUUiJVjewV2A9EP8o89Kb4AqMKplMQP2IxEPUws1Etu/ZkdsgUDabUZ/WmbP4ZbvJDOcunvbBUPPIfmw==
29192919

29202920
emoji-regex@^8.0.0:
29212921
version "8.0.0"
@@ -6674,7 +6674,7 @@ update-browserslist-db@^1.1.3:
66746674
picocolors "^1.1.1"
66756675

66766676
"uplot-react-native@file:..":
6677-
version "0.1.1"
6677+
version "0.1.3"
66786678
dependencies:
66796679
react-native-webview ">=13.0.0"
66806680
uplot ">=1.6.0"

0 commit comments

Comments
 (0)