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

Bar Chart - logarithmic type if all numbers are zero browser crashes "Out of memory" #4572

Closed
neway003 opened this issue Jul 27, 2017 · 4 comments

Comments

@neway003
Copy link

neway003 commented Jul 27, 2017

For the below bar chart code, type:'logarithmic',
If all the vehicle count are zero in data array bowser goes to Out of memory exception ,
If i remove type:'logarithmic' it works.

  1. chrome browser (Version 59.0.3071.115 (Official Build) (64-bit)) stops with Out of memory exception.
    scr

  2. Firefox (Version 54.0.1 (32-bit)) not showing any error or graph.

  3. IE (Version 10.0.9200.16384) not showing any error or graph.

  4. Opera (Version 46.0.2597.57 (PGO)) Also stops with Out of memory exception.
    scro

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script>-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.min.js"></script>
<div id="GateChartHolder" style="display: table; width: 100%; height: 400px;"></div>
<script type="text/javascript">
$(document).ready(function () {
	data = [{
		"LaneTitle": "Basement Entrance",
		"VehicleCount": 0
	}, {
		"LaneTitle": "Drop off area",
		"VehicleCount": 0
	}, {
		"LaneTitle": "Parking Entrance",
		"VehicleCount": 0
	}, {
		"LaneTitle": "Parking Exit",
		"VehicleCount": 0
	}];

	$("#GateChartHolder").html("<canvas id=\"gateChart\" width=\"400\" height=\"200\"></canvas>");
	var ctx = document.getElementById("gateChart");
	var vlbl = [];
	var vcount = [];
	$.each(data, function (k, v) {
		vlbl.push(v.LaneTitle);
		vcount.push(v.VehicleCount);
	});

	var myChart = new Chart(ctx, {
		type: 'bar',
		data: {
			labels: vlbl,
			datasets: [{
				label: 'Vehicle Count',
				data: vcount,
				borderWidth: 1
			}]
		},
		options: {
			scales: {
				yAxes: [{
					type: 'logarithmic',
					ticks: {
						callback: function (tick, index, ticks) {
							console.log(tick + "-" + index + "-" + ticks);
							return tick.toLocaleString();
						},
						min: 0
					},
					display: false
				}]
			}
		}
	});
});
</script>
@etimberg
Copy link
Member

@neway003 could you try v2.6.0 instead of v.2.5.0? I recall seeing and fixing something similar to this then

@neway003
Copy link
Author

Same condition on v2.6.0

@jcopperfield
Copy link
Contributor

jcopperfield added a commit to jcopperfield/Chart.js that referenced this issue Nov 16, 2017
 - issue chartjs#4572: logarithmic type if all numbers are zero browser crashes "Out of memory"
 - issue chartjs#4703: [BUG] Browser unresponsive on bubble chart with logarithmic axes
etimberg pushed a commit that referenced this issue Dec 12, 2017
- issue #4572: logarithmic type if all numbers are zero browser crashes "Out of memory"
 - issue #4703: [BUG] Browser unresponsive on bubble chart with logarithmic axes
@etimberg
Copy link
Member

Done in #4959

@etimberg etimberg added this to the Version 2.8 milestone Dec 12, 2017
yofreke pushed a commit to yofreke/Chart.js that referenced this issue Dec 30, 2017
- issue chartjs#4572: logarithmic type if all numbers are zero browser crashes "Out of memory"
 - issue chartjs#4703: [BUG] Browser unresponsive on bubble chart with logarithmic axes
exwm pushed a commit to exwm/Chart.js that referenced this issue Apr 30, 2021
- issue chartjs#4572: logarithmic type if all numbers are zero browser crashes "Out of memory"
 - issue chartjs#4703: [BUG] Browser unresponsive on bubble chart with logarithmic axes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants