ChartJs has encountered the issue of reaching the maximum stack call size, leading

I'm currently facing a challenge while trying to create a line graph using ChartJs to plot numerous points. The graph works perfectly fine when I have 600000000 values or less (6E8), but it fails to display anything beyond that threshold. My goal is to plot at least 50E8 values, but so far I haven't been able to find a solution in the ChartJs documentation regarding this issue. Below is the code I am working with:

    <div id="canvas-holder">
        <canvas id="myChart" width="800" height="300"></canvas>
    </div>
    <script>
        var options = {
        type: 'line',
        data: {
            labels: {{ labels | safe }},
            datasets: [{
                    label: 'Value',
                    data: {{ values | safe }},
                    backgroundColor: 'white',
                    borderWidth: 1,
                    order: 2
                },
                {
                    label: 'Peak value',
                    data: [{
                    x: {{ labels2[0] | safe }},
                    y: {{ values2[0] | safe }}
                    }, {
                    x: {{ labels2[1] | safe }},
                    y: {{ values2[1] | safe }}
                    }, {
                    x: {{ labels2[2] | safe }},
                    y: {{ values2[2] | safe }}
                    }],
                    backgroundColor: 'black',
                    borderWidth: 5,
                    pointRadius: 5,
                    showLine: false,
                    order: 1
                }
            ]
        },
        options: {
            responsive: true,
        scales: {
            xAxes: [{
                ticks: {
                    beginAtZero: true
                }
            }]
        }
    }
};

    var ctx = document.getElementById('myChart').getContext('2d');
    new Chart(ctx, options);

Answer №1

After some investigation, I discovered that the best approach was to limit the number of values passed in at once to less than 300k. To achieve this, I implemented a straightforward solution:

if len(my_list) > 300000:
    del my_list[::8]

You can adjust the threshold value as needed.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error encountered when attempting to insert data into a PostgreSQL database using Node.js and Sequelize

I'm currently using the node sequelize library to handle data insertion in a postgress database. Below is the user model defined in the Users.ts file: export class User extends Sequelize.Model { public id!: number; public name: string; public ...

I can't figure out why the callback function for my $.get() request is not being triggered when I send data to the Express

Could anyone help me understand why my callback function is not being called properly? $.get("http://localhost:8080/", msg, function(data) { alert("Data" + data); }); It seems like the server receives the reque ...

Unexpected behavior observed with callback function when inserting a query in Node.js

Having a minor issue with using the POST method and adding an INSERT. The functionality works correctly as shown below, but I am looking to implement a callback after the data has been inserted. Currently, the database is updated successfully, but I am una ...

Is there a way to ensure that my function does not return undefined and instead returns a specific value?

Currently, I am facing a roadblock while attempting to conquer the Rock-Paper-Scissors challenge proposed by The Odin Project. Some confusion arises as my function playRound seems to be returning undefined when executed. Any insights or assistance in res ...

"Trouble arises with the match() function in relation to email regex validation

After retrieving the HTML content from a website with my function, I am using String.prototype.match along with a regex rule to extract email addresses from that page. However, the issue is that I am receiving a line that matches the regex but does not con ...

Transforming the exterior designs in Angular

I am in the process of transitioning a product management admin site to Angular. Currently, all my views (such as the product list, detail view, and edit) are displayed inside an ng-view on my admin page, which is working well. However, I have a link for e ...

Retrieving JSON information from a nested array

I've noticed that this question has been asked frequently, but I haven't come across a case similar to mine. Here's the array printed out from a JSON response: Array ( [contents] => { "type": "XXXXXXXXXXXXXXX", "previous": " ...

Having trouble navigating to the end of a webpage while using Python for web scraping and Spotify's web player?

I am working on a Python program that can extract a list of track names from a Spotify playlist when given the link. Here is my current progress: from bs4 import BeautifulSoup from selenium import webdriver url="https://open.spotify.com/playlist/1xXEN6Uh ...

Ways to add elements to the DOM using jQuery from the local storage?

I'm facing a challenge where I have an input field and store the inputs in local storage. When I click on 'add', I want to immediately append the new inputs to my ul element. However, simply appending the current input won't work as it ...

Attempting to transfer a string variable into a JavaScript scope within an HTML document using handlebars-express

Struggling to pass a variable from server-side to client-side using handlebars-express... After searching through the content here for some time, I realize I might need some help. I've confirmed that the object passed is indeed of string type, but h ...

Building an HTML form to generate an array of objects by collecting form data

Hey there, I'm working on an HTML form in React that utilizes form action and FormData. However, when I extract the formData using my method, it shows a structure like this: https://i.stack.imgur.com/nzgLX.png My goal is to have an array of objects ...

Guide to building a seamless page without refreshes with the help of jquery, express, and handlebars

I need assistance with my express JS project. I am trying to set up two pages using NodeJS, incorporating handlebars as the template engine. My objective is to have the first page rendered using res.render('home'), and for the second page to be l ...

Enable a click event within an iFrame by clicking on an element in the parent document

I am attempting to trigger the click event of an element inside an iFrame (specifically a standard Twitter follow button) when clicking on an element within my main webpage. Below is the code snippet I have been experimenting with, but unfortunately it do ...

Vue JS - Unable to locate module (datepicker)

Today marks my first time delving into the world of vue.js, and as expected, I've encountered an error that has me stumped. I recently incorporated the v-md-date-range-picker module into my project: (. The setup instructions provided me with the f ...

Adjusting the position of the parent div by manipulating the bottom property

Is there a way to toggle the bottom property of a div when clicking its child anchor tag? <div class="nav" :class="{ 'full-width': isFullWidth }"> <a class="toggle-button" @click="toggleNav"><i class="fa fa-angle-down">< ...

What is the best way to eliminate duplicate elements from a randomly generated array?

Need help with this code: #include <stdio.h> #include <stdlib.h> int main() { char a[200], b = 0; int x; x = 100 + rand() % 200; for (int i = 0; i < x; i++) { a[i] = 'a' + rand() % 26; } for (int ...

Using Javascript to refresh an image and update a class within a DIV when another DIV is clicked

I have a code that is quite lengthy to share here, so I've created a demo on JSFiddle: http://jsfiddle.net/Emily92/5b72k225/ This particular code takes a random image and divides it into multiple sections based on the class applied to the div contain ...

What is the best way to call a JavaScript function within a PHP echo statement that outputs a <div> element?

Having trouble echoing this PHP code due to issues with single quotes, causing the HTML to end prematurely. Any suggestions on how to fix this? function button($conn){ $sql = "SELECT * FROM table"; $result= mysqli_query($conn, $sql); while($r ...

Is a shifting background image possible?

Can anyone shed some light on how the dynamic background image on this website is created? Is it a JavaScript plugin, a simple .gif, or something else entirely? Appreciate any insights! ...

Updating the "title" attribute dynamically using jQuery in real time

I have a span that displays data in a tooltip every second, fetched from the server: <span class="info tooltip" title="{dynamic content}"></span> To show the tooltip, I'm using the tooltipsy plugin: $('.tooltip').tooltipsy({ ...