question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not able to create two Y axes with the same scale and number of ticks

See original GitHub issue

I’m creating a stacked chart where bars represent electricity consumption and lines represent outside temperature:

image

I’m trying to achieve a chart where the temperature labels would align with the grid lines rendered by the consumption data as they do on the Y axis on the left. But as it can be seen from the pic above, both the number of ticks and their position is different from the ones in the consumption axis. This is something that seems like a bug, as I’m using the same value (5) for the numberOfTicks prop. But is this just a feature that’s caused by the underlying d3 library? Please help me to understand how the Y axis scaling works 🙏 😄

Below a simplified code:

<View
  style={{
    height: 300,
    flexDirection: 'row',
  }}>
  <YAxis
    data={consumptionData}
    style={{ marginBottom: 20 }}
    numberOfTicks={5}
  />
  <View style={{ flex: 1 }}>
    <BarChart
      style={{ flex: 1 }}
      numberOfTicks={5}
      data={consumptionData}>
      <Grid />
    </BarChart>
    <LineChart
      style={{
        position: 'absolute',
        top: 0,
        left: 0,
        right: 0,
        bottom: 20,
      }}
      data={temperatureData}
      numberOfTicks={5}
    />
    <XAxis style={{ height: 20 }} data={consumptionData} />
  </View>
  <YAxis
    data={temperatureData}
    style={{ marginBottom: 20 }}
    numberOfTicks={5}
  />
</View>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
ronkotcommented, Jul 2, 2020

Thanks @ajacquierbret for insights and tips and @JesperLekland for your great work with this library. And what a coincidence that we’re building same kind of charts 😄

I’ll try to play with the parameters and also try the axis label formatting trick. Maybe I’ll also have to study a bit d3 😬 😅

0reactions
ronkotcommented, Aug 3, 2020

Back from the holidays… I’ll close this issue for now and try these tips when I’ll have again time to investigate this issue. Once again, thanks for help and this great library 💎

Read more comments on GitHub >

github_iconTop Results From Across the Web

I would like to have two y-axis and corresponding y-axis ticks ...
I have two variables which I normalized by a constant and plotted on y axis (left) against an independent variable on x-axis. Both...
Read more >
trouble aligning ticks for matplotlib twinx axes - Stack Overflow
The y-axes have different scales, but I want the ticks and grid to be aligned. I am pulling the data from excel files,...
Read more >
Y-axis tick marks not aligning when using two y-axes in tw line
First time poster here, so please bear with me. I'm using this data: * Example generated by -dataex-. To install: ssc install dataex...
Read more >
Why not to use two axes, and what to use instead
We believe that charts with two different y-axes make it hard for most people to intuitively make right statements about two data series....
Read more >
Customize X-axis and Y-axis properties - Power BI
In this tutorial, you'll learn many different ways to customize the X-axis and Y-axis of your visuals. Not all visuals have axes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found