diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserHistoryGraph.cs b/osu.Game.Tests/Visual/Online/TestSceneUserHistoryGraph.cs
index 57ce4c41e7..484c59695e 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneUserHistoryGraph.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneUserHistoryGraph.cs
@@ -19,13 +19,12 @@ namespace osu.Game.Tests.Visual.Online
{
UserHistoryGraph graph;
- Add(graph = new UserHistoryGraph
+ Add(graph = new UserHistoryGraph("Test")
{
RelativeSizeAxes = Axes.X,
Height = 200,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
- TooltipCounterName = "Test"
});
var values = new[]
diff --git a/osu.Game/Overlays/Profile/Sections/Historical/ChartProfileSubsection.cs b/osu.Game/Overlays/Profile/Sections/Historical/ChartProfileSubsection.cs
index b82773155d..a48036dcbb 100644
--- a/osu.Game/Overlays/Profile/Sections/Historical/ChartProfileSubsection.cs
+++ b/osu.Game/Overlays/Profile/Sections/Historical/ChartProfileSubsection.cs
@@ -15,6 +15,11 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{
private ProfileLineChart chart;
+ ///
+ /// Text describing the value being plotted on the graph, which will be displayed as a prefix to the value in the history graph tooltip.
+ ///
+ protected abstract string GraphCounterName { get; }
+
protected ChartProfileSubsection(Bindable user, string headerText)
: base(user, headerText)
{
@@ -30,7 +35,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
Left = 20,
Right = 40
},
- Child = chart = new ProfileLineChart()
+ Child = chart = new ProfileLineChart(GraphCounterName)
};
protected override void LoadComplete()
diff --git a/osu.Game/Overlays/Profile/Sections/Historical/PlayHistorySubsection.cs b/osu.Game/Overlays/Profile/Sections/Historical/PlayHistorySubsection.cs
index 2f15886c3a..dfd29db693 100644
--- a/osu.Game/Overlays/Profile/Sections/Historical/PlayHistorySubsection.cs
+++ b/osu.Game/Overlays/Profile/Sections/Historical/PlayHistorySubsection.cs
@@ -9,6 +9,8 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{
public class PlayHistorySubsection : ChartProfileSubsection
{
+ protected override string GraphCounterName => "Plays";
+
public PlayHistorySubsection(Bindable user)
: base(user, "Play History")
{
diff --git a/osu.Game/Overlays/Profile/Sections/Historical/ProfileLineChart.cs b/osu.Game/Overlays/Profile/Sections/Historical/ProfileLineChart.cs
index f02aa36b6c..eb5deb2802 100644
--- a/osu.Game/Overlays/Profile/Sections/Historical/ProfileLineChart.cs
+++ b/osu.Game/Overlays/Profile/Sections/Historical/ProfileLineChart.cs
@@ -42,7 +42,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
private readonly Container rowLinesContainer;
private readonly Container columnLinesContainer;
- public ProfileLineChart()
+ public ProfileLineChart(string graphCounterName)
{
RelativeSizeAxes = Axes.X;
Height = 250;
@@ -88,7 +88,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
}
}
},
- graph = new UserHistoryGraph
+ graph = new UserHistoryGraph(graphCounterName)
{
RelativeSizeAxes = Axes.Both
}
diff --git a/osu.Game/Overlays/Profile/Sections/Historical/ReplaysSubsection.cs b/osu.Game/Overlays/Profile/Sections/Historical/ReplaysSubsection.cs
index e594e8d020..1c28306f17 100644
--- a/osu.Game/Overlays/Profile/Sections/Historical/ReplaysSubsection.cs
+++ b/osu.Game/Overlays/Profile/Sections/Historical/ReplaysSubsection.cs
@@ -9,6 +9,8 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{
public class ReplaysSubsection : ChartProfileSubsection
{
+ protected override string GraphCounterName => "Replays Watched";
+
public ReplaysSubsection(Bindable user)
: base(user, "Replays Watched History")
{
diff --git a/osu.Game/Overlays/Profile/Sections/Historical/UserHistoryGraph.cs b/osu.Game/Overlays/Profile/Sections/Historical/UserHistoryGraph.cs
index b1e8c8f0ca..52831b4243 100644
--- a/osu.Game/Overlays/Profile/Sections/Historical/UserHistoryGraph.cs
+++ b/osu.Game/Overlays/Profile/Sections/Historical/UserHistoryGraph.cs
@@ -11,25 +11,28 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
{
public class UserHistoryGraph : UserGraph
{
+ private readonly string tooltipCounterName;
+
[CanBeNull]
public UserHistoryCount[] Values
{
set => Data = value?.Select(v => new KeyValuePair(v.Date, v.Count)).ToArray();
}
- ///
- /// Text describing the value being plotted on the graph, which will be displayed as a prefix to the value in the .
- ///
- public string TooltipCounterName { get; set; } = "Plays";
+ public UserHistoryGraph(string tooltipCounterName)
+ {
+ this.tooltipCounterName = tooltipCounterName;
+ }
protected override float GetDataPointHeight(long playCount) => playCount;
- protected override UserGraphTooltip GetTooltip() => new HistoryGraphTooltip(TooltipCounterName);
+ protected override UserGraphTooltip GetTooltip() => new HistoryGraphTooltip(tooltipCounterName);
protected override object GetTooltipContent(DateTime date, long playCount)
{
return new TooltipDisplayContent
{
+ Name = tooltipCounterName,
Count = playCount.ToString("N0"),
Date = date.ToString("MMMM yyyy")
};
@@ -37,14 +40,17 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
protected class HistoryGraphTooltip : UserGraphTooltip
{
+ private readonly string tooltipCounterName;
+
public HistoryGraphTooltip(string tooltipCounterName)
: base(tooltipCounterName)
{
+ this.tooltipCounterName = tooltipCounterName;
}
public override bool SetContent(object content)
{
- if (!(content is TooltipDisplayContent info))
+ if (!(content is TooltipDisplayContent info) || info.Name != tooltipCounterName)
return false;
Counter.Text = info.Count;
@@ -55,6 +61,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
private class TooltipDisplayContent
{
+ public string Name;
public string Count;
public string Date;
}