with the following code i get transparent bars on the chart on the left upper side (maximize window). This is caused by SetNull in combination with HorizBox. I don`t know, if v4 or newer v3 releases contains this issue.
All series have the same values. In my application i must use SetNull() to avoid artefacts of 0 value bars. In that case i found this behaviour.
Code: Select all
// Controls
TChart chart1 = new TChart();
TChart chart2 = new TChart();
TChart chart3 = new TChart();
TChart chart4 = new TChart();
TableLayoutPanel tlp = new TableLayoutPanel();
tlp.Controls.Add(chart1);
tlp.Controls.Add(chart2);
tlp.Controls.Add(chart3);
tlp.Controls.Add(chart4);
this.Controls.Add(tlp);
tlp.Dock = DockStyle.Fill;
tlp.ColumnCount = 2;
tlp.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
tlp.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
tlp.RowCount = 2;
tlp.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
tlp.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
chart1.Dock = DockStyle.Fill;
chart2.Dock = DockStyle.Fill;
chart3.Dock = DockStyle.Fill;
chart4.Dock = DockStyle.Fill;
chart1.Aspect.View3D = false;
chart2.Aspect.View3D = false;
chart3.Aspect.View3D = false;
chart4.Aspect.View3D = false;
chart1.Header.Text = "Bars with SetNull()";
chart2.Header.Text = "HorizBars with SetNull()";
chart3.Header.Text = "Bars without SetNull()";
chart4.Header.Text = "HorizBars without SetNull()";
// Data
DataTable dt = new DataTable();
dt.Columns.Add("X", typeof(Double));
dt.Columns.Add("Y",typeof(String));
for (int i = 0; i < 10; i++)
{
if (i == 5)
{
dt.Rows.Add(0, "String" + i.ToString());
}
else
{
dt.Rows.Add(i, "String" + i.ToString());
}
}
// Generate bars
foreach (DataRow dr in dt.Rows)
{
Bar bar = new Bar(chart1.Chart);
Bar bar2 = new Bar(chart3.Chart);
HorizBar horizBar = new HorizBar(chart2.Chart);
HorizBar horizBar2 = new HorizBar(chart4.Chart);
bar.Title = "Bar" + dr[0].ToString();
bar2.Title = "Bar" + dr[0].ToString();
horizBar.Title = "HorizBar" + dr[0].ToString();
horizBar2.Title = "HorizBar" + dr[0].ToString();
bar.MultiBar = MultiBars.Stacked;
bar2.MultiBar = MultiBars.Stacked;
horizBar.MultiBar = MultiBars.Stacked;
horizBar2.MultiBar = MultiBars.Stacked;
bar.Marks.Visible = false;
bar2.Marks.Visible = false;
horizBar.Marks.Visible = false;
horizBar2.Marks.Visible = false;
}
// Fill with data
foreach (DataRow dr in dt.Rows)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
CustomBar cb = (CustomBar)chart1.Series[i];
cb.Add((Double)dr[0], dr[1].ToString());
cb = (CustomBar)chart2.Series[i];
cb.Add((Double)dr[0], dr[1].ToString());
cb = (CustomBar)chart3.Series[i];
cb.Add((Double)dr[0], dr[1].ToString());
cb = (CustomBar)chart4.Series[i];
cb.Add((Double)dr[0], dr[1].ToString());
if ((Double)dr[0] == 0)
{
cb = (CustomBar)chart1.Series[i];
cb.SetNull(cb.Count - 1);
cb = (CustomBar)chart2.Series[i];
cb.SetNull(cb.Count - 1);
}
}
}
chart2.Axes.Left.Inverted = true;
chart4.Axes.Left.Inverted = true;
Thanks in advance!