Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gantt Chart functionality in LiveCharts2 for Uno #1471

Open
butti71 opened this issue Mar 26, 2024 · 1 comment
Open

Gantt Chart functionality in LiveCharts2 for Uno #1471

butti71 opened this issue Mar 26, 2024 · 1 comment

Comments

@butti71
Copy link

butti71 commented Mar 26, 2024

Is your feature request related to a problem? Please describe.
In an old version of LiveCharts you added the Gantt Chart functionality (Issue #351) which I found very promising! I tried to access that functionality in an Uno App with livechart2, but it is not available any more.

Describe the solution you'd like
Gantt chart functionality as described here: (Issue #351)

Describe alternatives you've considered
Using the SkiaSharp library to create my own Gantt view.

Additional context
Screenshot about the feature request:
image

@drissoun
Copy link

drissoun commented Apr 5, 2024

I did find a solution: Use StackedRowSeries.

  1. You would create a mapper for your task class like so :LiveCharts.Configure(config => config.HasMap<Task>((Taks, point) => new(Task.ID, Task.Duration)));
  2. Then, in your ViewModel, for each of your task :
  • you would create first another decoy task that starts at 0 and lasts until the start of the task you want to draw. On each of the decoy taks, assign a specific field, such as bool VoidForGraph = true;
  • add them both to a serie like so:
    Series.Add(new StackedRowSeries<Task> {values = [decoyTask,Task], DataLabelsFormatter = (point) => (point.Model?.VoidForGraph ? "" : $"{(point.Model?.Name is null ? "" : point.Model.Name)}starts {point.Model.Start:N2} ends {point.Model.End:N2} }
  • use a conditionnal formated so that the decoyTask is not visible, such as
    .OnPointMeasured(point => { if (point.Visual is null) return; point.Visual.Stroke = point.Model?.Status == JobStatus.VoidForGraph ? Null : new SolidColorPaint(SKColors.Blue); })
  1. Fine tune as you want with DataLabelFormaters, colors, other broken tasks etc...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants