Skip to content

Uncaught Error: Value is null #2044

@zbinlin

Description

@zbinlin

Lightweight Charts™ Version: 5.1.0

** Reproduction conditions: **

  • When updating data, the new data has fewer data points than the original data.
  • timeScale options fixLeftEdge and fixRightEdge set to true.
  • More than two Series are add.
  • An error is triggered when updating one Series, then updating Options, and then updating another Series.
  • The error is triggered when updating data while the mouse cursor is hovering over a data point in a Series.

Steps/code to reproduce:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title></title>
		<style>
			#container {
				height: 500px;
			}
		</style>
</head>
<body>
	<div id="container"></div>
	<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/lightweight-charts.standalone.development.min.js"></script>
	<script>
const chart = LightweightCharts.createChart(document.getElementById('container'), {
    timeScale: {
        fixLeftEdge: true,
        fixRightEdge: true,
    },
});

const lineSeries1 = chart.addSeries(LightweightCharts.LineSeries, {});
const line1 = [ { "time": 1765929600, "value": -935013, }, { "time": 1766016000, "value": -869556, }, { "time": 1766102400, "value": -86550, }, { "time": 1766361600, "value": -560869, }, { "time": 1766448000, "value": -1116945, }, { "time": 1766534400, "value": -1641401, }, { "time": 1766620800, "value": -3506533, }, { "time": 1766707200, "value": 1439267, }, { "time": 1766966400, "value": -968063, }, { "time": 1767052800, "value": -994184, }, { "time": 1767139200, "value": 67111, }, { "time": 1767571200, "value": -3436334, }, { "time": 1767657600, "value": 579613, }, { "time": 1767744000, "value": -3873564, }, { "time": 1767830400, "value": 959572, }, { "time": 1767916800, "value": 196371, } ]
const line2 = [ { "time": 1765929600, "value": 34524, }, { "time": 1766016000, "value": 0, }, { "time": 1766102400, "value": 0, }, { "time": 1766361600, "value": 0, }, { "time": 1766448000, "value": 0, }, { "time": 1766534400, "value": -1820847, }, { "time": 1766620800, "value": 0, }, { "time": 1766707200, "value": 2013000, }, { "time": 1766966400, "value": 0, }, { "time": 1767052800, "value": 0, }, { "time": 1767139200, "value": 0, }, { "time": 1767571200, "value": -629540, }, { "time": 1767657600, "value": -1511852, }, { "time": 1767744000, "value": 0, }, { "time": 1767830400, "value": 0, }, { "time": 1767916800, "value": 0, } ]
lineSeries1.setData(line1);
const lineSeries2 = chart.addSeries(LightweightCharts.LineSeries, {});
lineSeries2.setData(line2);

window.addEventListener("keydown", (e) => {
    if (e.code === "Space") {
        const line11 = [ { "time": 1766534400, "value": 1346386, }, { "time": 1766620800, "value": 1035720, }, { "time": 1766707200, "value": 727577, }, { "time": 1766966400, "value": 416207, }, { "time": 1767052800, "value": 627531, }, { "time": 1767139200, "value": -1903334, }, { "time": 1767571200, "value": -7587891, }, { "time": 1767657600, "value": -1974835, }, { "time": 1767744000, "value": 13016455, }, { "time": 1767830400, "value": -1043809, }, { "time": 1767916800, "value": -1939719, } ]
        lineSeries1.setData(line11);
        lineSeries1.applyOptions({});
        const line22 = [ { "time": 1766534400, "value": 17774, }, { "time": 1766620800, "value": 0, }, { "time": 1766707200, "value": 0, }, { "time": 1766966400, "value": -266092, }, { "time": 1767052800, "value": 2871856, }, { "time": 1767139200, "value": -1188272, }, { "time": 1767571200, "value": -6799132, }, { "time": 1767657600, "value": 2891220, }, { "time": 1767744000, "value": 2346381, }, { "time": 1767830400, "value": 395989, }, { "time": 1767916800, "value": -448598, } ]
        lineSeries2.setData(line22);
    }
});

chart.timeScale().fitContent();
	</script>
</body>
</html>
  1. hover the series data point
  2. key press Space

Actual behavior:

Uncaught Error: Value is null
    s lightweight-charts.standalone.development.js:130
    Line lightweight-charts.standalone.development.js:2854
    _internal_barStyle lightweight-charts.standalone.development.js:2882
    _internal__items lightweight-charts.standalone.development.js:12066
    _internal__updateOptions lightweight-charts.standalone.development.js:12064
    _private__makeValid lightweight-charts.standalone.development.js:12087
    _internal_renderer lightweight-charts.standalone.development.js:12060
    yt lightweight-charts.standalone.development.js:5587
    Tt lightweight-charts.standalone.development.js:5619
    _internal_setAndSaveCurrentPosition lightweight-charts.standalone.development.js:6933
    _internal_updateCrosshair lightweight-charts.standalone.development.js:6961
    _internal_recalculateAllPanes lightweight-charts.standalone.development.js:7005
    _internal_setRightOffset lightweight-charts.standalone.development.js:6053
    _private__doFixLeftEdge lightweight-charts.standalone.development.js:6549
    _internal_setBaseIndex lightweight-charts.standalone.development.js:6153
    _internal_updateTimeScale lightweight-charts.standalone.development.js:6989
    _private__sendUpdateToChart lightweight-charts.standalone.development.js:13297
    _internal_applyNewData lightweight-charts.standalone.development.js:13159
    setData lightweight-charts.standalone.development.js:12753
    <anonymous> index.html:38
    EventListener.handleEvent* index.html:30
lightweight-charts.standalone.development.js:130:19
    s lightweight-charts.standalone.development.js:130
    Line lightweight-charts.standalone.development.js:2854
    _internal_barStyle lightweight-charts.standalone.development.js:2882
    _internal__items lightweight-charts.standalone.development.js:12066
    map self-hosted:175
    _internal__updateOptions lightweight-charts.standalone.development.js:12064
    _private__makeValid lightweight-charts.standalone.development.js:12087
    _internal_renderer lightweight-charts.standalone.development.js:12060
    yt lightweight-charts.standalone.development.js:5587
    Tt lightweight-charts.standalone.development.js:5619
    _internal_setAndSaveCurrentPosition lightweight-charts.standalone.development.js:6933
    _internal_updateCrosshair lightweight-charts.standalone.development.js:6961
    _internal_recalculateAllPanes lightweight-charts.standalone.development.js:7005
    _internal_setRightOffset lightweight-charts.standalone.development.js:6053
    _private__doFixLeftEdge lightweight-charts.standalone.development.js:6549
    _internal_setBaseIndex lightweight-charts.standalone.development.js:6153
    _internal_updateTimeScale lightweight-charts.standalone.development.js:6989
    _private__sendUpdateToChart lightweight-charts.standalone.development.js:13297
    _internal_applyNewData lightweight-charts.standalone.development.js:13159
    setData lightweight-charts.standalone.development.js:12753
    <anonymous> index.html:38
    (Async: EventListener.handleEvent)
    <anonymous> index.html:30


Uncaught Error: Value is null
    s lightweight-charts.standalone.development.js:130
    Line lightweight-charts.standalone.development.js:2854
    _internal_barStyle lightweight-charts.standalone.development.js:2882
    _internal__items lightweight-charts.standalone.development.js:12066
    _internal__updateOptions lightweight-charts.standalone.development.js:12064
    _private__makeValid lightweight-charts.standalone.development.js:12087
    _internal_renderer lightweight-charts.standalone.development.js:12060
    yt lightweight-charts.standalone.development.js:5587
    Tt lightweight-charts.standalone.development.js:5619
    _internal_setAndSaveCurrentPosition lightweight-charts.standalone.development.js:6933
    _internal_updateCrosshair lightweight-charts.standalone.development.js:6961
    _internal_recalculateAllPanes lightweight-charts.standalone.development.js:7005
    _internal_setPaneHeight lightweight-charts.standalone.development.js:6764
    _private__adjustSizeImpl lightweight-charts.standalone.development.js:11178
    _private__syncGuiWithModel lightweight-charts.standalone.development.js:11379
    _private__updateGui lightweight-charts.standalone.development.js:11331
    _private__drawImpl lightweight-charts.standalone.development.js:11257
    _private__drawRafId lightweight-charts.standalone.development.js:11319
    _private__invalidateHandler lightweight-charts.standalone.development.js:11313
    _private__invalidate lightweight-charts.standalone.development.js:7197
    _internal_lightUpdate lightweight-charts.standalone.development.js:6651
    _internal_recalculate lightweight-charts.standalone.development.js:5453
    _internal_recalculatePane lightweight-charts.standalone.development.js:6993
    _internal_setData lightweight-charts.standalone.development.js:3515
    _private__sendUpdateToChart lightweight-charts.standalone.development.js:13298
    _private__sendUpdateToChart lightweight-charts.standalone.development.js:13298
    _internal_applyNewData lightweight-charts.standalone.development.js:13159
    setData lightweight-charts.standalone.development.js:12753
    <anonymous> index.html:33
    EventListener.handleEvent* index.html:30
lightweight-charts.standalone.development.js:130:19

Expected behavior:

No Error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnexpected problem or unintended behavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions