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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745548255a4632442.html
评论列表(0条)