Select to view content in your preferred language

Charts

2600
8
10-16-2012 02:34 PM
TanyaOwens
Frequent Contributor
Hi,

I would like to create an application that uses charts as shown in http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#WebMapCharts except I don't want to use a map from arcgis online. I just want to click a line feature on my map and have it display chart info based on a related table from that feature. The related table has year and count data for the line segment. Can someone be kind enough to point me in the right direction to accomplish this?

Thanks!!
0 Kudos
8 Replies
DominiqueBroux
Esri Frequent Contributor
This pie chart sample should be a good starting point for getting charts in maptip.
0 Kudos
TanyaOwens
Frequent Contributor
This pie chart sample should be a good starting point for getting charts in maptip.


Thanks, I did see this sample but found the sample confusing and not exactly what I was looking for. I do not want the chart symbol to show up all the time and I don't want it connected with the legend. I just want a line series chart on a maptip or infowindow when the user clicks the feature. I found some sample code from the silverlight toolkit samples: http://forums.arcgis.com/threads/27765-Adding-charts?highlight=charts, looking at the line series under the DataVisualization. this is what I want i just am not sure how to link it up to my layer (which is currently a dynamic feature layer).

Also add in that my data is from a related table that needs to be used to create the chart. Is this even possible.
0 Kudos
TanyaOwens
Frequent Contributor
the hyperlink I put in the above message was incorrect it should be:

http://www.silverlight.net/content/samples/sl4/toolkitcontrolsamples/run/default.html
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Thanks, I did see this sample but found the sample confusing and not exactly what I was looking for. I do not want the chart symbol to show up all the time and I don't want it connected with the legend.


I created a new sample that keeps only the minimal code for getting a chart as maptip.
0 Kudos
TanyaOwens
Frequent Contributor
I created a new sample that keeps only the minimal code for getting a chart as maptip.


Thanks for this sample it is much easier to follow. I have to other questions:

1. I will be using a related table to get the values for the chart - how do I go about doing this or is it even possible?

2. How do I go about changing this from a pie chart to a line chart - my line chart will show the traffic count by the date (year).

3. Is there any reason you can think of why the ItemSourceConverter and other "local" data doesn't exist in my namespace? I am getting the following error:

"The tag 'ItemsSourceConverter' does not exist in XML namespace clr-namespace:TrafficCountWebApp'."

I have checked the namespace name and all added references and it matches the project I created that just had the original coded in it but when I add it to an existing project I have it doesn't seem to be able to find it. I have double checked and don't see anything missing.


Thanks!!
0 Kudos
TanyaOwens
Frequent Contributor
I figured out my question #3 - I had the c# code in the wrong location.

I am still really stuck on how to get to the related table for data source of the chart. 😞
0 Kudos
DominiqueBroux
Esri Frequent Contributor
I am still really stuck on how to get to the related table for data source of the chart


If your related table data are already loaded locally we can just extent the ItemsSourceConverter in order to return data coming from the related table as well.
The only limitation is that you need to be able to find the related data from the graphic attributes. That's most generally doable by using the ObjectId attribute : get the ObjectId from the Attributes dictionary, use this object id to find related data and return these data as KeyValuePair to display in the chart.


If your related data are not already loaded, it will be more complex since you will have to deal with asynchronous web requests.
In this case the chart ItemsSource has to be an observable collection (in order to react when the related values are added).
The general idea is :
   . the converter  executes a request to get related data and returns an empty observable collection.
   . in the complete handler of the request,  you populate the observable collection with the related data that you just got
   . the related data are displayed in the maptip chart (if the maptip is still visible 🙂 ).
0 Kudos
TanyaOwens
Frequent Contributor
Thanks for the info! Unfortunately I am still learning Silverlight so I need a bit more of a break down on how to do this:

1. What do you mean by the related table data being loaded locally? How would I go about setting that up? Part of my code is running a query on the related table �?? I followed the example from http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#QueryRelatedRecords. I would be fine with setting the chart up as a button click after the query has run �?? although I am not sure on how to go about setting up the button click to activate after the query. 

2. Where you said �??use the object id to find related data and return these data as KeyValuePair�?� �?�from what I can tell the current code pulls the KeyValuePair from the xaml �??FieldName�?� of the ItemsSourceConverter. How do I indicate in the xaml that the field is coming from the related table? Or is this all taken care of in the c# code? Is it possible to get an example of to retrieve the related table data and return it to the KeyValuePair?

3. In general, I am confused on how the KeyValuePair decides which field is the independent value and which is the dependent.  Maybe someone can point me in the right direction on this?


Sorry for all the questions �?? this is a concept that I am just having trouble getting a handle on. I really wish there was a sample of a chart created from related table data.
0 Kudos