最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google Charts - Curved Line Chart incorrectly dips below 0 - Stack Overflow

programmeradmin0浏览0评论

I have a Google line chart, I set 'curveType': 'function' so the graph is curved and has a nice appearance. My problem is that when a data point has a value of 0, followed by a following high value, the chart dips below 0 so that the curve can fit correctly. This also causes the vAxis to have a minRange of -2000, this isn't possible for my data (number of downloads over time).

I've tried to solve this by setting 'minValue': 0 and 'viewWindowMode': 'maximized' on the vAxis, but it hasn't solved the problem completely.

I have attached an image that will explain my problem a lot better than I can with words.

If anyone knows a solution to this, without me having to go back to straight lines, it would be much appreciated. Thanks

I have a Google line chart, I set 'curveType': 'function' so the graph is curved and has a nice appearance. My problem is that when a data point has a value of 0, followed by a following high value, the chart dips below 0 so that the curve can fit correctly. This also causes the vAxis to have a minRange of -2000, this isn't possible for my data (number of downloads over time).

I've tried to solve this by setting 'minValue': 0 and 'viewWindowMode': 'maximized' on the vAxis, but it hasn't solved the problem completely.

I have attached an image that will explain my problem a lot better than I can with words.

If anyone knows a solution to this, without me having to go back to straight lines, it would be much appreciated. Thanks

Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Oct 31, 2012 at 14:51 SteveEdsonSteveEdson 2,4952 gold badges29 silver badges46 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 15

The curve may continue to dip below 0 no matter what you do, but you can crop the view so the lowest point of the displayed graph is at 0. You can do that with the vAxis.viewWindow.min property:

lineChart.draw(data, 
   {
    curveType: "function",
    vAxis: {viewWindow: {min:0} } 
   }
);

See the LineChart documentation for information on vAxis.viewWindow.min and other configuration options.

Just a quick update on this. I realised that my data work not be suitable for a curved graph anyway, as it is discrete data and not continuous. I had to switch back to straight lines, which removed my problem. Not an ideal solution, I know, but it is one that worked for me.

You could try another charting library. I often use flot for simple graphs, and raphael graphs for more complicated things (slightly harder to manipulate, and looks a bit more clunky to me)

gRaphael: http://g.raphaeljs.com/ Flot: http://www.flotcharts.org/

发布评论

评论列表(0)

  1. 暂无评论