加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net图表控件值标签位置

发布时间:2020-12-16 09:46:13 所属栏目:asp.Net 来源:网络整理
导读:我在asp.net图表控件中显示数据.使用3d条形图.我正在显示栏旁边的值. (seriesCount.IsValueShownAsLabel = true;).图表控件使值标签仍然位于条形图的顶部,并使值难以阅读.我试图将这个标签放在右边,但到目前为止我没有办法做到这一点.我也试过启用智能标签,
我在asp.net图表控件中显示数据.使用3d条形图.我正在显示栏旁边的值. (seriesCount.IsValueShownAsLabel = true;).图表控件使值标签仍然位于条形图的顶部,并使值难以阅读.我试图将这个标签放在右边,但到目前为止我没有办法做到这一点.我也试过启用智能标签,希望并在标杆上放置标记以推动价值,但我还没有成功.任何建议表示赞赏.

示例代码:

Chart chartSubjects = new Chart();
chartSubjects.Width = Unit.Pixel(800);
chartSubjects.Height = Unit.Pixel(300);
chartSubjects.AntiAliasing = AntiAliasingStyles.All;

Series seriesCount = new Series("subjectsCountSeries");
seriesCount.YValueType = ChartValueType.Int32;
seriesCount.ChartType = SeriesChartType.Bar;
seriesCount.IsValueShownAsLabel = true;
seriesCount.ChartArea = "subjectsCountArea";
chartSubjects.Series.Add(seriesCount);

ChartArea areaCount = new ChartArea("subjectsCountArea");
LabelStyle yAxisStyle = new LabelStyle();
yAxisStyle.ForeColor = System.Drawing.ColorTranslator.FromHtml("#444444");
yAxisStyle.Font = new System.Drawing.Font("Arial",11,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Pixel);
areaCount.AxisY.LabelStyle = yAxisStyle;
areaCount.AxisY.IsLabelAutoFit = false;
areaCount.Position.Width = 50;
areaCount.Position.Height = 100;
areaCount.Position.X = 0;
areaCount.Position.Y = 0;
areaCount.Area3DStyle.Enable3D = true;
areaCount.Area3DStyle.LightStyle = LightStyle.Realistic;
areaCount.Area3DStyle.WallWidth = 4;
areaCount.Area3DStyle.Inclination = 10;
areaCount.Area3DStyle.Perspective = 10;
areaCount.Area3DStyle.Rotation = 20;
areaCount.Area3DStyle.PointDepth = 90;
chartSubjects.ChartAreas.Add(areaCount);

int[] pointsToAdd = new int[] { 1434,712,601,204,173,168,64,35,22,8,2 };
foreach (int point in pointsToAdd)
{
    DataPoint dataPoint = new DataPoint();
    dataPoint.SetValueY(point);
    seriesCount.Points.Add(dataPoint);
}

解决方法

这是你想要的?

<asp:Series Name="Series1" ChartType="Bar" 
            CustomProperties="BarLabelStyle=Right" IsValueShownAsLabel="True" 
            Palette="EarthTones" XValueMember="xvalue" YValueMembers="yvalue">
</asp:Series>

CustomProperties =“BarLabelStyle = Right”为我做了.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读