为什么我的 StackedColumn 图表中的第二个系列不是从 y = 0 开始?
我在显示数据时遇到问题。我的问题是,我建立的第一个系列从 y 上的“0”开始,但第二个系列从之前系列的 y 值开始。我需要在代码中进行哪些调整才能允许第一个系列之后的所有后续系列从 y = 0 开始?
代码。
private void BuildGraph(machine_data[] array)
{
int series_cnt = 1;
chart1.Series.Clear();
chart2.Series.Clear();
for (int x = 0; x < array.Count(); x++)
{
chart1.Series.Add(array[x].name + array[x].Digital_Location);
chart2.Series.Add(array[x].name + array[x].Digital_Location);
int numpoints = array[x].Multi_Datapoints.Count();
for (Int32 i = 0; i < numpoints; i++)
{
/***************************/
chart1.Series[array[x].name + array[x].Digital_Location].ChartType = SeriesChartType.Area;
chart1.Series[array[x].name + array[x].Digital_Location].Points.AddXY(array[x].Multi_Datapoints[i].dt, array[x].Multi_Datapoints[i].state);
/***************************/
chart2.Series[array[x].name + array[x].Digital_Location].ChartType = SeriesChartType.StackedColumn;
// Set up the charting location of the Series
if (array[x].name == "Preci_4")
chart2.Series[array[x].name + array[x].Digital_Location].Points.AddXY(0, array[x].count_1s);
else
chart2.Series[array[x].name + array[x].Digital_Location].Points.AddXY(1, array[x].count_1s);
// Set up the color of the series' according to which DIO they correspond to.
if (array[x].Digital_Location == "DIO0")
chart2.Series[array[x].name + array[x].Digital_Location].Color = Color.Green;
else
chart2.Series[array[x].name + array[x].Digital_Location].Color = Color.Red;
/*chart2.AlignDataPointsByAxisLabel();
return chart2;*/
}
series_cnt++;
}
I am having trouble displaying data. My problem is that the first series i establish starts from "0" on y, but the second series starts at the y value from the series before it. What do i need to adjust in my code to allow all subsequent series after the first to start at y = 0?
Code.
private void BuildGraph(machine_data[] array)
{
int series_cnt = 1;
chart1.Series.Clear();
chart2.Series.Clear();
for (int x = 0; x < array.Count(); x++)
{
chart1.Series.Add(array[x].name + array[x].Digital_Location);
chart2.Series.Add(array[x].name + array[x].Digital_Location);
int numpoints = array[x].Multi_Datapoints.Count();
for (Int32 i = 0; i < numpoints; i++)
{
/***************************/
chart1.Series[array[x].name + array[x].Digital_Location].ChartType = SeriesChartType.Area;
chart1.Series[array[x].name + array[x].Digital_Location].Points.AddXY(array[x].Multi_Datapoints[i].dt, array[x].Multi_Datapoints[i].state);
/***************************/
chart2.Series[array[x].name + array[x].Digital_Location].ChartType = SeriesChartType.StackedColumn;
// Set up the charting location of the Series
if (array[x].name == "Preci_4")
chart2.Series[array[x].name + array[x].Digital_Location].Points.AddXY(0, array[x].count_1s);
else
chart2.Series[array[x].name + array[x].Digital_Location].Points.AddXY(1, array[x].count_1s);
// Set up the color of the series' according to which DIO they correspond to.
if (array[x].Digital_Location == "DIO0")
chart2.Series[array[x].name + array[x].Digital_Location].Color = Color.Green;
else
chart2.Series[array[x].name + array[x].Digital_Location].Color = Color.Red;
/*chart2.AlignDataPointsByAxisLabel();
return chart2;*/
}
series_cnt++;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经弄清楚了——我正在制作 4 个独立的系列。我只需要 2 个系列并改变 x 位置。当我制作 2 个系列时,我就可以从 0 开始。
I've figured it out - I was making 4 separate series. I need only 2 series and to vary the x position. When I make 2 series I am then able to start from 0.