Page view counter

Bubbles – 1 Chart – three Axes

 

In this follow up to yesterday's blog post about the Bubbles Chart available from the December Release of the Silverlight Toolkit, I'd like to explore the unique advantages the bubbles chart provides for finding outliers in many real world situations.

The scenario I'm contriving is this: I'd like to examine two vital sets of (fictional) information at once

  • How many blog blog posts and videos have we created on each of 8 important topics
  • On average, how interested are our members in each of these topics.

I could create two charts and compare them side by side, but a bubbles chart instantly identifies where I have problems and where I'm on track…

ThreeWayFullView

In this chart, the larger the bubble the greater the average user interest, on a scale of 0 to 100.  The Y axis (on the left side) is the number of blog entries and videos on the topic (the negative numbers are an artifact of accommodating a large bubble that falls below zero), the X axis lists the 9 topics (at the moment, the bubbles chart can only place integers and dates, so my Topics class uses an ID and a lookup, explained below. Clicking on a bubble causes its information to be displayed above.

The bubble I've clicked on in the image above is number 5 (Skinning) and it is indicating we've got it about right, the interest level is 60 out of 100, and we've done 125 posts which is tracking appropriately.  In the cropped image below I focus on two outliers,

ThreeWayBubbles

The tiny bubble up at 350 indicates that we have a topic of little interest that we are spending too much time on, and the giant bubble down around 0 (actually indicating 5 posts) is a sure sign we have a high interest topic that we're ignoring. An equal sized bubble up and to the right shows a high interest topic we are covering well.

Key here is that at a glance we've identified two problems that are easily missed without this chart, and easily solved with this information.

How It Works

 

 

The implementation is very much as you saw yesterday. To get to the heart of it, I created a single page version that has only  the following files:

  • Page.xaml
  • Page.xaml.cs
  • App.xaml
  • App.xaml.cs
  • BlogTopic.cs

The App.xaml files. Page.Xaml is posted, here is an excerpt that illustrates the important points…

  <Grid
    x:Name="Layout"
    Background="White">
    <Grid.RowDefinitions>
      //….
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
       //….
   </Grid.ColumnDefinitions>
    <Border  //….  />
    <TextBlock
      x:Name="Message" //… />
    <charting:Chart
      x:Name="DrillDownChart"
      BorderBrush="Gray"
      Margin="1"
      Grid.Row="1"
      Grid.ColumnSpan="3">
      <charting:Chart.Series>
        <charting:BubbleSeries
          Title="."
         IndependentValueBinding="{Binding TopicID}"
          DependentValueBinding="{Binding NumberOfPosts}"
          SizeValueBinding="{Binding AverageRating}" />

      </charting:Chart.Series>
    </charting:Chart>
  </Grid>
</UserControl>

The three lines that matter are the binding of the Independent and Dependent values and the SizeValue. These are bound to properties of the BlogTopic class which, as you've seen with other classes, both defines its members and defines a static method to generate the data we'll need.

In this case, since I need to provide integers for the IndependentValueBinding, I provide a TopicID as an integer, and a static Dictionary that maps these integers to strings (e.g., TopicID 2 = Web Services.  The complete listing for BlogTopic.cs  is posted, here is an excerpt,

namespace Bubbles3D
{
  public class BlogTopic
  {
   public static Dictionary<int, string> Topics =
          new Dictionary<int, string>();

    public int TopicID { get; set; }
    public int NumberOfPosts { get; set; }
    public double AverageRating { get; set; }


    public static List<BlogTopic> CreateData()
    {
      Topics.Add( 1, "Toolkit" );
      Topics.Add( 2, "Web Services" );
       //….

      List<BlogTopic> BlogTopics = new List<BlogTopic>();

      BlogTopics.Add(
        new BlogTopic() {
              TopicID = 1,
            NumberOfPosts = 250,
            AverageRating = 65 } );
             //….
      return BlogTopics;
    }

Finally, the only remaining code is in the Page.xaml.cs where the ItemSource must be attached to the bubble series and the Selection changed event must be handled.  Here is that code in full,

using System.Windows.Controls;
using System.Collections.Generic;
using System.Windows;

using Microsoft.Windows.Controls.DataVisualization.Charting;
namespace Bubbles3D
{
  public partial class Page : UserControl
  {
    private List<BlogTopic> blogTopics;
    public Page()
    {
      InitializeComponent();
      Loaded += 
          new System.Windows.RoutedEventHandler( Page_Loaded );
    }

    void Page_Loaded( 
          object sender, System.Windows.RoutedEventArgs e )
    {
      BubbleSeries bSeries = 
             DrillDownChart.Series[0] as BubbleSeries;
      blogTopics = BlogTopic.CreateData();
      bSeries.ItemsSource = blogTopics;
      bSeries.IsSelectionEnabled = true;
      bSeries.SelectionChanged += 
           new SelectionChangedEventHandler( bSeries_SelectionChanged );
      Message.Text = 
          "Larger bubbles are more popular, higher bubbles are are topics with more articles";
    }

    void bSeries_SelectionChanged( 
      object sender, SelectionChangedEventArgs e )
    {
      if ( e.AddedItems.Count > 0 )
      {
        BlogTopic blogTopic = e.AddedItems[0] as BlogTopic;
        Layout.DataContext = blogTopic;
        Message.Text = blogTopic.NumberOfPosts.ToString() + 
             " posts on " + 
              BlogTopic.Topics[blogTopic.TopicID] + 
              " with an average interest of  " + 
              blogTopic.AverageRating.ToString() + 
              " on a scale of 0 to 100";
      }
    }
  }
}
 
Source: Bubbles3D.zip
Published Thursday, December 18, 2008 8:00 AM by jesseliberty
Filed under: ,

Comments

# Dew Drop - December 19, 2008 | Alvin Ashcraft's Morning Dew

Pingback from  Dew Drop - December 19, 2008 | Alvin Ashcraft's Morning Dew

Friday, December 19, 2008 10:40 AM by Dew Drop - December 19, 2008 | Alvin Ashcraft's Morning Dew

# Silverlight Toolkit: Bubble chart at Programming with Silverlight, WPF &amp; .NET

Pingback from  Silverlight Toolkit: Bubble chart at Programming with Silverlight, WPF &amp; .NET

# Silverlight Cream for December 20, 2008 -- #462

In this issue: Nikhil Kothari, David Wynne, Damon Payne, Laurent Bugnion, Terence Tsang, Scott Morrison

Saturday, December 20, 2008 5:08 PM by Community Blogs

# My new home page, expanded [Updated collection of great Silverlight Charting resources!]

It's been a couple of months since I shared my semi-comprehensive page of Charting resources on the web

Friday, February 06, 2009 2:30 AM by Delay's Blog

# Resources for Silverlight Charting and others

Overviews ( 100 level ) Silverlight Toolkit Released – More controls! - Tim Heuer 's during the PDC keynote

Wednesday, February 11, 2009 12:48 AM by Felix Wang | Evangelizing the Next Web

# Tutoriales para Silverlight

En el blog de Felix Wang , he encontrado este art&iacute;culo donde se agrupan una colecci&oacute;n de

Thursday, February 19, 2009 4:10 AM by DotNetClub Complutense Madrid

# The Bubble Chart - Silverlight Toolkit

Pingback from  The Bubble Chart - Silverlight Toolkit

Monday, March 09, 2009 6:13 PM by The Bubble Chart - Silverlight Toolkit

# Sparkling Client Podcast on The Bubble Chart

&#160; &#160; I'm very pleased to provide this link to a brief discussion with Erik Mork about the Bubble

Tuesday, March 10, 2009 11:40 PM by

# Sparkling Client Podcast on The Bubble Chart

I'm very pleased to provide this link to a brief discussion with Erik Mork about the Bubble Chart from

Wednesday, March 11, 2009 12:18 AM by Microsoft Weblogs

# Top-silverlight &raquo; Blog Archive &raquo; My new home page, extended [Updated collection of great Silverlight and WPF Charting resources!]

Pingback from  Top-silverlight  &raquo; Blog Archive   &raquo; My new home page, extended [Updated collection of great Silverlight and WPF Charting resources!]

# My new home page, enhanced [Updated collection of great Silverlight/WPF Data Visualization resources!]

In the time since posting my last collection of Silverlight/WPF Charting links , there's been some great

Monday, July 20, 2009 5:40 AM by Microsoft Weblogs

# Easing in Silverlight 3 Animations

Pingback from  Easing in Silverlight 3 Animations

Thursday, August 13, 2009 12:36 PM by Easing in Silverlight 3 Animations

# Silverlight 3 Element Binding

Pingback from  Silverlight 3 Element Binding

Thursday, August 20, 2009 11:48 AM by Silverlight 3 Element Binding