Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

scrollToPosition with big negative value and when no data breaks the chart #889

Closed
timocov opened this issue Nov 12, 2021 · 0 comments · Fixed by #891
Closed

scrollToPosition with big negative value and when no data breaks the chart #889

timocov opened this issue Nov 12, 2021 · 0 comments · Fixed by #891
Assignees
Labels
bug Unexpected problem or unintended behavior.
Milestone

Comments

@timocov
Copy link
Contributor

timocov commented Nov 12, 2021

Lightweight Charts Version: 3.7.0

Steps/code to reproduce:

function generateData() {
	const res = [];
	const time = new Date(Date.UTC(2018, 0, 1, 0, 0, 0, 0));
	for (let i = 0; i < 100; ++i) {
		res.push({
			time: time.getTime() / 1000,
			value: i,
		});

		time.setUTCDate(time.getUTCDate() + 1);
	}
	return res;
}

function runTestCase(container) {
	const chart = LightweightCharts.createChart(container);
	chart.timeScale().scrollToPosition(-100000);

	chart.timeScale().subscribeVisibleTimeRangeChange(() => console.log('range changed'));

	return new Promise(resolve => {
		setTimeout(() => {
			const mainSeries = chart.addLineSeries();
			mainSeries.setData(generateData());
			resolve();
		}, 300);
	});
}

Actual behavior:

lightweight-charts.standalone.development.js:168 Uncaught Error: Value is null
    at ensureNotNull (lightweight-charts.standalone.development.js:168)
    at TimeScale._internal_timeRangeForLogicalRange (lightweight-charts.standalone.development.js:3034)
    at TimeScale._internal_visibleTimeRange (lightweight-charts.standalone.development.js:3025)
    at TimeScaleApi.getVisibleRange (lightweight-charts.standalone.development.js:11254)
    at TimeScaleApi._private__onVisibleBarsChanged (lightweight-charts.standalone.development.js:11358)
    at lightweight-charts.standalone.development.js:1507
    at Array.forEach (<anonymous>)
    at Delegate._internal_fire (lightweight-charts.standalone.development.js:1507)
    at TimeScale._private__setVisibleRange (lightweight-charts.standalone.development.js:3477)
    at TimeScale._private__updateVisibleRange (lightweight-charts.standalone.development.js:3383)

Expected behavior:

No errors.

@timocov timocov added the bug Unexpected problem or unintended behavior. label Nov 12, 2021
@timocov timocov added this to the 3.8 (optional) milestone Nov 12, 2021
@timocov timocov self-assigned this Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected problem or unintended behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant