<chartingToolkit:Chart Title="Typical Use">
<chartingToolkit:ChartSeries>
<chartingToolkit:LineSeries Title="Particulate Levels" ItemsSource="{Binding LevelsInRainfall, Source={StaticResource ParticulateLevel}}" IndependentValueBinding="{Binding Rainfall}" DependentValueBinding="{Binding Particulate}"/>
</chartingToolkit:Chart.Series>
</chartingToolkit:Chart>
I have not used LineSeries myself but if you look at the code and chart sample, you will notice that they set ItemsSource, IndependentValueBinding (X-axis) and DependentValueBinding (Y-axis).
<Charting:Chart> <Charting:Chart.Series> <Charting:ColumnSeries Title="Wind Speed" ItemsSource="{Binding ElementName=MyMap, Path=Layers[MyHurricaneFeatureLayer].Graphics}" IndependentValueBinding="{Binding Attributes[EVENTID]}" DependentValueBinding="{Binding Attributes[WINDSPEED]}"/> </Charting:ColumnSeries> </Charting:Chart.Series> </Charting:Chart>
private IEnumerable<Graphic> GetLastObservations(IEnumerable<Graphic> graphics) { return from g in graphics where g.TimeExtent.Intersects(MyMap.TimeExtent) group g by g.Attributes["EVENTID"] into grp select grp.OrderByDescending(g => g.Attributes["Date_Time"]).First(); }2) Define a property to return the LastObservations:
private readonly ObservableCollection<Graphic> _lastObservations = new ObservableCollection<Graphic>(); public ObservableCollection<Graphic> LastObservations { get { return _lastObservations; } }
private void SetLastObservations() { var layer = MyMap.Layers["MyHurricaneFeatureLayer"] as GraphicsLayer; LastObservations.Clear(); foreach (var g in GetLastObservations(layer.Graphics)) LastObservations.Add(g); }4) Call SetLastObservations when the collection can change i.e. when the feature layer updates and when the time extent changes:
private void FeatureLayer_UpdateCompleted(object sender, EventArgs e) { SetLastObservations(); } private void MyMap_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "TimeExtent") SetLastObservations(); }4) In XAML, hook up these events
<Charting:Chart><Charting:Chart.Series> <Charting:ColumnSeries Title="Wind Speed" ItemsSource="{Binding LastObservations}" IndependentValueBinding="{Binding Attributes[EVENTID]}" DependentValueBinding="{Binding Attributes[WINDSPEED]}"> </Charting:ColumnSeries> </Charting:Chart.Series> <Charting:Chart.Axes> <Charting:LinearAxis Orientation="Y" Minimum="0" Maximum="120" Interval="20" ShowGridLines="True" FontStyle="Italic"/> </Charting:Chart.Axes> </Charting:Chart>
public TemporalRendererTracks() { InitializeComponent(); DataContext = this; }
If you need to get one line or one column by graphic, the ItemSources of your chart can be the Graphics property of your layer.
Something like (based on this sample : http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#TemporalRendererTracks) :
<Chart.Chart>what do I need to do to reference Chart so I can that part working?
xmlns:Charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
In your project, add a reference to System.Windows.Controls.DataVisualization.Toolkit.
and in your xaml, add this line:xmlns:Charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
<esri:FeatureLayer ID="WellsFeatureLayer" Url="http://serverprd02/ArcGIS/rest/services/SilverLightDir/Wells_Timeline/MapServer/0" />
<Charting:Chart>
<Charting:Chart.Series>
<Charting:ColumnSeries Title="Wind Speed" ItemsSource="{Binding ElementName=MyMap, Path=Layers[MyHurricaneFeatureLayer].Graphics}" IndependentValueBinding="{Binding Attributes[EVENTID]}" DependentValueBinding="{Binding Attributes[WINDSPEED]}"/>
</Charting:ColumnSeries>
</Charting:Chart.Series>
</Charting:Chart>
No clue.
Do you get something if you use the first version I gave that doesn't need any code:
<Charting:Chart> <Charting:Chart.Series> <Charting:ColumnSeries Title="Wind Speed" ItemsSource="{Binding ElementName=MyMap, Path=Layers[MyHurricaneFeatureLayer].Graphics}" IndependentValueBinding="{Binding Attributes[EVENTID]}" DependentValueBinding="{Binding Attributes[WINDSPEED]}"/> </Charting:ColumnSeries> </Charting:Chart.Series> </Charting:Chart>
<esri:ArcGISDynamicMapServiceLayer ID="WellsLayer" Opacity="0.8" Url="http://serverprd02/ArcGIS/rest/services/SilverLightDir/Wells_Timeline/MapServer" Initialized="ArcGISDynamicMapServiceLayer_Initialized" /> <esri:FeatureLayer ID="WellsFeatureLayer" Url="http://serverprd02/ArcGIS/rest/services/SilverLightDir/Wells_Timeline/MapServer/0" />
<charting:Chart HorizontalAlignment="Left" VerticalAlignment="Bottom">
<charting:Chart.Series>
<charting:ColumnSeries Title="Wind Speed" ItemsSource="{Binding ElementName=map1, Path=Layers[WellsLayer].Graphics}" IndependentValueBinding="{Binding Attributes[EOM]}" DependentValueBinding="{Binding Attributes[Adj_Close]}">
</charting:ColumnSeries>
</charting:Chart.Series>
</charting:Chart>
Path=Layers[WellsFeatureLayer].Graphics