Hi,
I have report with one chart. I would like to have chart with dynamic series.
My dataset (attachment): 00ds.png
My C# code:
customChart.DataGroupColumn =
"Status"
;
customChart.PlotArea.XAxis.DataLabelsColumn =
"Quarter"
;
I've got some strange chart as a result: 01.png. Some series are assigned incorrect. For example, in the Q1 there is "Deleted" with value 10, but it should be in the Q3.
I would like to get something like this: 02.png (note that Q3 and Q4 are changed in the X axis).
Is it possible?
Thanks,
Rafal
4 Answers, 1 is accepted
Try sorting the data by Quarter followed by a sort in Status. I believe that will correct the chart.
John
When using the DataGroupColumn property the items arrangement is consequential and cannot have gaps - meaning that if it should appear like this:
data1, empty, data2,
it will actually render like this:
data1, data2, empty
The only way to avoid this is to programmatically create the series and the items. When you create the items they need to have both Y-Value and X-Value (the X-Value determines exactly where on the X-AXis the column will be placed).
You will find these articles helpful on the matter:
Elian
the Telerik team
BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >
We shouldn't have to "doctor" the data to make the charts work correctly.
I have to find an embedded reporting solution for many different types of reports but I really don't want to have to do this for every datasource I supply.
You don't need to 'doctor' the data, you just need to build the series programmatically. Please refer to the links in the previous post and to the following sample code snippet creating a chart with grouping by Category:
private
void
chart1_NeedDataSource(
object
sender, EventArgs e)
{
//here you can actually get the data from the database but the differences are minor
var data = DataClass.GetData();
chart1.Series.Add(
new
ChartSeries());
foreach
(var item
in
data)
{
//this simulates the grouping
//if the series already exists we take it and use it
var series = chart1.Series.GetByName(item.Category.ToString());
//if it doesn't, we create it
if
(series ==
null
)
{
series =
new
ChartSeries(item.Category.ToString());
chart1.Series.Add(series);
}
//now we work with this series
//we use the new ChartSeriesItem(double x, double y) overload
//if the chart will be only for 1 year time span then we can use the month for x-value
//if it covers more than one year, we will need more complex expression, including the year
series.Items.Add(
new
ChartSeriesItem(item.Date.Month, item.Value));
}
//and now we change the x-axis labels with the months names
chart1.PlotArea.XAxis.AutoScale =
false
;
chart1.PlotArea.XAxis.AddRange(1, 12, 1);
var months =
"January February March April May June July August September October November December"
.Split(
' '
);
for
(
int
i = 0; i < 12; i++)
{
chart1.PlotArea.XAxis.Items[i].TextBlock.Text = months[i];
}
chart1.PlotArea.XAxis.Appearance.LabelAppearance.RotationAngle = -30;
}
Greetings,
Elian
the Telerik team
HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!