patelajk Posted April 16, 2010 Report Share Posted April 16, 2010 Hi 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 Quote Link to comment Share on other sites More sharing options...
Frank Posted April 21, 2010 Report Share Posted April 21, 2010 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) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.