Jump to content
Software FX Community

Creating a Stacked Bar Chart - Help


Recommended Posts


I am trying to create a stacked bar chart with a line and I am having some trouble.

I have some code below:

    Chart1.DataSourceSettings.Fields.Add(New FieldMap("Sold_For_USD", FieldUsage.Value))      Chart1.DataSourceSettings.Fields.Add(New FieldMap("Num_Deals", FieldUsage.Value))      'Chart1.DataSourceSettings.Fields.Add(New FieldMap("BuyOutExitType", FieldUsage.Value))      Chart1.DataSourceSettings.Fields.Add(New FieldMap("Heading", FieldUsage.Label))

The line chart should be  "Sold_For_USD" and the bar chart should be "Num_Deals" stacked against BuyOutExitType and the x axis should be Heading.

I know how to create a bar chart with a line using this code:

    ' THIS IS THE LINE CHART (Sold_For_USD)     Chart1.Series(0).Gallery = Gallery.Lines     Chart1.Series(0).AxisY.Title.Text = "Number of Deals"         Chart1.Series(1).AxisY = Chart1.AxisY2 ' ADD A SECOND Y AXIS     Chart1.Series(1).AxisY.Title.Text = "$bn"     ' THIS IS THE BAR CHART (Num_Deals)     Chart1.Series(1).Gallery = Gallery.Bar   Chart1.AllSeries.AxisY.Title.Text = "Number of Deals"


But I how do I make the bar chart stacked against "BuyOutExitType" I know i can use:

Chart1.AllSeries.Stacked = Stacked.Normal

but I don't know how to stack it against the  field in my query

Hope this makes sense

thanks in advanced




Link to comment
Share on other sites

Add the line at the end:

Chart1.DataSourceSettings.Fields.Add(New FieldMap("Num_Deals", FieldUsage.Value))

     'Chart1.DataSourceSettings.Fields.Add(New FieldMap("BuyOutExitType", FieldUsage.Value))

  Chart1.DataSourceSettings.Fields.Add(New FieldMap("Sold_For_USD", FieldUsage.Value))

Chart1.DataSourceSettings.Fields.Add(New FieldMap("Heading", FieldUsage.Label))

Then, after the data is read, set:

chart.Series[1].Gallery = Gallery.Lines; // Last series is series 1 (2 series)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...