Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starting date is not shown on x-axis #618

Open
sanaf1333 opened this issue Sep 16, 2024 · 0 comments
Open

Starting date is not shown on x-axis #618

sanaf1333 opened this issue Sep 16, 2024 · 0 comments
Labels

Comments

@sanaf1333
Copy link

sanaf1333 commented Sep 16, 2024

I am showing dates on x-axis but the problem is that the starting date is not shown. My data is in this format:
["2002-08-31T00:00:00.000Z", "2003-08-31T00:00:00.000Z", "2004-08-31T00:00:00.000Z", "2005-08-31T00:00:00.000Z", "2006-08-31T00:00:00.000Z", "2007-08-31T00:00:00.000Z", "2008-08-31T00:00:00.000Z", "2009-08-31T00:00:00.000Z", "2010-08-31T00:00:00.000Z", "2011-08-31T00:00:00.000Z", "2012-08-31T00:00:00.000Z", "2013-08-31T00:00:00.000Z", "2014-08-31T00:00:00.000Z", "2015-08-31T00:00:00.000Z", "2016-08-31T00:00:00.000Z", "2017-08-31T00:00:00.000Z", "2018-08-31T00:00:00.000Z", "2019-08-31T00:00:00.000Z", "2020-08-31T00:00:00.000Z", "2021-08-31T00:00:00.000Z", "2022-08-31T00:00:00.000Z", "2023-08-31T00:00:00.000Z", "2024-08-31T00:00:00.000Z"]

On x-axis, following labels are shown 2004, 2006, 2008, 2010, 2012, 2014, 2016, 2018, 2020, 2022, 2024 but 2002 is not shown in the start. What can I change so it shows the starting year too? I have tried playing around with scale, labels, xAccessor but nothing is working, I made the first one appear but again it is not useful for every case as sometimes we have a lot of years so we might need a jump of 4 years or more which is not tailored then, also I have monthly data too liek the above pne but with more repeated years so in the custom formatted labels that is messed up too. Can someone please help me out here?

<XAxis

          data={dates}

          formatLabel={value => new Date(value).getFullYear().toString()}

          xAccessor={d => new Date(d.item).getTime()}

          numberOfTicks={9}

          scale={scale.scaleTime}

          contentInset={{ left: 20, right: apx(80) }}

          style={{ marginHorizontal: -10, paddingTop: 6, width: apx(750) }}

          svg={{ fontSize: 10, fill: 'grey' }}

        />

What platform?

react-native version: 0.74.2
react-native-svg-charts version: ^5.4.0
react-native-svg version: ^15.3.0

@sanaf1333 sanaf1333 added the bug label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant