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.

Add text over AreaChart

See original GitHub issue

What is the problem?

I want to add Text/label over the areachart region. But when I add Text from react-native-svg to the decorators method, the app crashes without error. If I remove it, the app works fine. I am looking to generate something like this: screen shot 2018-04-05 at 7 29 56 pm

  • iOS
  • Android

Versions: “react-native”: “0.52.0”, “react-native-svg”: “^6.3.1”, “react-native-svg-charts”: “^4.2.0”,

Code to reproduce

// put code here
import React from 'react';
import { Path, Circle, Line, G, Text } from 'react-native-svg'
import { AreaChart } from 'react-native-svg-charts'
import * as shape from 'd3-shape'

const Chart = props => (
    <AreaChart
        style={{height: 100}}
        showGrid={false}
        data={props.item}
        contentInset={{top: 30, bottom: 30}}
        curve={shape.curveNatural}
        svg={{fill: '#BFE5EC'}}
        renderDecorator={({ x, y, index, value }) => (
            <G key={index}>
              <Circle
                  style={{ zIndex: 10}}
                  cx={x(index)}
                  cy={y(value)}
                  r={4}
                  strokeWidth={2}
                  stroke={'#20AAC3'}
                  fill="white"
              />
              <Line
                  x1={x(index)}
                  y1={"250"}
                  x2={x(index)}
                  stroke="#BFE5EC"
                  strokeWidth="0.3"
              />
              <Text
                  stroke="#383834"
                  fontSize="12"
                  x={50}
                  y={50}
                  textAnchor="middle"
              >Test</Text>
            </G>
        )}
        extras={[
          ({line}) => (
              <Path
                  key={'line'}
                  d={line}
                  strokeWidth={2}
                  stroke={'#20AAC3'}
                  fill={'none'}
              />
          ),
        ]}
    />
);

export default Chart;

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JesperLeklandcommented, Apr 5, 2018

Ugh, I hate Expo… I’ll try to run your example when I get the chance and see if I can find what’s going on

0reactions
Neha3011commented, Apr 10, 2018

@JesperLekland That doesn’t work either. 😦 I will find a work around. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add text box to chart in Excel? - ExtendOffice
Generally, you can click Insert tab and select Text Box to insert a text box into Excel, so does inserting text boxes to...
Read more >
Adding Text Boxes to Charts in Excel - Causal
To add a text box to a bar chart, first click on the bar that you want to annotate. Then, click the "Insert"...
Read more >
Add Text to Point on Control Chart - QI Macros
Click on the point: · Select the QI Macros Chart menu and select Add Text to Point: · A window will open with...
Read more >
Excel Charts: Is it possible to add specific text to the bars on a ...
Select the data labels with one click, then with a second single click select a single data label. Type a = sign into...
Read more >
How to Add Text Labels in Excel Chart (4 Quick Methods)
1. Insert Text Labels Manually in Excel Chart from Another Column · Firstly, we need to right-click on the data series. · Then,...
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