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.

Wired splines representation when stable data

See original GitHub issue

Hi @osdnk,

I’m doing some tests with stable data (without variation) and the graph looks weird:

image

The line dotted in purple is the path of react-native-animated-charts (I don’t know why it does those splines), and on the other hand the chart in the background is the representation of victory charts using the same dataset.

Here I attach dataset and ChartPathProvider configuration, it would be very useful if you can help me @osdnk.

const data = [
  {
    "x": 0,
    "y": 138.35,
  },
  {
    "x": 1,
    "y": 138.35,
  },
  {
    "x": 2,
    "y": 138.35,
  },
  {
    "x": 3,
    "y": 138.35,
  },
  {
    "x": 4,
    "y": 138.35,
  },
  {
    "x": 5,
    "y": 138.35,
  },
  {
    "x": 6,
    "y": 138.35,
  },
];
const points = React.useMemo(
  () => ({
    points: interpolator({
      data,
      includeExtremes: true,
      range: 300, // ~1 year of working days
    }),
    smoothingStrategy: 'bezier',
  }),
  [data]
);
<ChartPathProvider data={points}>
  <ChartPath height={SIZE / 2} stroke="yellow" width={SIZE} />
</ChartPathProvider>

Thanks

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
osdnkcommented, Oct 27, 2020

Hey, many thanks. Let me quickly take a look

1reaction
osdnkcommented, Oct 27, 2020

Hey, Use the newest version and adjust your code by adding y bounds:

const data = [
  {
    "x": 0,
    "y": 138.35,
  },
  {
    "x": 1,
    "y": 138.35,
  },
  {
    "x": 2,
    "y": 138.35,
  },
  {
    "x": 3,
    "y": 138.35,
  },
  {
    "x": 4,
    "y": 138.35,
  },
  {
    "x": 5,
    "y": 138.35,
  },
  {
    "x": 6,
    "y": 138.35,
  },
];
const points = React.useMemo(
  () => ({
    points: interpolator({
      data,
      includeExtremes: true,
      range: 300, // ~1 year of working days
      yRange: [136, 140] // ADD THIS!
    }),
    smoothingStrategy: 'bezier',
  }),
  [data]
);
<ChartPathProvider data={points}>
  <ChartPath height={SIZE / 2} stroke="yellow" width={SIZE} />
</ChartPathProvider>
Read more comments on GitHub >

github_iconTop Results From Across the Web

56 SPLINES AND GEOMETRIC MODELING
INTRODUCTION. Piecewise polynomials of fixed degree and continuously differentiable up to some order are known as splines or finite elements.
Read more >
Curves and Splines in CAD - Wirebiters
As a result, irregular curves are represented by a combination of starting/ending points, derivative data, and hull shape points.
Read more >
Spline Surface - an overview | ScienceDirect Topics
NURBS surfaces exported by CAD systems to represent the surface of the solid are bivariate vector valued piecewise rational functions that are defined...
Read more >
Spline approximation-based data compression for sensor ...
A lossy but error-bounded sensor array data compression algorithm is proposed, in which the major part of the sensor array data are approximated ......
Read more >
A review of spline function procedures in R
A polynomial spline such as a cubic or a B-spline, can be erratic at the boundaries of the data. To address this issue,...
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