[fix] Fit chart in box boundaries

This commit is contained in:
Hristo Nedelkov 2023-08-09 09:32:05 +03:00
parent 1e56634029
commit c903095228
2 changed files with 49 additions and 14 deletions

View File

@ -24,17 +24,16 @@ function App() {
return ( return (
<TamaguiProvider config={config}> <TamaguiProvider config={config}>
<StatisticBox
memory="45"
stateIcon="https://placehold.co/16x16"
stateText="Improving performance"
title="Title of the box"
/>
<StatusProvider> <StatusProvider>
<div style={{ height: '500px', width: '300px' }}> <div style={{ height: '500px', width: '300px' }}>
<StandardGauge data={data} /> <StandardGauge data={data} />
</div> </div>
<StatisticBox
memory="30"
stateIcon="https://placehold.co/60x40"
stateText="Oooo"
title="Auuuu"
/>
</StatusProvider> </StatusProvider>
</TamaguiProvider> </TamaguiProvider>
) )

View File

@ -7,25 +7,61 @@ const MyResponsiveLine = () => {
color: 'hsl(315, 70%, 50%)', color: 'hsl(315, 70%, 50%)',
data: [ data: [
{ {
x: 'plane', x: '1',
y: 34, y: 15,
}, },
{ {
x: 'helicopter', x: '2',
y: 12,
},
{
x: '3',
y: 43,
},
{
x: '4',
y: 20,
},
{
x: '5',
y: 60, y: 60,
}, },
{ {
x: 'boat', x: '6',
y: 5,
},
{
x: '7',
y: 15,
},
{
x: '8',
y: 12,
},
{
x: '9',
y: 43,
},
{
x: '10',
y: 20, y: 20,
}, },
{
x: '11',
y: 60,
},
{
x: '12',
y: 5,
},
], ],
}, },
] ]
return ( return (
<ResponsiveLine <ResponsiveLine
data={data} data={data}
margin={{ top: 0, right: 0, bottom: 0, left: 30 }} margin={{ top: 0, right: 0, bottom: 0, left: -75 }}
xScale={{ type: 'point' }} xScale={{ type: 'linear', min: 0, max: 12 }}
yScale={{ yScale={{
type: 'linear', type: 'linear',
min: 'auto', min: 'auto',
@ -40,7 +76,7 @@ const MyResponsiveLine = () => {
enableGridX={false} enableGridX={false}
enableGridY={false} enableGridY={false}
enablePoints={false} enablePoints={false}
pointSize={10} pointSize={1}
pointColor={{ theme: 'background' }} pointColor={{ theme: 'background' }}
pointBorderWidth={2} pointBorderWidth={2}
pointBorderColor={{ from: 'serieColor' }} pointBorderColor={{ from: 'serieColor' }}