admin管理员组文章数量:1023782
I have a StackedColumn Chart. I would like to draw text at the X position of the Series centerpoint and a Y position near the top of the chart. I am having trouble figuring out where the Series XY position is.
The closest thing I have been able to achieve is shown below:
I achieved this by drawing the labels as follows:
startX = chartRect.Left + (float)(chartDailyBuildRateDisplay.ChartAreas[0].AxisX.ValueToPixelPosition(0));
startY = chartRect.Top + 5;
g.DrawRectangle(whitePen, startX, startY + 15, 120, 40);
g.FillRectangle(steelBlueBrush, startX, startY + 15, 120, 40);
g.DrawString(" Goal: " + LVDTGoal.ToString(), font, whiteBrush, startX, startY + 20);
startX = chartRect.Left + (float)(chartDailyBuildRateDisplay.ChartAreas[0].AxisX.ValueToPixelPosition(1));
g.DrawRectangle(whitePen, startX, startY + 15, 120, 40);
g.FillRectangle(steelBlueBrush, startX, startY + 15, 120, 40);
g.DrawString(" Goal: " + RVDTGoal.ToString(), font, whiteBrush, startX, startY + 20);
etc.
Obviously I need to include something else like the Axis size or something like that? Any help would be appreciated.
I have a StackedColumn Chart. I would like to draw text at the X position of the Series centerpoint and a Y position near the top of the chart. I am having trouble figuring out where the Series XY position is.
The closest thing I have been able to achieve is shown below:
I achieved this by drawing the labels as follows:
startX = chartRect.Left + (float)(chartDailyBuildRateDisplay.ChartAreas[0].AxisX.ValueToPixelPosition(0));
startY = chartRect.Top + 5;
g.DrawRectangle(whitePen, startX, startY + 15, 120, 40);
g.FillRectangle(steelBlueBrush, startX, startY + 15, 120, 40);
g.DrawString(" Goal: " + LVDTGoal.ToString(), font, whiteBrush, startX, startY + 20);
startX = chartRect.Left + (float)(chartDailyBuildRateDisplay.ChartAreas[0].AxisX.ValueToPixelPosition(1));
g.DrawRectangle(whitePen, startX, startY + 15, 120, 40);
g.FillRectangle(steelBlueBrush, startX, startY + 15, 120, 40);
g.DrawString(" Goal: " + RVDTGoal.ToString(), font, whiteBrush, startX, startY + 20);
etc.
Obviously I need to include something else like the Axis size or something like that? Any help would be appreciated.
Share Improve this question asked Nov 20, 2024 at 17:59 TimTim 274 bronze badges 1- I don't quite understand where you want the text. Would you please draw a simple mspaint image to illustrate? Maybe with some more columns to so it's clear what you want it to look like with higher values. – JorisJ1 Commented Nov 24, 2024 at 13:48
1 Answer
Reset to default 0Ah, I see the problem. I started with ValueToPixelPosition(0) which I thought was the first Bar. It is not. I assume that is the xAxis itself. Changing my code to start at 1 for the first bar, solved the problem.
I have a StackedColumn Chart. I would like to draw text at the X position of the Series centerpoint and a Y position near the top of the chart. I am having trouble figuring out where the Series XY position is.
The closest thing I have been able to achieve is shown below:
I achieved this by drawing the labels as follows:
startX = chartRect.Left + (float)(chartDailyBuildRateDisplay.ChartAreas[0].AxisX.ValueToPixelPosition(0));
startY = chartRect.Top + 5;
g.DrawRectangle(whitePen, startX, startY + 15, 120, 40);
g.FillRectangle(steelBlueBrush, startX, startY + 15, 120, 40);
g.DrawString(" Goal: " + LVDTGoal.ToString(), font, whiteBrush, startX, startY + 20);
startX = chartRect.Left + (float)(chartDailyBuildRateDisplay.ChartAreas[0].AxisX.ValueToPixelPosition(1));
g.DrawRectangle(whitePen, startX, startY + 15, 120, 40);
g.FillRectangle(steelBlueBrush, startX, startY + 15, 120, 40);
g.DrawString(" Goal: " + RVDTGoal.ToString(), font, whiteBrush, startX, startY + 20);
etc.
Obviously I need to include something else like the Axis size or something like that? Any help would be appreciated.
I have a StackedColumn Chart. I would like to draw text at the X position of the Series centerpoint and a Y position near the top of the chart. I am having trouble figuring out where the Series XY position is.
The closest thing I have been able to achieve is shown below:
I achieved this by drawing the labels as follows:
startX = chartRect.Left + (float)(chartDailyBuildRateDisplay.ChartAreas[0].AxisX.ValueToPixelPosition(0));
startY = chartRect.Top + 5;
g.DrawRectangle(whitePen, startX, startY + 15, 120, 40);
g.FillRectangle(steelBlueBrush, startX, startY + 15, 120, 40);
g.DrawString(" Goal: " + LVDTGoal.ToString(), font, whiteBrush, startX, startY + 20);
startX = chartRect.Left + (float)(chartDailyBuildRateDisplay.ChartAreas[0].AxisX.ValueToPixelPosition(1));
g.DrawRectangle(whitePen, startX, startY + 15, 120, 40);
g.FillRectangle(steelBlueBrush, startX, startY + 15, 120, 40);
g.DrawString(" Goal: " + RVDTGoal.ToString(), font, whiteBrush, startX, startY + 20);
etc.
Obviously I need to include something else like the Axis size or something like that? Any help would be appreciated.
Share Improve this question asked Nov 20, 2024 at 17:59 TimTim 274 bronze badges 1- I don't quite understand where you want the text. Would you please draw a simple mspaint image to illustrate? Maybe with some more columns to so it's clear what you want it to look like with higher values. – JorisJ1 Commented Nov 24, 2024 at 13:48
1 Answer
Reset to default 0Ah, I see the problem. I started with ValueToPixelPosition(0) which I thought was the first Bar. It is not. I assume that is the xAxis itself. Changing my code to start at 1 for the first bar, solved the problem.
版权声明:本文标题:C# MSChart. How do I find the XY position of the Series Label for a StackedColumn ChartType? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745548254a2155497.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论