I have a composite line chart with one x axis and up to 8 y axis. All is good. I have written some code to reset the tick intervals as needed and that works. Now I have two problems. I have axis.TimeAxisStyle.TimeAxisStyle = RulerGenre.Continuous. When I zoom and scroll the x axis values change and the chart area does not scroll only the lines and the x axis labels are pushed down underneath my legend. When I set axis.TimeAxisStyle.TimeAxisStyle = RulerGenre.Discrete the zoom/scroll behavior is what I want (the whole area to scroll left and right and keep x axis label static), however, the x axis disregards all the tickmark interval settings now and overlaps the layers if I choose a larger amount of data records to chart, but the labels are now up from underneath the legend.
Attached pic discreet.jpg show the overlapping and ignoring the tickmark settings
Attached pic continuous1.jpg show the chart set on continuous and the labels are good but continuous2.jpg shows what happens when I zoom/scroll.
continuous1
continuous2
Any ideas?
Hi Michael,
This does not appear to be the expected behavior for the chart. I attempted to reproduce the behavior you're showing here, but I wasn't successful. Are you able to share a sample project with us? I can create a private case if necessary.
Once I am able to reproduce the issue, I will write it up in our system for further review.
This code is embedded deep in an enterprise application but I can give you the core of the code. The data source is a simple data table with a date column (x-axis) and a numeric column (y-axis). SwapRowsAndColumns is set to false and ChartType is Composite.
My chart area is define in this method:
private ChartArea GetChartArea() { var area = new ChartArea(); area.Bounds = new Rectangle(0, 0, 100, 94); area.BoundsMeasureType = MeasureType.Percentage; return area; }
Here is the code that build the x-axis:
private AxisItem DefineXAxisItems(ChartArea area) { var axis = new AxisItem(); axis.ScrollScale.Visible = true; axis.ScrollScale.Scale = 1; axis.ScrollScale.Scroll = 0; axis.ScrollScale.Height = 16; axis.ScrollScale.Width = ultraChart.Width; axis.MajorGridLines.Color = Color.LightSlateGray; //axis.MinorGridLines.Visible = true; //axis.MinorGridLines.Color = Color.LightSlateGray; axis.Key = "Date"; axis.DataType = AxisDataType.Time; axis.Labels.ItemFormat = AxisItemLabelFormat.Custom; axis.Labels.ItemFormatString = "<ITEM_LABEL:MM/dd/yy HH:mm:ss>"; axis.Labels.Orientation = TextOrientation.Custom; axis.Labels.OrientationAngle = -30; axis.TickmarkIntervalType = AxisIntervalType.Hours; axis.TickmarkStyle = AxisTickStyle.Smart; axis.TimeAxisStyle.TimeAxisStyle = RulerGenre.Continuous; // RulerGenre.Discrete; axis.OrientationType = AxisNumber.X_Axis; axis.SetLabelAxisType = SetLabelAxisType.ContinuousData; area.Axes.Add(axis); return axis; }
Create enough data points to have more than 30 points (100 is a pretty good number) along your x-axis. The settings above will create the x-axis with the axis labels spaced apart. When you zoom the axis and then scroll from left to right the date labels will change as the y-axis line scrolls but not the x-axis gridlines.
Now change the axis.TimeAxisStyle.TimeAxisStyle to be RulerGenre.Discrete. Now watch all your x-axis labels be crammed together and overlapping. However, the zooming and scrolling now behaves as desired by having the x-axis major grid lines under the y-axis scroll with the y-axis and the date labels stay static. Even if I set TickmarkStyle to AxisTickStyle.DataInterval and set my TickmarkInterval to a number large enough to try and force the gridlines to spread out the chart ignores the setting and overlaps the x-axis labels.
I hope this helps.