gpt4 book ai didi

c# - Asp.net 图表,如何将 X 轴标签位置设置为左对齐而不是居中?

转载 作者:行者123 更新时间:2023-11-28 08:43:11 24 4
gpt4 key购买 nike

我花了几个小时试图解决这个愚蠢的问题。我用 asp 图表控件创建了一个直方图。我想要做的就是将 xaxis 标签放在列的左侧而不是居中。 Xaxis 标签似乎没有像系列那样的位置属性,所以我无法弄清楚,这令人沮丧。

这是我正在谈论的图形类型的示例代码,向您展示我大致得到的结果:

        private void Graphique()
{
// Creating the series
Series series2 = new Series("Series2");

// Setting the Chart Types
series2.ChartType = SeriesChartType.Column;

// Adding some points
series2.Points.AddXY(1492, 12);
series2.Points.AddXY(2984, 0);
series2.Points.AddXY(4476, 1);
series2.Points.AddXY(5968, 2);
series2.Points.AddXY(7460, 2);
series2.Points.AddXY(8952, 12);
series2.Points.AddXY(10444, 4);
series2.Points.AddXY(11936, 3);
series2.Points.AddXY(13428, 3);
series2.Points.AddXY(14920, 5);
series2.Points.AddXY(16412, 1);

Chart3.Series.Add(series2);

Chart3.Width = 600;
Chart3.Height = 600;

// Series visual
series2.YValueMembers = "Frequency";
series2.XValueMember = "RoundedValue";
series2.BorderWidth = 1;
series2.ShadowOffset = 0;
series2.IsXValueIndexed = true;

// Setting the X Axis
Chart3.ChartAreas["ChartArea1"].AxisX.IsMarginVisible = true;
Chart3.ChartAreas["ChartArea1"].AxisX.Interval = 1;
Chart3.ChartAreas["ChartArea1"].AxisX.Maximum = Double.NaN;
Chart3.ChartAreas["ChartArea1"].AxisX.Title = "kbps";

// Setting the Y Axis
Chart3.ChartAreas["ChartArea1"].AxisY.Interval = 2;
Chart3.ChartAreas["ChartArea1"].AxisY.Maximum = Double.NaN;
Chart3.ChartAreas["ChartArea1"].AxisY.Title = "Frequency";
}

现在我的真实图表是这样的,Actual result

我想要类似这个网站的东西: Desired layout chart

你看,x 标签在左边,考虑到直方图的每一列代表一系列值的频率,这更有意义......

任何帮助将不胜感激...

最佳答案

您是否尝试添加 CustomLabels 来替换默认的?例如:

for (int i = 0; i <= 10; i++) {
area.AxisX.CustomLabels.Add(i + 0.5, i + 1.5, i, 0, LabelMarkStyle.None);
}

前两个用于定位,第三个是标签的文本值。

关于c# - Asp.net 图表,如何将 X 轴标签位置设置为左对齐而不是居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27736390/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com