Hi,
I have a StackedBar100 chart in my report, everything works fine, but the problem is the appereance of the percentage result in the Bar.
For example: If I have a bar divided in two or more... the first value appears in the botton of the second part of bar and the other value appears in the top of the second part of the bar. I'd like to see each value appearing inside the correct bar.
Is that possible??
Another Question: I think this code is not good... maybe there is an easy way to do that with the same result.. isnt there??
Thanks...
Code:
DataTable GetData()
{
DataTable dataTable = new DataTable();
dataTable.Columns.Add("Descricao", typeof(string));
dataTable.Columns.Add("Qtd1", typeof(int));
dataTable.Columns.Add("Qtd2", typeof(int));
dataTable.Rows.Add(new object[] { "A", 3, 5 });
dataTable.Rows.Add(new object[] { "B", 2, 5 });
dataTable.Rows.Add(new object[] { "C", 5, 5 });
return dataTable;
}
private void chart2_NeedDataSource(object sender, EventArgs e)
{
try
{
DataTable dt = new DataTable();
dt = GetData();
Telerik.Reporting.Processing.Chart chart = sender as Telerik.Reporting.Processing.Chart;
chart2.Series.Clear();
ChartSeries s = null;
for (int i = 0; i < dt.Columns.Count -1; i++)
{
s = new ChartSeries();
s.Type = ChartSeriesType.StackedBar100;
s.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing;
s.DefaultLabelValue = "#%";
chart2.Series.Add(s);
foreach (DataRow row in dt.Rows)
{
ChartSeriesItem item = new ChartSeriesItem();
item.YValue = Convert.ToDouble(row[i+1]);
s.AddItem(item);
}
}
foreach (DataRow row in dt.Rows)
{
s.PlotArea.XAxis.AutoScale = false; //false permite gerar o xaxis com os valores que eu definir
s.PlotArea.XAxis.AddItem((string)row["Descricao"]);
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
I have a StackedBar100 chart in my report, everything works fine, but the problem is the appereance of the percentage result in the Bar.
For example: If I have a bar divided in two or more... the first value appears in the botton of the second part of bar and the other value appears in the top of the second part of the bar. I'd like to see each value appearing inside the correct bar.
Is that possible??
Another Question: I think this code is not good... maybe there is an easy way to do that with the same result.. isnt there??
Thanks...
Code:
DataTable GetData()
{
DataTable dataTable = new DataTable();
dataTable.Columns.Add("Descricao", typeof(string));
dataTable.Columns.Add("Qtd1", typeof(int));
dataTable.Columns.Add("Qtd2", typeof(int));
dataTable.Rows.Add(new object[] { "A", 3, 5 });
dataTable.Rows.Add(new object[] { "B", 2, 5 });
dataTable.Rows.Add(new object[] { "C", 5, 5 });
return dataTable;
}
private void chart2_NeedDataSource(object sender, EventArgs e)
{
try
{
DataTable dt = new DataTable();
dt = GetData();
Telerik.Reporting.Processing.Chart chart = sender as Telerik.Reporting.Processing.Chart;
chart2.Series.Clear();
ChartSeries s = null;
for (int i = 0; i < dt.Columns.Count -1; i++)
{
s = new ChartSeries();
s.Type = ChartSeriesType.StackedBar100;
s.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.Nothing;
s.DefaultLabelValue = "#%";
chart2.Series.Add(s);
foreach (DataRow row in dt.Rows)
{
ChartSeriesItem item = new ChartSeriesItem();
item.YValue = Convert.ToDouble(row[i+1]);
s.AddItem(item);
}
}
foreach (DataRow row in dt.Rows)
{
s.PlotArea.XAxis.AutoScale = false; //false permite gerar o xaxis com os valores que eu definir
s.PlotArea.XAxis.AddItem((string)row["Descricao"]);
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}