1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 04:02:59 +08:00

ProfileLineChart layout implementation

This commit is contained in:
Andrei Zavatski 2020-11-14 04:46:26 +03:00
parent b9b47349ad
commit 9d8e7e8954
2 changed files with 103 additions and 0 deletions

View File

@ -0,0 +1,39 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Game.Overlays.Profile.Sections.Historical;
using osu.Framework.Graphics;
using static osu.Game.Users.User;
using System;
using osu.Game.Overlays;
using osu.Framework.Allocation;
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneProfileLineChart : OsuTestScene
{
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Pink);
public TestSceneProfileLineChart()
{
var values = new[]
{
new UserHistoryCount { Date = new DateTime(2010, 5, 1), Count = 1000 },
new UserHistoryCount { Date = new DateTime(2010, 6, 1), Count = 20 },
new UserHistoryCount { Date = new DateTime(2010, 7, 1), Count = 20000 },
new UserHistoryCount { Date = new DateTime(2010, 8, 1), Count = 30 },
new UserHistoryCount { Date = new DateTime(2010, 9, 1), Count = 50 },
new UserHistoryCount { Date = new DateTime(2010, 10, 1), Count = 2000 },
new UserHistoryCount { Date = new DateTime(2010, 11, 1), Count = 2100 }
};
Add(new ProfileLineChart
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Values = values
});
}
}
}

View File

@ -0,0 +1,64 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using JetBrains.Annotations;
using static osu.Game.Users.User;
namespace osu.Game.Overlays.Profile.Sections.Historical
{
public class ProfileLineChart : CompositeDrawable
{
private UserHistoryCount[] values;
[CanBeNull]
public UserHistoryCount[] Values
{
get => values;
set
{
values = value;
graph.Values = values;
}
}
private readonly UserHistoryGraph graph;
public ProfileLineChart()
{
RelativeSizeAxes = Axes.X;
Height = 250;
InternalChild = new GridContainer
{
RelativeSizeAxes = Axes.Both,
ColumnDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
new Dimension()
},
RowDimensions = new[]
{
new Dimension(),
new Dimension(GridSizeMode.AutoSize)
},
Content = new[]
{
new Drawable[]
{
Empty(),
graph = new UserHistoryGraph
{
RelativeSizeAxes = Axes.Both
}
},
new Drawable[]
{
Empty(),
Empty()
}
}
};
}
}
}