none
[Excel]Adding multiple series to a chart

    Question

  • Hi,

    I'd like to create a BubleGraph chart, with multiple series. Each series must have only one bubble point.

    My excel table contains 3 columns, each row represents a serie :

    - A contains the labels I want to use for series name.

    - B contains the Y value for the unique serie point.

    - C contains the X value for the unique serie point.

    Here's my code

    Excel.WorkSheet resultSheet = _app.ActiveSheet;
    Excel.ChartObjects chartObjects = resultSheet.ChartObjects();
    Excel.ChartObject chartObject = chartObjects.Add(300, 10, 640, 480);
    Excel.Chart chart = chartObject.Chart;
    chart.ChartType = Excel.XlChartType.xlBubble3DEffect;
    
    chart.ChartWizard(resultSheet.Cells.Range["B2", "C2"]);
                
    Excel.SeriesCollection col = chart.SeriesCollection();
    Excel.Series series = col.Item(1);         
            
    series.XValues = resultSheet.Cells.Range["C2"];
    series.Values = resultSheet.Cells.Range["B2"];
    

    This code adds one series, with one bubble point (C2 contains the X value of the bubble, and B2 the Y value).

    After this, I'm able to add a new serie, but I'm not able to add data to this serie.

     Excel.Series series2 = col.NewSeries();
    series2.XValues = resultSheet.Cells.Range["C3"];
    series2.Values = resultSheet.Cells.Range["B3"];

    This adds a second serie, but it's empty.

     

    Thank you

    • Moved by Cindy Meister MVPMVP Friday, July 02, 2010 5:57 PM Excel-related question (From:Visual Studio Tools for Office)
    Friday, July 02, 2010 2:51 PM

Answers

  • I'm using Excel 2007.

    "Possibilities - you want different colors for each bubble - that is a built-in option.  you want to have a different data label with each point, you can do that. "

    Yes, I want both.

    I've managed to do want I want : I don't use the ChartWizart or SetDataSource function. I create an empty graph, and for each bubble, an empty serie. Then, I set the Value, XValue and serie Name.

    I know I don't "really" need bubbles, I use them for the graphical rendering. I prefer them than the plot marks.

     

    Monday, July 05, 2010 8:47 AM

All replies

  • What version of Excel are you using?

    And before I go - what is the reason to make each point a separate series?  Possibilities - you want different colors for each bubble - that is a built-in option.  you want to have a different data label with each point, you can do that.  For example you might want to look at Jon Peltier's free chart labels utility, which has code you can see.

    Jon Peltier's charting http://peltiertech.com/Excel/Charts/


    If this answer solves your problem, please check Mark as Answered. If this answer helps, please click the Vote as Helpful button. Cheers, Shane Devenshire

    Saturday, July 03, 2010 5:44 AM
  • I'm using Excel 2007.

    "Possibilities - you want different colors for each bubble - that is a built-in option.  you want to have a different data label with each point, you can do that. "

    Yes, I want both.

    I've managed to do want I want : I don't use the ChartWizart or SetDataSource function. I create an empty graph, and for each bubble, an empty serie. Then, I set the Value, XValue and serie Name.

    I know I don't "really" need bubbles, I use them for the graphical rendering. I prefer them than the plot marks.

     

    Monday, July 05, 2010 8:47 AM
  • I've managed to do want I want : I don't use the ChartWizart or SetDataSource function. I create an empty graph, and for each bubble, an empty serie. Then, I set the Value, XValue and serie Name.

    I know I don't "really" need bubbles, I use them for the graphical rendering. I prefer them than the plot marks.

     

    Hello Baobaz,

    Do you mean you got it working already? Is there any other help you need on this?

     

    Best regards,
    Ji Zhou - MSFT
    Microsoft Online Community Support

     


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Friday, July 09, 2010 8:28 AM
    Moderator