开发者

How do the values for a Google chart have to look?

开发者 https://www.devze.com 2023-04-11 04:04 出处:网络
I\'m using NGChart to generate charts over Googles chart API in C#. BarChart _budgetChart = new BarChart(BarsType.Stacked, BarsDirection.Vertical, new ChartSize(500, 100), new ChartData(new int[] { 6

I'm using NGChart to generate charts over Googles chart API in C#.

BarChart _budgetChart = new BarChart(BarsType.Stacked, BarsDirection.Vertical, new ChartSize(500, 100), new ChartData(new int[] { 60, 20, 1 }));

when I'm using this code, I get a bar chart that looks like this: http://chart.apis.google.com/chart?chd=s:8UB&cht=bvs&chs=500x100

I actually do not have any Ideo why the bar is full-sized with a value of 60. I'd rather like to use percentage data values, so for example the value 100 draws a bar that goes to the very top, a value开发者_运维知识库 of 50 draws a bar that has the half height ( would be 50px in this example, as my graph is 100px high) - How do I do that? I didn't find anything in the docs of NGChart.

the GoogleChartSharp API does it the same way, so I think there is maybe a special property or sth like that I have to set.

Edit: I don't get it.. I tried the maximum value, which is 61. In this chart, the first 3 values are 10 and the last one is 61, so 61 is the highest value that works for correct output. If the value is higher than 61 (in this example 62), the whole chart gets scaled down.

Ex 1 (Value 61): http://chart.apis.google.com/chart?chd=s:KKK9&cht=bvs&chs=300x100 Ex 2 (Value 62): http://chart.apis.google.com/chart?chd=e:AKAKAKA-&cht=bvs&chs=300x100

I simply don't understand how Google processes the values.


i can't found any info about property in NGChart, but can suggest this workaround: you can draw a bar with value of 100, but do it in transparent color

BarChart _budgetChart = new BarChart(BarsType.Stacked, BarsDirection.Vertical, 
new ChartSize(500, 100), 
new ChartData(new int[] { 60, 20, 1, 100 }));
_budgetChart.Colors = new ChartColors(new[] {Color.Red,Color.Red,Color.Red,Color.Transparent});

this should give you desired result, but it workaround thogh... so be careful =)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号