Current filter:
                                You should refresh the page.
                                Support Center
                                  • We currently have a report with a Gantt chart showing one solid bar for each "resource" that is associated with a "task". One of our customers has asked us to allow them to specify groups of resources for a task (in addition to the individual resources with separate bars) and to show a stripe within the bar for each resource within the group. A bar might have a single color (for one resource) or it might have two, three or more parallel stripes running the length of the bar for a group of resources. Is this possible?

                                    I am attaching a mock-up of a chart in case my explanation is not clear.

                                    Thank you.


                                1 Solution

                                Creation Date Rating Importance Sort by

                                Our ChartControl does not provide such a functionality. The only possible solution is to draw required stripes manually, in the CustomPaint event handler. To determine the required coordinates use DiagramToPoint and PointTodiagram methods.

                                • Neal Kaloupek 07.16.2013


                                  I eventually got this working after roughly 16 hours' work searching online and doing a lot of stumbling. To be honest your reply could have been more helpful if you had given more references, a code sample or other guidance - especially since there is no program code or example referenced from any of the links that you provided.

                                  For the benefit of anyone who wants to do something similar, I found the following to be helpful:
                                   (How to convert axis values of series points into screen coordinates)
                                   (Bar width in pixels )

                                  Following is a portion of my program code. Outside of this code I have a dictionary of Resource => Color and I have put the Resource name(s) into the Series.Point.Argument, prefixed by a "!". Multiple resource names are separated by commas:

                                   private void xrChartGantt_CustomPaint(object sender, CustomPaintEventArgs e)
                                              List<Color> rectangleColorList = new List<Color>();
                                              int barWidth = 0;
                                              int partialBarWidth = 0;

                                              XRChart chart = (XRChart)sender;
                                              Series series = chart.Series[0];

                                              for (int i = 0; i < series.Points.Count; i++)
                                                  if (series.Points[i].Argument.Substring(series.Points[i].Argument.IndexOf('!') + 1).Contains(','))
                                                      string[] resourceNames = series.Points[i].Argument.Substring(series.Points[i].Argument.IndexOf('!') + 1).Split(new char[] { ',' });
                                                      List<string> resourceList = new List<string>();
                                                      for (int j = 0; j < resourceNames.Count(); j++)
                                                          resourceNames[j] = resourceNames[j].Trim();
                                                          // Only keep resources that aren't filtered out
                                                          if (dictResourceColor.ContainsKey(resourceNames[j]))

                                                      ControlCoordinates cc1 = ((XYDiagram2D)chart.Diagram).DiagramToPoint(series.Points[0].Argument, series.Points[0].Values[0]);
                                                      ControlCoordinates cc2 = null;
                                                      if (series.Points.Count > 1)
                                                          cc2 = ((XYDiagram2D)chart.Diagram).DiagramToPoint(series.Points[1].Argument, series.Points[1].Values[0]);
                                                      // If there's one point, calculate the bar width using double its Y position; otherwise use the difference between the first and second points
                                                      barWidth = Convert.ToInt32(Math.Round((series.Points.Count <= 1 ? cc1.Point.Y * 2 : (cc2.Point.Y - cc1.Point.Y)) * ((OverlappedGanttSeriesView)chart.Series[0].View).BarWidth, 0));
                                                      partialBarWidth = barWidth / resourceList.Count();

                                                      // Get right and left points for the bar
                                                      ControlCoordinates ccLeft = ((XYDiagram2D)chart.Diagram).DiagramToPoint(series.Points[i].Argument, series.Points[i].Values[0]);
                                                      ControlCoordinates ccRight = ((XYDiagram2D)chart.Diagram).DiagramToPoint(series.Points[i].Argument, series.Points[i].Values[1]);

                                                      // Go through resources and create a rectangle for each.
                                                      for (int j = 0; j < resourceList.Count(); j++)
                                                          // Point.Y is the middle of the axis point. Start the rectangle half a bar width above that.
                                                          Point upperLeft = new Point(ccLeft.Point.X, ccLeft.Point.Y - barWidth / 2 + partialBarWidth * j);
                                                          Rectangle r = new Rectangle(upperLeft, new Size(ccRight.Point.X - ccLeft.Point.X, partialBarWidth));
                                                          e.Graphics.DrawRectangle(new Pen(this.dictResourceColor[resourceList[j]]), r);
                                                          SolidBrush brush = new SolidBrush(this.dictResourceColor[resourceList[j]]);
                                                          e.Graphics.FillRectangle(brush, r);

                                • Thank you for your sample code. I believe that it will be helpful to our customers.

                                If you need additional product information, write to us at or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2017 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners