plotly / plotly/plotly.js

Colored and Styled Error Bars described incorrectly in docs

Open
#6,386 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P2
Dominant language
JavaScript
Stars
18.3k
Forks
2k
Avg merge
2d 12h
Merged PRs (30d)
28

Description

This error was reported by Martin Shell, the VP customer success at Taipy.

The error is located in Colored and Styled Error Bars.
In the example, the js code begins as follow:

function linspace(a,b,n) {
  return d3.range(n).map(function(i){return a+i*(b-a)/(n-1);});
}
x_theo = linspace(-4, 4, 100)
sincx = Math.sin(x_theo) / x_theo

(looks like someone translated this FROM python -- ironic as I am translating it TO python).
In any case, in the last line, x_theo is a js array and I think the coder was trying to get an array out, but this code results in sincx being set to NaN. Plotly js basically ignores sincx and the resulting chart is clearly not what is intended. You need to do something like:

sincx = x._theo.map(x=>Math.sin(x)/x)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open the JavaScript documentation section titled “Colored and Styled Error Bars” and inspect the example beginning with linspace and ending with the sincx calculation. Correct the array calculation so the example produces the intended error-bar chart, then verify the rendered example no longer contains NaN values.

Written by the indexing model from the issue text.

Assessment

Tech stack
d3, javascript
Domain
data-visualization, documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.