Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
180
Xamtimeline: overlappimg series and titles
posted

Hello!

I have a timeline where I want to show two series. My current timeline looks like this:

As you can see, the blue series is overlapping with the green series. How can I achieve that the blue series is above the green series, so that I can see the green series completely?

And I also have enough space above the series, how can I show the titles without overlapping?

Here is the code I'm using:

DateTimeAxis dateAxis = new DateTimeAxis();

dateAxis.Minimum = this._shiftStart.AddMinutes(-30);
dateAxis.Maximum = this._shiftEnd.AddMinutes(30);
dateAxis.AutoRange = false;
dateAxis.UnitType = DateTimeUnitType.Minutes;
dateAxis.Unit = 30;

DateTimeSeries timelineSeries = new DateTimeSeries();
timelineSeries.Position = Position.TopOrLeft;
timelineSeries.Fill = new SolidColorBrush(Colors.Blue);
timelineSeries.HollowFill = new SolidColorBrush(Colors.Blue);

DateTimeSeries timelineSeriesTotal = new DateTimeSeries();
timelineSeriesTotal.Position = Position.TopOrLeft;
timelineSeriesTotal.Fill = new SolidColorBrush(Colors.Green);
timelineSeriesTotal.HollowFill = new SolidColorBrush(Colors.Green);

EventTitleLayoutSettings settings = new EventTitleLayoutSettings();
settings.Enabled = false;
settings.HorizontalOffset = 20;
settings.VerticalOffset = 15;

Style zoomBarStyle = this.FindResource("ZoombarStyle") as Style;
Style legendStyle = this.FindResource("LegendStyle") as Style;
Style sceneStyle = this.FindResource("SceneStyle") as Style;

foreach (var job in item.employeeJobs)
{
try
{
var entry = CreateTimelineEntry(job);

if (entry != null)
{
timelineSeries.Entries.Add(entry);
}
//timelineSeries.Entries.Add(CreateTimelineEntry(job));
}
catch (Exception ex)
{
Log.Error(ex);
}

DateTimeEntry newEntry2 = new DateTimeEntry();
newEntry2.Time = job.startTime.AddMinutes(30);
newEntry2.Duration = job.endTime - job.startTime;
newEntry2.Title = job.job;
newEntry2.Details = "Details\nDetails\nDetails\nDetails";

timelineSeriesTotal.Entries.Add(newEntry2);
}

XamTimeline timeline = new XamTimeline();
timeline.Foreground = new SolidColorBrush(Colors.Black);
timeline.Height = 300;//150
timeline.Width = 1600;
timeline.ZoombarStyle = zoomBarStyle;

timeline.LegendStyle = legendStyle;

timeline.VerticalAlignment = VerticalAlignment.Bottom;
timeline.HorizontalAlignment = HorizontalAlignment.Left;

timeline.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FF0089FF"));

timeline.VerticalContentAlignment = VerticalAlignment.Bottom;

timeline.SceneStyle = sceneStyle;

timeline.FontWeight = FontWeights.Normal;

timeline.Axis = dateAxis;

timeline.Series.Add(timelineSeriesTotal);

timeline.Series.Add(timelineSeries);

timeline.EventTitleLayoutSettings = settings;

CreateTimelineEntry just creates a new entry.

If you need more information, please let me know!

Parents
  • 34430
    Offline posted

    Hello Nicolas,

    With the code that you have provided, the simplest way to prevent the series from overlapping would be to set the Position property to the opposite value "BottomOrRight" for one of them. This will place one of your series below the labels on your DateTimeAxis, and will prevent them from overlapping. Of course, this sort of fails if you have more than two series that would overlap.

    Another option would be to possibly style the EventSpan objects such that they are stacked. An example of this can be found here: https://www.infragistics.com/community/forums/f/ultimate-ui-for-wpf/49045/how-to-stack-eventspan-eventpoint.

    Regarding the labels overlapping, this is due to the setting of "false" for the Enabled property of the EventTitleLayoutSettings object. This will prevent the label-collision algorithm from taking place, and will allow the labels of your timeline entries to overlap. I would recommend removal of this setting if you wish for the labels to not collide or overlap.

    Please let me know if you have any other questions or concerns on this matter.

    Sincerely,
    Andrew
    Associate Developer

Reply Children
No Data