Display Values on Bars of a Bar chart in asp.net

橙三吉。 提交于 2019-12-10 13:45:48

问题


I want to display values on the top of the bars in asp.net chart. Also I want to hide the x axis while displaying it. For mock up please see the image below. Thanks.

I tried following but doesn't work.

var c = HorizontalChart;
        //c.ChartAreas.Add(new ChartArea("HChartArea"));
        //c.ChartAreas[0].BackHatchStyle = ChartHatchStyle.None;
        c.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
        c.ChartAreas[0].AxisY.MajorGrid.Enabled = false;
        c.ChartAreas[0].AxisY.CustomLabels="Code here for Lable values" <-------------
        c.Width = 300;
        c.Height = 300;
        Series myHorizontalSeries = new Series();
        myHorizontalSeries.Color = System.Drawing.Color.Blue;
        myHorizontalSeries.ChartType = SeriesChartType.Bar;
        myHorizontalSeries.Points.DataBindXY(new string[] { "one", "two", "three" }, new int[] { 1, 2, 3 });
        c.Series.Add(myHorizontalSeries);

回答1:


You should try setting the Axis Enabled property to false

c.ChartAreas[0].AxisX.Enabled = AxisEnabled.False;

To show the values you set the IsValueShownAsLabel property of the series to true




回答2:


You may try :

I want to display values on the top of the bars in asp.net chart.

myHorizontalSeries.IsValueShownAsLabel = true;

Also I want to hide the x axis while displaying it.

c.ChartAreas[0].AxisX.Enabled = AxisEnabled.False;



回答3:


another example you can show values like labels

c.Series[myHorizontalSeries].Label = "#VALY";

Hope I've helped.



来源:https://stackoverflow.com/questions/13839359/display-values-on-bars-of-a-bar-chart-in-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!