Select to view content in your preferred language

Charting Toolkit Column Series in a FeatureLayer MapTip?

3497
27
04-08-2010 08:02 AM
KevinStofan
New Contributor
I'm trying to nest a Column Chart in the MapTip output of a FeatureLayer. The three ColumnSeries in the markup below are three ways I have tried to get this to work. No errors come up in debug, but the graph does not display any data or populate the axes. TEL_TOT, MOB_TOT, and INT_TOT refer to OutFields of the FeatureLayer. Can this even be done with out any code behind? Any help would be greatly appreciated.

<chartingToolkit:Chart Title="Communication">
    <chartingToolkit:Chart.Series>
        <chartingToolkit:ColumnSeries
            Title="Telephone Users"
            ItemsSource="{Binding Converter={StaticResource FeatureDictionaryConverter},
                ConverterParameter=TEL_TOT, Mode=OneWay}"
            IndependentValueBinding="{Binding Key}"
            DependentValueBinding="{Binding Value}"/>
        <chartingToolkit:ColumnSeries
            Title="Mobile Users"
            ItemsSource="{Binding Converter={StaticResource FeatureDictionaryConverter},
                ConverterParameter=MOB_TOT, Mode=OneWay}"
            IndependentValuePath="Key"
            DependentValuePath="Value"/>
        <chartingToolkit:ColumnSeries
            Title="Internet Users"
            ItemsSource="{Binding Converter={StaticResource FeatureDictionaryConverter},
                ConverterParameter=MOB_TOT, Mode=OneWay}"
            IndependentValueBinding="{Binding Key}"
            DependentValueBinding="{Binding Value}" />
    </chartingToolkit:Chart.Series>
</chartingToolkit:Chart>
0 Kudos
27 Replies
DominiqueBroux
Esri Frequent Contributor

However, I would still like to remove the legend box.

You can edit the chart template with Blend and remove the legend (or less 'brute force' you should be able to edit the 'LegendStyle' as well).


Also, is there a work around for not being able to use a number as the Name? The underscore is unsightly.


The name of the Serie is coming from your definition of the IndependantVlaue : IndependentValueBinding="{Binding Name}" . It means that it's the name of your listbox item :
<ListBoxItem Name="_1998" Content="{Binding [tcmlatestcounts._1998], TargetNullValue={StaticResource zero}}" />

Is there any problem to remove the underscore from this name? If there is a problem, a workaround might be to use the 'Tag' property instead of the 'Name', i.e:
- IndependentValueBinding="{Binding Tag}"
and
- <ListBoxItem Tag="1998" Content="{Binding [tcmlatestcounts._1998], TargetNullValue={StaticResource zero}}" />
0 Kudos
MuhammadWaqar_ul_islam
Occasional Contributor
Need FULL CODE FOR XMAL AND C#
thanks
0 Kudos
DonFreeman
Emerging Contributor
Dominique -
The editor does not allow Names that begin with a number, hence the underscore. However your suggestion to use Tag in it's place worked great. Thanks

Now, is there a way I can concatenate 2 field values to produce the Title? Something like
<toolkit:Chart Title="{Binding [tcmlatestcounts._STREET+tcmlatestcounts._FROM]}" FontWeight="Bold"  Width="800" Height="400">
0 Kudos
DominiqueBroux
Esri Frequent Contributor
As the title can be any UIElement, you can define it as a stackpanel containing 2 TextBlocks.
0 Kudos
DonFreeman
Emerging Contributor
How would I do that? Does that mean I have to modify the chart template with a hundred lines of code?

Also another question, I'd like to show the actual value in text on top of the columns similar to the attached picture. Would there be a way to do this?
0 Kudos
DominiqueBroux
Esri Frequent Contributor

How would I do that? Does that mean I have to modify the chart template with a hundred lines of code?


No. Just define the chart title with this syntax:
 
<chartingToolkit:Chart ..............>
  <chartingToolkit:Chart.Title>
    <StackPanel Orientation="Horizintal">
      <TextBlock Text="{Binding ........}" />
      <TextBlock Text="{Binding ........}" />
    </StackPanel>
  </chartingToolkit:Chart.Title>
  ......
0 Kudos
DonFreeman
Emerging Contributor
Cool. I never know if its going to be simple or extremely difficult. How about my second question? Is there a way to place values on top of the bars?
0 Kudos
DominiqueBroux
Esri Frequent Contributor
How about my second question? Is there a way to place values on top of the bars?

Looks possible, but I didn't test it myself : https://msmvps.com/blogs/deborahk/archive/2011/02/19/silverlight-charting-displaying-data-above-the-...
0 Kudos