Add an XAxisTicksPerLabel property to LineGraphWidget
This commit is contained in:
@@ -35,6 +35,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
public string YAxisValueFormat = "{0}";
|
public string YAxisValueFormat = "{0}";
|
||||||
public int XAxisSize = 10;
|
public int XAxisSize = 10;
|
||||||
public int YAxisSize = 10;
|
public int YAxisSize = 10;
|
||||||
|
public int XAxisTicksPerLabel = 1;
|
||||||
public string XAxisLabel = "";
|
public string XAxisLabel = "";
|
||||||
public string YAxisLabel = "";
|
public string YAxisLabel = "";
|
||||||
public bool DisplayFirstYAxisValue = false;
|
public bool DisplayFirstYAxisValue = false;
|
||||||
@@ -77,6 +78,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
YAxisValueFormat = other.YAxisValueFormat;
|
YAxisValueFormat = other.YAxisValueFormat;
|
||||||
XAxisSize = other.XAxisSize;
|
XAxisSize = other.XAxisSize;
|
||||||
YAxisSize = other.YAxisSize;
|
YAxisSize = other.YAxisSize;
|
||||||
|
XAxisTicksPerLabel = other.XAxisTicksPerLabel;
|
||||||
XAxisLabel = other.XAxisLabel;
|
XAxisLabel = other.XAxisLabel;
|
||||||
YAxisLabel = other.YAxisLabel;
|
YAxisLabel = other.YAxisLabel;
|
||||||
DisplayFirstYAxisValue = other.DisplayFirstYAxisValue;
|
DisplayFirstYAxisValue = other.DisplayFirstYAxisValue;
|
||||||
@@ -178,7 +180,10 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
for (int n = pointStart, x = 0; n <= pointEnd; n++, x += xStep)
|
for (int n = pointStart, x = 0; n <= pointEnd; n++, x += xStep)
|
||||||
{
|
{
|
||||||
cr.DrawLine(graphOrigin + new float2(x, 0), graphOrigin + new float2(x, -5), 1, Color.White);
|
cr.DrawLine(graphOrigin + new float2(x, 0), graphOrigin + new float2(x, -5), 1, Color.White);
|
||||||
var xAxisText = GetXAxisValueFormat().F(n);
|
if (n % XAxisTicksPerLabel != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var xAxisText = GetXAxisValueFormat().F(n / XAxisTicksPerLabel);
|
||||||
var xAxisTickTextWidth = labelFont.Measure(xAxisText).X;
|
var xAxisTickTextWidth = labelFont.Measure(xAxisText).X;
|
||||||
var xLocation = x - (xAxisTickTextWidth / 2);
|
var xLocation = x - (xAxisTickTextWidth / 2);
|
||||||
labelFont.DrawTextWithShadow(xAxisText, graphOrigin + new float2(xLocation, 2), Color.White, BackgroundColorDark, BackgroundColorLight, 1);
|
labelFont.DrawTextWithShadow(xAxisText, graphOrigin + new float2(xLocation, 2), Color.White, BackgroundColorDark, BackgroundColorLight, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user