How do I place labels on a Bubble chart?

5 posts, 0 answers
  1. Ross
    Ross avatar
    3 posts
    Member since:
    Jul 2010

    Posted 15 Sep 2010 Link to this post

    I cant seem to figure out how to work with a bubble chart.
    My two problems are
    1) How do I place a label on each bubble? Am I using the correct chart type?
    2) Putting two series in place, the chart puts the bubbles on the same place.

    I have a chart displayed with no data, and 3 buttons. One for each year.
    When I click the year button, the WCF comes back and draws bubbles, but no label is displayed for each bubble.
    Changing to a Line3DSeriesDefinition shows the label fine but I dont want that chart type. Scatter series maybe, but then no lable appears either.
    Next problem is clicking a 2nd year button puts an new series of bubble on, but they are on top of the first series. Why are they not placed on different points as the data is different?

    Here is my xmal.
    -----------------
    <telerik:RadChart x:Name="chtChart"
          Margin="10"
          Grid.Row="1"
          Grid.ColumnSpan="3"
          BorderThickness="1,1,1,1"
          d:LayoutOverrides="Height" >
     <control:RadChart.Background>
      <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
       <GradientStop Color="#FFF8F8F8" Offset="1"/>
       <GradientStop Color="#FFD2CB1A"/>
       <GradientStop Color="{StaticResource ChartBgBrush}" Offset="0.392"/>
      </LinearGradientBrush>
     </control:RadChart.Background>
    </telerik:RadChart>
    -----------------

    Here's my C#
    ------------------------------
     void btnYear_Click(object sender, RoutedEventArgs e)
     {
      var MyService = new BrandDataServiceReference.BrandzWcfServiceClient();
      MyService.GetChartDataCompleted += new EventHandler<BrandDataServiceReference.GetChartDataCompletedEventArgs>(MyService_GetChartDataCompleted);
      MyService.GetChartDataAsync(Convert.ToInt32(((Button)sender).DataContext.ToString()));
     }

     void MyService_GetChartDataCompleted(object sender, BrandDataServiceReference.GetChartDataCompletedEventArgs e)
     {

      SeriesMapping seriesMapping = new SeriesMapping();
      seriesMapping.SeriesDefinition = new BubbleSeriesDefinition();
      seriesMapping.LegendLabel = Convert.ToString(e.Result[0].Year);
      seriesMapping.ItemMappings.Add(new ItemMapping("X_Value", DataPointMember.XValue));
      seriesMapping.ItemMappings.Add(new ItemMapping("Y_Value", DataPointMember.YValue));
    // Lines below dont do anything
      seriesMapping.ItemMappings.Add(new ItemMapping("Name", DataPointMember.Label));
      seriesMapping.ItemMappings.Add(new ItemMapping("Name", DataPointMember.Tooltip));
    // Lines above dont do anything
      chtChart.ItemsSource = e.Result;
      chtChart.SeriesMappings.Add(seriesMapping);
     }

    ------------------------------

  2. Ross
    Ross avatar
    3 posts
    Member since:
    Jul 2010

    Posted 15 Sep 2010 Link to this post

    The chart shown with blue bubbles is produced when I click the 2010 button.
    The 2nd picture is 1/2 way through the re-draw that happens when I click the 2009 button.
    When finished, all that you see is the red bubbles, as the blueones are benieth the red
    The data is different,. so why are the points on top of each other?
    Where are the bubble labels?

  3. Evgenia
    Admin
    Evgenia avatar
    1437 posts

    Posted 20 Sep 2010 Link to this post

    Hi Ross,

    To be able to see item labels for bubbles you should turn on ShowItemLabels property as it is set to false by default. You can do this in the constructor of BubbleSeriesDefinition:

    series.Definition = new BubbleSeriesDefinition() { ShowItemLabels=true };

    The overlapping of bubbles when they are added as different series seems quite strange. Could you provide us with an example, which show this, so we will be able to investigate the issue? Thank you.

    All the best,
    Evgenia
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  4. Ross
    Ross avatar
    3 posts
    Member since:
    Jul 2010

    Posted 20 Sep 2010 Link to this post

    Hi Evgenia
    thanks for the reply.
    I can now get the lables, is easy once you know how isnt it?
    I've also figured out what I'm doing wrong re: same bubbles appearing.
    If you look at my code, I've defining the series definition then binding it to the e.result returned by my WCF service.
    Every time I add another dataset, I am binding it to the new result set, so of course its appearing in the same place.
    So, my question is:

    Having already drawn a chart and displayed a set of bubbles on it, can I (how do I) place a new set of bubbles in addition to the existing set? Do I need to redraw the whole chart with both sets of data?

    Thanks
    Ross

  5. Evgenia
    Admin
    Evgenia avatar
    1437 posts

    Posted 23 Sep 2010 Link to this post

    Hi Ross,

    I'm glad you figured your problem "same bubbles appearing" on your own. I'm sorry but it's impossible to
    place a new set of bubbles in addition to the existing set with databinding. What I can suggest you are 2 approaches:
    1. You can collect and manage all the data you need to show in the chart in a collection of collections. Then databind all the data at once. Databinding to nested collections allows the chart to be data bound to a collection/array nested inside another collection/array. For more information take a look at this help topic - http://www.telerik.com/help/silverlight/radchart-populating-with-data-data-binding-to-nested-collections.html
    2. Add data series manually as described here - http://www.telerik.com/help/silverlight/radchart-populating-with-data-creating-chart-in-code-behind.html. Each time you get new data you can add  new data series to the chart.

    Hope this helps.

    Greetings,
    Evgenia
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top