如何在Y轴上获得百分比 [英] How to get percentages on my Y-axis

查看:100
本文介绍了如何在Y轴上获得百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


 


我想让y轴上的值显示为百分比,在C#中上下文。我的代码:


 



 



this 。chart.ChartAreas [0] .AxisX.Title =
" Year" ;


。chart.ChartAreas [0] .AxisY.Title =
" Percentage" ;


系列 <小号pan style ="font-size:x-small"> curSerie =
。chartReturningRunners.Series.Add(" myName");



curSerie.Label = "#PERCENT" ; //不做诀窍,让积分显示
为百分比,而不是y轴值
                



curSerie.ChartType = System.Windows.Forms.DataVisualization.Charting。



SeriesChartType 。行;


curSerie.Points.AddXY(2010,20); // y显示20% -axis,但是如何......


curSerie.Points.AddXY(2011,40); //在y轴上显示40%,但是如何...


 


我希望有人能指出我正确的方向。此外,知道在哪里搜索简单的答案会很棒这样的问题。我查看了Microsoft Charts Add-On帮助文件,但这完全没用......; - (


 



 


解决方案

尝试类似:

 
this.chart.ChartAreas [0] .AxisY.LabelStyle.Format = " {0.00 }%" ;


Hi,

 

I want to have the values on the y-axis shown as percentage, in a C# context. My code:

 

 

this.chart.ChartAreas[0].AxisX.Title = "Year";

this.chart.ChartAreas[0].AxisY.Title = "Percentage";

Series curSerie = this.chartReturningRunners.Series.Add("myName");

curSerie.Label = "#PERCENT"; // does not do the trick, makes the points show as percentage, not the y-axis values               

curSerie.ChartType = System.Windows.Forms.DataVisualization.Charting.

SeriesChartType.Line;

curSerie.Points.AddXY(2010, 20); // 20% shown on y-axis, but how...

curSerie.Points.AddXY(2011, 40);// 40% shown on y-axis, but how...

 

I hope someone can point me in the right direction. Also, it would be great to know where to search for answer to simple questions like this. I looked in the Microsoft Charts Add-On help-file but that is totally useless ... ;-(

 

 

解决方案

Try something like:

this.chart.ChartAreas[0].AxisY.LabelStyle.Format = "{0.00} %";


这篇关于如何在Y轴上获得百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆