Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Chart Uplot example not showing up? #1

Open
AdamMarciniak opened this issue May 7, 2021 · 1 comment
Open

Chart Uplot example not showing up? #1

AdamMarciniak opened this issue May 7, 2021 · 1 comment

Comments

@AdamMarciniak
Copy link

AdamMarciniak commented May 7, 2021

I've got a Tab.Screen app with a bunch of screens and I've added the Uplot exmpla code in a file called "Chart.js" like so:

import React, {useState, useCallback, useEffect, useRef} from 'react';
import {UPlot} from '@dpwiese/react-native-canvas-charts/UPlot';

const opts = {
  title: 'My Chart',
  id: 'chart1',
  class: 'my-chart',
  width: 400,
  height: 600,
  series: [
    {},
    {
      show: true,
      spanGaps: false,
      label: 'RAM',
      value: (self, rawValue) => '$' + rawValue.toFixed(2),
      stroke: 'red',
      width: 1,
      fill: 'rgba(255, 0, 0, 0.3)',
      dash: [10, 5],
    },
  ],
};

const data = [
  [0, 100],
  [35, 71],
  [90, 15],
];

export default () => <UPlot opts={opts} data={data} />;

Than in my App.js file I use the chart like so:

<Tab.Screen name="Charts">{() => <Chart></Chart>}</Tab.Screen>

I know the component runs because I can put a console log into it and it works. But for some reason it gives me a blank screen when I go to that page. Any idea what could be wrong?

EDIT:

It looks like the JS in the <script> tags in the index.html file isn't being run? I tried doing a console.log from there and nothing happens.

@mountain-hiker
Copy link
Contributor

I created a vanilla react native project from scratch to test this and I am having the same issue.

@AdamMarciniak were you able to get it working?

I can confirm I can console.log from the UPlot index.js but when I console.log from the main index.js I get no output.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants