Current filter:
                                You should refresh the page.
                                Support Center
                                  • I am trying to create a Gantt chart dynamically in the backend code of a web service. The chart will demonstrate shift information for a specific day for a specific Unit.

                                    The code below is for creating the chart and then adding the chart to a callback panel which will be used to refresh the chart when a different unit is selected from a Gridview.

                                    This chart however draws the gantt chart as one long pixel on the 23rd of August and ranges from the 22nd to the 24th. I just wish to show the data over the specific 24 hour period according to the date of the information.

                                    I have attached an image that shows a graph created using the chart wizard on the design view of the default page as a reference for the look I am trying to achieve and below it the dynamically created chart.

                                    protected void drawChart() { WebChartControl wbc = new WebChartControl(); wbc.PaletteName = "Trek"; wbc.Legend.Visible = false; wbc.Series.Add(new Series("Shift 1", ViewType.SideBySideGantt)); wbc.Series[0].ValueScaleType = ScaleType.DateTime; wbc.Series.Add(new Series("Shift 2", ViewType.SideBySideGantt)); wbc.Series[1].ValueScaleType = ScaleType.DateTime; wbc.Series.Add(new Series("Shift 3", ViewType.SideBySideGantt)); wbc.Series[2].ValueScaleType = ScaleType.DateTime; wbc.Series[0].Points.Add(new SeriesPoint("FEL 2046", new DateTime[] { new DateTime(2012, 8, 23, 0, 0, 0), new DateTime(2012, 8, 23, 4, 0, 0) })); wbc.Series[1].Points.Add(new SeriesPoint("FEL 2046", new DateTime[] { new DateTime(2012, 8, 23, 8, 0, 0), new DateTime(2012, 8, 23, 14, 0, 0) })); wbc.Series[2].Points.Add(new SeriesPoint("FEL 2046", new DateTime[] { new DateTime(2012, 8, 23, 16, 0, 0), new DateTime(2012, 8, 23, 21, 0, 0) })); wbc.Series.AddRange(new Series[] { wbc.Series[0], wbc.Series[1], wbc.Series[2] }); SideBySideGanttSeriesView gView = (SideBySideGanttSeriesView)wbc.Series[1].View; gView.MaxValueMarker.Visible = true; gView.MaxValueMarker.Kind = MarkerKind.Star; gView.MaxValueMarker.StarPointCount = 5; gView.MaxValueMarker.Size = 10; gView.BarWidth = 0.5; wbc.Width = cbpChart.Width; wbc.Height = cbpChart.Height; cbpChart.Controls.Add(wbc); }

                                1 Solution

                                Creation Date Rating Importance Sort by

                                To prevent this behavior set the AxisBase.DateTimeGridAlignment and AxisBase.DateTimeMeasureUnit properties to Hour.

                                • Donald Dunlop 02.14.2013


                                  I assume you mean the wbc.Diagram properties AxisBase.DateTimeGridAlignment and AxisBase.DateTimeMeasureUnit should be set to hours but every time I try access the wbc.Diagram there is just a null object there. Is there any reason for this?


                                • Thank you for your response. It is necessary to add WebChartControl to the Page.Controls collection before accessing the diagram and its properties (e.g. see Control 'ctl02_CallbackState' of type 'InternalHiddenField' must be placed inside a form tag with runat=server). Please update your code accordingly and let us know if you need any clarification.

                                • Donald Dunlop 02.14.2013


                                  I've added the line
                                  to my code and am able to access the wbc.Diagram object however there is no option for setting it's AxisBase I can access it's AxisX elements, however assigning these values to hour does not change the graph and the display remains the same as in my original post

                                  GanttDiagram gDiagram = (GanttDiagram)wbc.Diagram;
                                  gDiagram.AxisX.DateTimeGridAlignment = DateTimeMeasurementUnit.Hour;
                                  gDiagram.AxisX.DateTimeMeasureUnit = DateTimeMeasurementUnit.Hour;

                                • The Gantt diagram is already rotated. So, set these properties for Y axis:

                                  GanttDiagram gDiagram = (GanttDiagram)wbc.Diagram; gDiagram.AxisY.DateTimeGridAlignment = DateTimeMeasurementUnit.Hour; gDiagram.AxisY.DateTimeMeasureUnit = DateTimeMeasurementUnit.Hour;
                                • Donald Dunlop 02.14.2013

                                  Thank you for all the help, I figured it out as you responded to the post here. Much appreciated

                                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