This is a migrated thread and some comments may be shown as answers.

Display data with different-style rows in crosstab

7 Answers 309 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
SIlvia
Top achievements
Rank 1
SIlvia asked on 17 Apr 2009, 10:14 AM
Hello, i'm new in this forum and in telerik. I'm using crosstab and I want to make the rows in the crosstab of a different color depending on a field of dataset. I saw that I can do it with FormattingRules, but I want to do a design, because the color I want is a field of the dataset. How can I do? 
Thanks for your help,
Silvia

7 Answers, 1 is accepted

Sort by
0
Hrisi
Telerik team
answered on 21 Apr 2009, 02:41 PM
Hi SIlvia,

You can use Conditional formatting to change the color of the cell depending of the value. Please note that you should use aggregate functions in the Conditional Formatting expressions.

You can find attached our Crosstab example - Product Line Sales with added Conditional Formatting on textbox4.

Kind regards,
Hrisi
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
SIlvia
Top achievements
Rank 1
answered on 24 Apr 2009, 08:33 AM
Thanks, i've done.
Now i have another question.

I'm using pie chart and I want to make slices of cake in pie of a different color depending on a field of dataset. The color I want is a field of the dataset. How can I do? 
Thanks for your help,
Silvia
0
Steve
Telerik team
answered on 27 Apr 2009, 08:38 AM
Hello SIlvia,

You can use the chart item's NeedDataSource event, which should have access to both the data item and pie item. Then based on the color from the data item - set the color through the appearance setting of the pie item.

Kind regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
SIlvia
Top achievements
Rank 1
answered on 27 Apr 2009, 09:56 AM
Sorry, but i'm new in telerik. 
I'm trying it to decide if my company has to buy it.

I cant find the chart item's NeedDataSource event.

I see chart_NeedDataSource event that I've used to fill my chart in this way

 

Dim chartTorta As Telerik.Reporting.Processing.Chart = TryCast(sender, Telerik.Reporting.Processing.Chart)

 

chartTorta.DataSource =

Me.RiempiTortaTableAdapter1.GetData

but only this.

Now my pie is ok, but I want to make slices of cake in pie of a different color depending on a field of database.

How can i do?

Thanks for your help,
Silvia

 

0
Steve
Telerik team
answered on 27 Apr 2009, 10:27 AM
Hi SIlvia,

Although used mainly for binding, the NeedDataSource event can also be used if you want to make any last minute changes to the definition chart item. So that is the correct place and following the instructions from my previous post, you should be able to achieve what you're after. You can review this KB article to see how to get the raw object data.

Kind regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
SIlvia
Top achievements
Rank 1
answered on 27 Apr 2009, 11:02 AM
So if I understand correctly, I must declare the items in this way:

Private

 

Sub torta_NeedDataSource(ByVal sender As Object, ByVal e As System.EventArgs) Handles torta.NeedDataSource

 

 

    Dim chartTorta As Telerik.Reporting.Processing.Chart = TryCast(sender, Telerik.Reporting.Processing.Chart)

 

 

    Dim defChart As Telerik.Reporting.Chart = DirectCast(chartTorta.ItemDefinition, Telerik.Reporting.Chart)

 

    chartTorta.DataSource =

Me.RiempiTortaTableAdapter1.GetData(103823)

 

 

End Sub

But now? How can I define color of different slice?

 

0
Robert Munz
Top achievements
Rank 1
answered on 04 Jun 2009, 05:46 PM

I have ran to this issue today as well. So to answer the question: "How can I define color of different slice?" here is smaple of my code to make it happen.

Private Sub chartVersionDetails_NeedDataSource(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chartVersionDetails.NeedDataSource
        Dim chartVersionDetails As Telerik.Reporting.Processing.Chart = TryCast(sender, Telerik.Reporting.Processing.Chart)
        Dim row As DataRow = (TryCast(chartVersionDetails.DataItem, System.Data.DataRowView)).Row
        FilterTable(String.Concat("Version = '", row(1), "'"))
        Dim chartVersionDetailsDef As Telerik.Reporting.Chart = DirectCast(chartVersionDetails.ItemDefinition, Telerik.Reporting.Chart)
        Dim s As New ChartSeries()
        s.Appearance.LabelAppearance.LabelLocation = Telerik.Reporting.Charting.Styles.StyleSeriesItemLabel.ItemLabelLocation.Outside
        s.Appearance.LabelAppearance.Position.AlignedPosition = Telerik.Reporting.Charting.Styles.AlignedPositions.Center
        s.Type = ChartSeriesType.Pie
        s.DefaultLabelValue = "#Y (#%)"
        s.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels
        For Each dtRow As DataRow In filtredTable.Rows
            Dim item As New ChartSeriesItem()
            item.YValue = DirectCast(row("Total"), Integer)
            'Match proper color with the status in the slice
            Select Case CInt(dtRow("StatusID"))
                Case 0
                    item.Appearance.FillStyle.SecondColor = Color.Sienna
                    item.Appearance.FillStyle.SecondColor = Color.Wheat
                Case 1
                    item.Appearance.FillStyle.MainColor = Color.WhiteSmoke
                    item.Appearance.FillStyle.SecondColor = Color.Violet
                Case 2
                    item.Appearance.FillStyle.MainColor = Color.Red
                    item.Appearance.FillStyle.SecondColor = Color.RosyBrown
                Case 3
                    item.Appearance.FillStyle.MainColor = Color.Purple
                    item.Appearance.FillStyle.SecondColor = Color.Pink
                Case 4
                    item.Appearance.FillStyle.MainColor = Color.Salmon
                    item.Appearance.FillStyle.SecondColor = Color.RoyalBlue
            End Select
            s.Items.Add(item)
        Next
        chartVersionDetailsDef.Series.Clear()
        chartVersionDetailsDef.Series.Add(s)
End Sub

1 thing to notice:
- there is not specified any datasource for the chart, because we hard code series manualy and assign them to the chart through:        "chartVersionDetailsDef.Series.Add(s)".  Like that we override what would be bound to the chart.
I hope this helps to somebody. ;-)

Tags
General Discussions
Asked by
SIlvia
Top achievements
Rank 1
Answers by
Hrisi
Telerik team
SIlvia
Top achievements
Rank 1
Steve
Telerik team
Robert Munz
Top achievements
Rank 1
Share this question
or