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

LineSeries ordinal #143

Open
royderksroute42 opened this issue Oct 30, 2018 · 3 comments
Open

LineSeries ordinal #143

royderksroute42 opened this issue Oct 30, 2018 · 3 comments
Labels

Comments

@royderksroute42
Copy link

Hi there,

I've been trying for a (long) while but i can't figure out how to make an ordinal LineSeries - chart with String 'x' values. It seems to be unable to determine where its ticks should be; even when using numbers fo the 'x' value. Playing around with the numTicks properties and such all result in the same. Is this package capable of rendering a LineSeries?

data

[
        { x: 'car', y: 1 },
        { x: 'plane', y: 2 },
        { x: 'new york', y: 3 },
        { x: 'ocean', y: 4 },
        { x: 'pencil', y: 5 },
      ]
<XYChart
    height={height}
    width={width}
    xScale={{ type: 'ordinal' }}
    yScale={{ type: 'linear' }}
  >
    <LineSeries
      data={[
        { x: 'car', y: 1 },
        { x: 'plane', y: 2 },
        { x: 'new york', y: 3 },
        { x: 'ocean', y: 4 },
        { x: 'pencil', y: 5 },
      ]}
    />
    <XAxis />
    <YAxis />
  </XYChart>

screen shot 2018-10-30 at 14 17 19

@williaster
Copy link
Owner

Hey @royderksroute42 thanks for checking out @data-ui!

I think that you're right that something is up with the ordinal type scale, so I'll mark this as a bug to make sure that it gets resolved.

BUT you can work around this for now with a band scale and setting paddingInner = 1:

xScale={{ type: 'band', paddingInner: 1 }}

Here's a codesandbox to check out/play with, I hope that helps for the time being until I get a chance to fix it! (have been slammed at work recently but will try to get this fixed asap)

image

@williaster williaster added the bug label Oct 30, 2018
@royderksroute42
Copy link
Author

royderksroute42 commented Nov 5, 2018

Thank you for the quick reply, it seems the workaround is working as it should; the codesandbox was very useful and helped a lot. Cheers!

@williaster
Copy link
Owner

FYI this is due to ordinal type scales requiring full explicit domains for each value, which XYChart does not currently handle (it will set a 2-element min/max). Working on a fix to not require users to pass this in explicitly.

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

2 participants