import React, { useState } from 'react'; import { View, Text, Dimensions, Pressable, StyleSheet, ScrollView } from "react-native"; import { LineChart } from 'react-native-chart-kit'; const screenWidth = Dimensions.get("window").width; const Grafico = () => { const [timeFrame, setTimeFrame] = useState("1D"); const data = { labels: ["Lun", "Mar", "Mer", "Gio", "Ven", "Sab", "Dom"], datasets: [ { data: [20, 45, 28, 80, 70, 43, 100, 100], color: (opacity = 1) => `rgba(134, 65, 244, ${opacity})`, strokeWidth: 2 } ], legend: ["Money"] }; const handleTimeFrameChange = (newTimeFrame: React.SetStateAction) => { setTimeFrame(newTimeFrame); }; return ( {/* Contenitore con bordo per il grafico */} {/* ScrollView per bottoni */} handleTimeFrameChange("1D")}> 1D handleTimeFrameChange("1W")}> 1W handleTimeFrameChange("1M")}> 1M handleTimeFrameChange("July")}> July handleTimeFrameChange("June")}> June handleTimeFrameChange("May")}> May handleTimeFrameChange("All")}> All ); }; const chartConfig = { color: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`, strokeWidth: 1, barPercentage: 0.5, useShadowColorFromDataset: false }; const styles = StyleSheet.create({ container: { padding: 20, }, chartContainer: { borderWidth: 2, borderColor: 'black', borderRadius: 10, padding: 10, marginBottom: 20, alignItems: 'center', }, scrollContainer: { paddingVertical: 10, alignItems: 'center', }, buttonRow: { flexDirection: 'row', justifyContent: 'space-around', }, buttonText: { fontSize: 16, color: 'white', // Cambia il colore del testo per contrasto backgroundColor: '#1a1a1a', // Aggiungi un background color per i bottoni padding: 10, // Rendi il bottone più compatto marginHorizontal: 5, // Spaziatura laterale più piccola borderRadius: 5, // Arrotonda i bordi }, activeButton: { color: 'purple', fontWeight: 'bold', backgroundColor: 'lightgray', // Cambia il colore di sfondo per il bottone attivo } }); export default Grafico;