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

[BUG] Category Scale misplaced #4060

Closed
martinzuern opened this issue Mar 22, 2017 · 4 comments
Closed

[BUG] Category Scale misplaced #4060

martinzuern opened this issue Mar 22, 2017 · 4 comments

Comments

@martinzuern
Copy link
Contributor

When creating a bubble chart, using a time and a category scale, the bubbles are placed wrong (one of them is even placed off the canvas)

Example: https://jsfiddle.net/martinzuern/skyd9kv2/8/

Expected Behavior

The bubbles should appear as specified in the data set.
E.g. when changing the axis to linear scale, the bubbles are displayed correctly:
screen shot 2017-03-22 at 18 07 54

Current Behavior

The bubbles are displayed in the wrong position and also off-canvas:
screen shot 2017-03-22 at 18 07 27

Possible Solution

Steps to Reproduce (for bugs)

var ctx = $('#chart-errors');
var bubbleChartData = {
  yLabels: [400, 404, 503],
  datasets: [{
    label: 'Errors',
    backgroundColor: 'red',
    borderColor: 'red',
    borderWidth: 1,
    data: [{
		"x": "2017-03-06T15:00:00.000Z",
		"y": 400,
		"quantity": 1,
		"r": 5
	}, {
		"x": "2017-03-14T03:00:00.000Z",
		"y": 503,
		"quantity": 1,
		"r": 5
	}, {
		"x": "2017-03-20T15:00:00.000Z",
		"y": 400,
		"quantity": 4,
		"r": 5
	}, {
		"x": "2017-03-20T15:00:00.000Z",
		"y": 404,
		"quantity": 1,
		"r": 5
	}]
  }]
};
var chart = new Chart(ctx, {
  type: 'bubble',
  data: bubbleChartData,
  options: {
    scales: {
      yAxes: [{
        type: 'category',
        position: 'left'
      }],
      xAxes: [{
        type: 'time',
      }]
    }
  }
});

Context

The chart displays clearly wrong results

Environment

  • Chart.js version: 2.4.0
  • Browser name and version: Chrome 56.0.2924.87
@etimberg
Copy link
Member

I feel like this is related to the fact that the category axis gets labels from the data.labels property.

@martinzuern
Copy link
Contributor Author

Also reproducible with version 2.5.0 (https://jsfiddle.net/martinzuern/4kb980qz/1/)

@martinzuern
Copy link
Contributor Author

Seems like getPixelForValue(value, index, datasetIndex, includeOffset) in src/scales/scale.category.js returns a wrong value here: When a string/integer (for the scale ticks) as value parameter is used, then the function returns the correct values. But when a Object is used, the returned values are incorrect.

@etimberg
Copy link
Member

Resolved in #4062

etimberg pushed a commit that referenced this issue Mar 27, 2017
* Fixed issue, that category scale shows data points misplaced. See #4060
* Cleaned code
* Fixed Irregular whitespace
* Fixed error in case value is undefined
* Verified that no error is thrown in case value === null
ericnkatz pushed a commit to ericnkatz/Chart.js that referenced this issue May 24, 2017
* Fixed issue, that category scale shows data points misplaced. See chartjs#4060
* Cleaned code
* Fixed Irregular whitespace
* Fixed error in case value is undefined
* Verified that no error is thrown in case value === null
roicos pushed a commit to roicos/Chart.js that referenced this issue Aug 21, 2017
* Fixed issue, that category scale shows data points misplaced. See chartjs#4060
* Cleaned code
* Fixed Irregular whitespace
* Fixed error in case value is undefined
* Verified that no error is thrown in case value === null
exwm pushed a commit to exwm/Chart.js that referenced this issue Apr 30, 2021
* Fixed issue, that category scale shows data points misplaced. See chartjs#4060
* Cleaned code
* Fixed Irregular whitespace
* Fixed error in case value is undefined
* Verified that no error is thrown in case value === null
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

2 participants