financeDiscontinuousScale- Help with specifying an initial index -persisting lines
See original GitHub issueI’m trying use discontinuousTimeScaleProviderBuilder() to take advantage of persisting the position of a line. I found that I could maybe use the indexCalculator, and just persist a ‘zero-day’ value, and maintain the same position throughout the lifetime of the persistance of a chart.
Eventually I get a
financeDiscontinuousScale.js:85 Uncaught TypeError: Cannot read property 'level' of undefined
Here is some code
//we should find the 0-day in our data and work from there
//zeroDay is a string, we need to convert to a date and find it in our inputData
var {data: inputData,defaultBarsDisplayed,zeroDay}=props;
var barsDisplayed=defaultBarsDisplayed||100
var zeroDayDate=new Date(zeroDay)
var zeroIndex = inputData.findIndex(function (x) {
return x.date.getTime() === zeroDayDate.getTime();
});
var initialIndex=-zeroIndex+inputData.length-barsDisplayed
var indexCalculator = discontinuousTimeScaleProviderBuilder().initialIndex(initialIndex).indexCalculator();
var { index, interval } = indexCalculator(dataToCalculate.slice(-barsDisplayed));
var xScaleProvider = discontinuousTimeScaleProviderBuilder().withIndex(index).withInterval(interval)
var { data: stateData, xScale, xAccessor, displayXAccessor } = xScaleProvider(dataToCalculate.slice(-barsDisplayed))
return { stateData, xScale, xAccessor, displayXAccessor }
Some vars at the breakpoint
statedata[0],statedata[1]
financeDiscontinuousScale (j=342, which is out of bounds, but it should be 171, which I specified )
Is there a potential way around the Math.max, or a better way? https://github.com/rrag/react-stockcharts/blob/master/src/lib/scale/financeDiscontinuousScale.js#L76
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think I figured out my problem, I can’t do arithmetic! 😃
@itsjimbo sorry I missed your last comment
j
iterates the integer values inside the xdomain so for e.g. if the xDomain is from say -200 to 300j
iterates between these values, the important part to remember here is that the scale always needs the complete index. Even if you append more data to the beginning or end, you need a new index [] for the complete data. To put it differently, index [].length and data[].length must always matchi
always iterates between 17 to 0 (atleast for now)I dont see any changes needed in that block of code.
It does get confusing when you want to lazy load data before the 0 index, but I see that as a documentation problem.