mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Handle empty values as a separate case
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -32,6 +33,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
AddStep("values from 1-10", () => graph.Values = Enumerable.Range(1, 10).Select(i => (float)i));
|
AddStep("values from 1-10", () => graph.Values = Enumerable.Range(1, 10).Select(i => (float)i));
|
||||||
AddStep("values from 1-100", () => graph.Values = Enumerable.Range(1, 100).Select(i => (float)i));
|
AddStep("values from 1-100", () => graph.Values = Enumerable.Range(1, 100).Select(i => (float)i));
|
||||||
AddStep("reversed values from 1-10", () => graph.Values = Enumerable.Range(1, 10).Reverse().Select(i => (float)i));
|
AddStep("reversed values from 1-10", () => graph.Values = Enumerable.Range(1, 10).Reverse().Select(i => (float)i));
|
||||||
|
AddStep("empty values", () => graph.Values = Array.Empty<float>());
|
||||||
AddStep("Bottom to top", () => graph.Direction = BarDirection.BottomToTop);
|
AddStep("Bottom to top", () => graph.Direction = BarDirection.BottomToTop);
|
||||||
AddStep("Top to bottom", () => graph.Direction = BarDirection.TopToBottom);
|
AddStep("Top to bottom", () => graph.Direction = BarDirection.TopToBottom);
|
||||||
AddStep("Left to right", () => graph.Direction = BarDirection.LeftToRight);
|
AddStep("Left to right", () => graph.Direction = BarDirection.LeftToRight);
|
||||||
|
@ -51,13 +51,18 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
if (!value.Any())
|
||||||
|
{
|
||||||
|
bars.Clear();
|
||||||
|
Invalidate(Invalidation.DrawNode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int newCount = value.Count();
|
int newCount = value.Count();
|
||||||
|
|
||||||
float size = newCount;
|
float size = 1.0f / newCount;
|
||||||
if (size != 0)
|
|
||||||
size = 1.0f / size;
|
|
||||||
|
|
||||||
float maxLength = MaxValue ?? (newCount == 0 ? 0 : value.Max());
|
float maxLength = MaxValue ?? value.Max();
|
||||||
|
|
||||||
foreach (var bar in value.Select((length, index) => new { Value = length, Index = index }))
|
foreach (var bar in value.Select((length, index) => new { Value = length, Index = index }))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user