Creating a visually appealing gantt chart in React Native using the react-google-charts library - here's how!

These are the current packages I am using:


react-google-charts 1.5.5
react 16.0.0-beta.5
react-native https://github.com/expo/react-native/archive/sdk-22.0.1.tar.gz

I am currently working on rendering a Gantt Chart and you can find an example here and another one here.

Below is the code snippet I'm using:


import React, { Component } from 'react';
import { View, ScrollView, Text } from 'react-native';
import { Card, Avatar } from 'react-native-elements';
import { Chart } from 'react-google-charts';

class ScheduleScreen extends Component {
    constructor(props) {
        super(props);
        this.state = {
            rows: [],
            columns: []
        };
    }

    onButtonPressClose = () => {
        this.props.navigation.navigate('Home');
    }

    render() {
        return (
            <View>
            <ScrollView>
                <Card title="Schedule">
                    <Chart
                        graph_id="ganttchart"
                        chartType="Gantt"
                        columns={this.state.columns}
                        rows={this.state.rows}
                        chartPackages={['gantt']}
                        width="100%" height="9999px"
                    />
                </Card>
            </ScrollView>
            <View style={styles.buttonBackContainer}>
            <Avatar
                medium
                rounded
                backgroundColor="#66ff33"
                icon={{ name: 'chevron-left' }}
                onPress={this.onButtonPressClose}
            />
            </View>
            </View>
        );
    }
}

const styles = {
    buttonBackContainer: {
        position: 'absolute',
        top: 20,
        left: 20,
        right: 20,
        flexDirection: 'row',
        justifyContent: 'flex-start'
    }
};

export default ScheduleScreen;

An error occurred when I started the app. Here's the error message:


Body:
{"message":"TransformError:
/Users/ling/workspace/chartapp/node_modules/react-google-charts/lib/index.js:
[BABEL]/Users/ling/workspace/chartapp/node_modules/react-google-
charts/lib/index.js:Unknown 
option:/Users/ling/workspace/chartapp/node_modules/react-google-
charts/react/react.js.Children.Check out http://babeljs.io/docs/usage/options/
for more information about options.....

Can anyone help me troubleshoot this error? I have checked for lint errors in the code but couldn't find any.

Thank you for any assistance or suggestions provided.

Answer №1

The error message you posted seems to be specifically related to issues with react-google-charts.

It appears that react-native may not be supported by react-google-charts, as there are no mentions of it on their npm page. I came across a similar issue on their GitHub repository, where someone asked if it would work with react native. You can check out the discussion here. Alternatively, you might want to explore other chart libraries for react native by referring to this question on Stack Overflow.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can a key event be activated on the DOM Window using Javascript or JQuery?

Can a key event be triggered on the DOMWindow or DOMDocument using JavaScript? I am developing a browser extension to interact with a website that has shortcut key events, similar to those in GMail. While I have come across other methods for triggering key ...

Displaying images in a React app using Node.js

I receive the image from the user as formdata Here is how I structured the Schema for the image The Image has been successfully stored in Monogodb This is my process of fetching image information using Axios I implement code for rendering the image on the ...

Steps for extracting URL parameters from AWS API Gateway and passing them to a lambda function

After successfully setting up my API gateway and connecting it to my lambda function, I specified the URL as {id} with the intention of passing this parameter into the lambda. Despite numerous attempts using both the default template and a custom one for ...

Issue encountered while compiling Next Js in Expo

Encountering an error while attempting to utilize Expo components in my Next.js project. I am using Expo with Next.js for web development and aiming to have both platforms share the same components. However, I'm facing this specific error: Module pa ...

Issue with React not displaying JSX when onClick Button is triggered

I've recently started learning React and I'm facing a problem that I can't seem to figure out. I have a basic button, and when it's clicked, I want to add another text or HTML element. While the console log statement is working fine, th ...

I can't figure out why my code isn't functioning properly. My goal is to have a PDF file generated when the submit button is clicked on a form, and for a

Hello everyone, I am new to the world of programming, but I have been assigned a project that involves using jQuery, JavaScript, html2pdf, and Bootstrap 5. I seem to be facing some issues with my code. Can someone please help me identify what's wron ...

`A brief disruption in loading the visual style of Google Maps`

Using the Ionic Framework, AngularJS, and Google Maps API, I encountered an irritating issue with my mobile app. Every time the map loads, there is a noticeable delay in loading the map style. This delay is particularly problematic as my map style converts ...

Encourage (or kindly request) the user to refresh the browser

I manage a website that heavily relies on javascript and ajax functionality. I have found ways to make users refresh their browsers upon initial loading, but what about after they have already been using the site? I am looking to improve the speed of the ...

How can the horizontal scroll bar width be adjusted? Is it possible to create a custom

Within my div, I have implemented multiple cards that scroll horizontally using the CSS property: overflow-x: scroll; This setup results in a horizontal scrollbar appearing under the div, which serves its purpose. However, I would prefer a customized scr ...

Falling rain animation in JavaScript

I'm a beginner in the world of JavaScript and I'm trying to create a div on a webpage with a rain effect. I've managed to generate random blue points within the div, but I'm struggling to make them move downwards. Here's the code I ...

Guide on decrypting a file encrypted with C# using Node JS

I currently have encrypted files in C# using DES and PKCS7 encryption. My objective is to decrypt these files in Node JS. The decryption code in C# that I am using appears like this: public string SSFile_Reader( string fileToDecrypt ) { DESCryptoService ...

50% greater than the highest of the other values

I'm a beginner when it comes to JavaScript and I need help setting a maximum value of 50% of the selling price. Can someone offer guidance? The fields I have are called "sale_price" and "discount". click here for image description What is the best ...

What is the best way to display data retrieved through Ajax, jQuery, and JavaScript on an HTML page

I have successfully used the script below to fetch data from an api endpoint and populate my charts. Now, I want not only to display the data in my charts but also directly output it in my HTML code using something like the document.write() function. How ...

The problem arises when Angular's $interval function is not recognized

Despite the possibility of this being considered a duplicate, none of the related topics have provided a solution to my simple date count down directive: class Clock { constructor() { this.restrict = 'AC'; this.replace = true ...

Using a Do/While loop in combination with the setTimeout function to create an infinite loop

Having trouble with this script. The opacity transition works fine, but there seems to be an issue with the loop causing it to run indefinitely. My goal is to change the z-index once the opacity reaches 0. HTML <div class="ribbon_services_body" id="ri ...

Possible solutions for AngularJS using ng- tags

I absolutely love incorporating AngularJs into my Multiple Pages Laravel Application. However, using the Laravel Blade Template Engine has made me reconsider adding Angular Tags to clutter my blade templates. For instance <div ng-controller="TodoCont ...

Where the package.json file resides

Is there a designated location for the package.json file in a project, like within the project directory? Where should the package.json file be located in a multi-component project? What is the significance of having version 0.0.0 in th ...

Loading tabs dynamically in Angular 2 based on header click event

I successfully created a custom tab component using Angular 2, and it is functioning well with the following usage: <us-tab-verticle> <vtab-content [tabTitle]="'Basic Information'"><basic-info> </basic-info></vtab- ...

Enhance your Wordpress posts with a custom pop-up form for each individual button

On a page, there are various custom posts being displayed with the post type 'property', each containing a button: <button class="btn btn-primary">Submit Offer</button> This button is looped and shown below every post. What ...

Transforming a string into an object

I've been working on this code where my aim is to convert a string into an object and then display the data from an ajax call. However, it appears that using the string value in this way is not functioning as expected. var string = "first: 'Geor ...