Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a simple Silverlight Application that has a Map control that shows a ESRI Tiled layer service and a Dynamic Layer service. The Dynamic Layer service is just called "Wells" and it has a "Date" column and "Gas_Percent" field that would be perfect to show in a Chart. Does anyone know how I can do this? I've been looking at these examples in below hyperlink (for LineSeries) (Silverlight Chart Examples) but I don't know how to use my Wells layer and Date and Gas_Percent columns in place of what they have. Can anyone help me on this?

Thank you in advance.

share|improve this question
add comment

3 Answers

Sorry for the delay.. this is how i did it C# code I have a method which executes a GP task that returns a graphics layer I iterate each graphic, create an observable collection and bind the observable collection to the data grid. there are other ways to bind but this worked for me when used with the chart Hope this helps

    // GP task that returns graphics
    public void Execute(object parameter)
    {
        Geoprocessor getData = new Geoprocessor();
        getData.Url = "GP task URL...";
        getData.Failed += this.GP_Failed;
        getData.GetResultDataCompleted += this.GP_GetResultDataCompleted;
        getData.GetResultDataAsync(this.jobId, "parameter");            
    }

    // The event raised when GP task successful
    void GP_GetResultDataCompleted(object sender, GPParameterEventArgs e)
    {
        object attributeValue = null;

        // Internal class object
        CategoryAttributes categoryAttributes = new CategoryAttributes();

        if (e.Parameter is GPFeatureRecordSetLayer)
        {
            GPFeatureRecordSetLayer gpLayer = e.Parameter as GPFeatureRecordSetLayer;

            // Create a new graphics layer
            GraphicsLayer graphicsLayer = new GraphicsLayer();
            graphicsLayer.ID = "GraphicsLayer";

            // Add the graphics to the graphics layer and an observable collection that is binded to a data grid
            foreach (Graphic graphic in gpLayer.FeatureSet.Features)
            {
                CategoryAttribute categoryAttribute = new CategoryAttribute();

                attributeValue = g.Attributes.Where(x => x.Key.Contains("CategoryCount")).SingleOrDefault().Value;
                if (attributeValue != null)
                {
                    categoryAttribute.Count = attributeValue.ToString();
                }

                attributeValue = g.Attributes.Where(x => x.Key.Contains("CategoryValue")).SingleOrDefault().Value;
                if (attributeValue != null)
                {
                    categoryAttribute.Value = attributeValue.ToString();
                }

                attributeValue = g.Attributes.Where(x => x.Key.Contains("CategoryAmount")).SingleOrDefault().Value;
                if (attributeValue != null)
                {
                    categoryAttribute.Amount = attributeValue.ToString();
                }
                categoryAttributes.Add(categoryAttribute);

                graphicsLayer.Graphics.Add(graphic);
            }

            // Add to map
            this.myMap.Layers.Add(graphicsLayer);

            // Bind data to data grid
            this.MyDataGrid.ItemsSource = categoryAttributes;
        }
    }

    // Internal classes for creating the observable collection
    internal class CategoryAttributes : ObservableCollection<CategoryAttribute>
    {
    }
    internal class CategoryAttribute
    {
        public double CategoryCount { get; set; }
        public double CategoryValue { get; set; }
        public double CategoryAmount { get; set; }
    }        
share|improve this answer
add comment

How exactly did you bind the feature layer to the Data Grid? I've added a regular Data Grid to my Silverlight App but have not figured out how to bind it to my feature layer

Moderator- I tried responding to user2294 response but it ends up displaying as an answer can you adjust this for me? thanks

share|improve this answer
1  
This sample binds a featurelayer to a datagrid. –  Kirk Kuykendall May 13 '11 at 19:46
add comment

I did a similar kind of thing some time back... this is what I did and by the way I did this for a featurelayer/graphics layer using ESRI ArcGIS API

Binding the feature/graphics layer attributes to a data grid (did not use the featuredata grid ESRI provides) Then bind a specific grid column to a chart. Infact the way I did was the user can click on a column and the chart would display that column (simple bar chart). So you click a different column the chart changes.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.