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.

Vertical lines don't show

See original GitHub issue

VERTICAL doesn’t show vertical lines. HORIZONTAL works. BOTH shows just horizontal lines.

Vertical line is shown only at x=0. Reproducible example:

import React from 'react'
import { View, StyleSheet } from 'react-native';
import { Path } from 'react-native-svg'
import { AreaChart, Grid, Line, XAxis, YAxis } from 'react-native-svg-charts'
import * as shape from 'd3-shape'

class AreaChartExample extends React.PureComponent {

    render() {

       const data = [ 50, 10, 40, 95, -4, -24, 85, 91, 35, 53, -53, 24, 50, -20, -80 ]
        // const data2 = Array(data.length).fill(4);
        const Outline = ({ line }) => (
            <Path
                key={'line'}
                d={line}
                stroke={'rgb(134, 65, 244)'}
                fill={'none'}
            />
        )

        const xAxisHeight = 30
        const verticalContentInset = { top: 10, bottom: 10 }
        const axesSvg = { fontSize: 10, fill: 'grey', fontFamily: "Verdana" };

        return (
          <View
            style={ {
              height: 200,
              padding: 20,
              margin: 20,
              flexDirection: 'row',
              borderRadius: 5,
              shadowOffset: {width: 0, height: 2},
              shadowRadius: 5,
              shadowOpacity: 0.3,
            } }
          >
            <YAxis
                data={data}
                style={ { marginBottom: xAxisHeight } }
                contentInset={ verticalContentInset }
                svg={axesSvg}
            />
            <View style={{ flex: 1, marginLeft: 10 }}>
              <AreaChart
                  style={{ flex: 1 }}
                  // style={ StyleSheet.absoluteFill }

                  data={data}
                  contentInset={ verticalContentInset }
                  curve={shape.curveNatural}
                  svg={{ fill: 'rgba(134, 65, 244, 0.2)' }}
              >
                   <Grid
                    svg={{strokeDasharray: [6, 8]}}
                  />
                  <Grid
                    svg={{strokeDasharray: [6, 8]}}
                    direction={ Grid.Direction.VERTICAL }
                    belowChart={ false }
                  />
                  <Outline/>
              </AreaChart>
              <XAxis
                style={{ marginHorizontal: -10, height: xAxisHeight }}
                data={data}
                formatLabel={(value, index) => index}
                contentInset={{ left: 10, right: 10 }}
                svg={axesSvg}
              />
            </View>
          </View>
        )
    }
}

export default AreaChartExample

Same issue as here: https://github.com/JesperLekland/react-native-svg-charts/issues/249

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:5
  • Comments:5

github_iconTop GitHub Comments

1reaction
mikeislearningcommented, Oct 14, 2021

Struggled with this issue for a while, here’s my solution. I used xPositionModifier to place the grid line in the centre of each bar instead of bordering it.

  const VerticalGrid = ({ x, bandwidth, data }) => {
    const xPositionModifier = bandwidth / 2 - bandwidth;
    return (
      <G>
        {data.map((_, index) => {   
          return (
            <Line
              key={index}
              strokeDasharray="3, 4"
              y1={'0.5%'}
              y2={'96%'}
              x1={x(index)r}
              x2={x(index)}
              stroke={rgba(0,0,0,0.2)}
            />
          );
        })}
      </G>
    );
  };
1reaction
M4FFScommented, Jul 22, 2021

Still an issue two years on

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Fix The Vertical Lines On Your Monitor Screen?
Generally, this issue occurs when different components of the connection channel between the monitor and PC do not function properly. Loosely ...
Read more >
Fix Vertical Lines on Laptop Screen. Easily! - Driver Easy
If you ever have the vertical line on laptop screen issue, don't worry. ... Right-click on the empty area of your desktop and...
Read more >
Vertical lines on screen - Microsoft Community
To narrow down the issue, kindly go to BIOS and check to see if the vertical lines are persists or not. If they...
Read more >
What Are the Causes of Fine Vertical Lines When Printing Low ...
Printer cleanliness and ink supply problems can cause fine vertical lines to appear in printed images; however, low resolution prints present additional ...
Read more >
Vertical line does not show in geom_boxplot - Stack Overflow
In this answer: I've created a much bigger sample; I'm using yearmonth from tsibble for simplicity; I've solved the issue with the vertical...
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