{"action":"closed","issue":{"url":"https://api.github.com/repos/highcharts/highcharts/issues/7463","repository_url":"https://api.github.com/repos/highcharts/highcharts","labels_url":"https://api.github.com/repos/highcharts/highcharts/issues/7463/labels{/name}","comments_url":"https://api.github.com/repos/highcharts/highcharts/issues/7463/comments","events_url":"https://api.github.com/repos/highcharts/highcharts/issues/7463/events","html_url":"https://github.com/highcharts/highcharts/issues/7463","id":277339690,"number":7463,"title":"Wrong position for added ticks x-axis after zoom","user":{"login":"kzoon","id":1461707,"avatar_url":"https://avatars3.githubusercontent.com/u/1461707?v=4","gravatar_id":"","url":"https://api.github.com/users/kzoon","html_url":"https://github.com/kzoon","followers_url":"https://api.github.com/users/kzoon/followers","following_url":"https://api.github.com/users/kzoon/following{/other_user}","gists_url":"https://api.github.com/users/kzoon/gists{/gist_id}","starred_url":"https://api.github.com/users/kzoon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kzoon/subscriptions","organizations_url":"https://api.github.com/users/kzoon/orgs","repos_url":"https://api.github.com/users/kzoon/repos","events_url":"https://api.github.com/users/kzoon/events{/privacy}","received_events_url":"https://api.github.com/users/kzoon/received_events","type":"User","site_admin":false},"labels":[{"id":56034,"url":"https://api.github.com/repos/highcharts/highcharts/labels/Bug","name":"Bug","color":"fa0000","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-11-28T10:52:01Z","updated_at":"2017-12-07T10:41:19Z","closed_at":"2017-12-07T10:41:19Z","author_association":"NONE","body":"#### Expected behaviour\r\nWhen using the tickposition option, the x-axis sometimes adds an additional tick. This tick should be in the right position \r\n\r\n#### Actual behaviour\r\n1 The added tick can be outside the zoomed range\r\n2 The added tick sometimes is not on a category\r\n\r\n#### Live demo with steps to reproduce\r\n1 The added tick can be outside the zoomed range: http://jsfiddle.net/kzoon/suyokcuL/1/:\r\nzoom between august 2011 and April 2012 gives a tick on January 2012, but zoom between Jan 2011 and august 2011 gives no tick at all.\r\n\r\n2 The added tick sometimes is not on a category: \r\nhttp://jsfiddle.net/kzoon/yhagvbg6/1/\r\n\r\n#### Affected browser(s)\r\nAll\r\n\r\n#### My analysis\r\n\r\nCaused by axis trimTicks method:\r\nProblem 1 is caused because the added tick is calculated by calculation the mean of  the first and the last item in tickPositions, disregarding the fact that it might be outside the current zoom range. Solution: \r\nUse the actual max and min of the axis\r\nProblem 2 is caused because the calculated mean is not rounded\r\n\r\nThis code is my workaround, but should probably be polished:\r\n   ```\r\n       if (tickPositions.length === 0 && defined(roundedMin)) {\r\n                if (this.categories) {\r\n                    tickPositions.push(Math.round((this.min + this.max) / 2));\r\n                } else {\r\n                    tickPositions.push((roundedMax + roundedMin) / 2);\r\n                }\r\n            }\r\n```\r\n\r\n"}}
{"actor":{"display_login":"TorsteinHonsi"}}