{"action":"opened","issue":{"url":"https://api.github.com/repos/ocadotechnology/hexagonjs/issues/52","labels_url":"https://api.github.com/repos/ocadotechnology/hexagonjs/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/ocadotechnology/hexagonjs/issues/52/comments","events_url":"https://api.github.com/repos/ocadotechnology/hexagonjs/issues/52/events","html_url":"https://github.com/ocadotechnology/hexagonjs/issues/52","id":122772439,"number":52,"title":"Plot: graphs with 0 values thrown an error when using gradient stroke/fill","user":{"login":"c-frater","id":3194349,"avatar_url":"https://avatars.githubusercontent.com/u/3194349?v=3","gravatar_id":"","url":"https://api.github.com/users/c-frater","html_url":"https://github.com/c-frater","followers_url":"https://api.github.com/users/c-frater/followers","following_url":"https://api.github.com/users/c-frater/following{/other_user}","gists_url":"https://api.github.com/users/c-frater/gists{/gist_id}","starred_url":"https://api.github.com/users/c-frater/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c-frater/subscriptions","organizations_url":"https://api.github.com/users/c-frater/orgs","repos_url":"https://api.github.com/users/c-frater/repos","events_url":"https://api.github.com/users/c-frater/events{/privacy}","received_events_url":"https://api.github.com/users/c-frater/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ocadotechnology/hexagonjs/labels/Bug","name":"Bug","color":"EC3A65"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-17T16:39:21Z","updated_at":"2015-12-17T16:39:21Z","closed_at":null,"body":"The `createLinearGradient` function used in Plot is not expecting all the values in the data to be 0 and causes the offset for the gradient in the svg to be set to `Infinity%` or `NaN%`\r\n\r\nIt looks to be down to this line:\r\n`.attr('offset', ((value.yValue - series.axis.yScale.domainMin) / (series.axis.yScale.domainMax - series.axis.yScale.domainMin) * 100) + '%')`\r\n\r\nExample: \r\n```html\r\n<div id=\"sparkline\" style=\"height: 3em\"></div>\r\n```\r\n\r\n```coffeescript\r\nsp = new hx.Sparkline('#sparkline', {\r\n  fillColor: 'rgba(0,0,0,0)',\r\n  strokeColor: [\r\n    {\r\n      yValue: 2.5,\r\n      color: '#000'\r\n    }\r\n    {\r\n      yValue: 2.6,\r\n      color: '#F00'\r\n    }\r\n  ]\r\n  data: [\r\n    {\r\n      x: 0\r\n      y: 0\r\n    },\r\n    {\r\n      x: 1\r\n      y: 0\r\n    },\r\n    {\r\n      x: 2\r\n      y: 0\r\n    }\r\n  ]\r\n})\r\n\r\nsp.render()\r\n```"}}