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

Make XAxis and YAxis extend an Axis class #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 38 additions & 43 deletions src/axis.vala
Original file line number Diff line number Diff line change
@@ -1,44 +1,18 @@
namespace LiveChart {
namespace LiveChart {

public class XAxis {

public float tick_interval { get; set; default = 10;}
public float tick_length { get; set; default = 60;}
public bool visible { get; set; default = true; }
public Labels labels = new Labels();
public Path axis = new Path();
public Path lines = new Path();

public XAxis() {
axis.color = {0.5, 0.5, 0.5, 0.5};
lines.color = {0.5, 0.5, 0.5, 0.2};
}

public double get_ratio() {
return tick_length / tick_interval;
}
}

public struct Ticks {
Gee.List<float?> values;
public Ticks() {
values = new Gee.ArrayList<float?>();
}
}

public class YAxis {
private Bounds bounds = new Bounds();
public abstract class Axis {
public Bounds bounds = new Bounds();
private double ratio = 1;

public float ratio_threshold { get; set; default = 1.118f;}
public float tick_interval { get; set; default = 60;}
public float tick_interval { get; set; default = 60; }
public bool visible { get; set; default = true; }

public Labels labels = new Labels();
public Path axis = new Path();
public LiveChart.Path lines = new LiveChart.Path();

[Version (deprecated = true, deprecated_since = "1.0.0b7")]
[Version (deprecated = true, deprecated_since = "1.0.0b7")]
public float tick_length { get; set; default = 60;}
public string unit { get; set; default = "";}

Expand All @@ -48,16 +22,6 @@ namespace LiveChart {
public double? fixed_max;
public Ticks ticks;

public YAxis(string unit = "") {
this.unit = unit;
ticks = get_ticks();
axis.color = {0.5, 0.5, 0.5, 0.5};
lines.color = {0.5, 0.5, 0.5, 0.2};
bounds.notify["upper"].connect(() => {
this.ticks = get_ticks();
});
}

public double get_ratio() {
return this.ratio;
}
Expand All @@ -74,7 +38,7 @@ namespace LiveChart {
if (bounds.has_upper() && this.fixed_max == null) {
this.ratio = (double) area_height / ((double) bounds.upper * ratio_threshold);
}

if (this.fixed_max != null) {
this.ratio = (double) area_height / ((double) this.fixed_max);
}
Expand Down Expand Up @@ -126,4 +90,35 @@ namespace LiveChart {
return ticks;
}
}
}

public struct Ticks {
Gee.List<float?> values;
public Ticks() {
values = new Gee.ArrayList<float?>();
}
}

public class XAxis : Axis {
public XAxis() {
tick_interval = 10;
axis.color = {0.5, 0.5, 0.5, 0.5};
lines.color = {0.5, 0.5, 0.5, 0.2};
}

public new double get_ratio() {
return tick_length / tick_interval;
}
}

public class YAxis : Axis {
public YAxis(string unit = "") {
this.unit = unit;
ticks = get_ticks();
axis.color = {0.5, 0.5, 0.5, 0.5};
lines.color = {0.5, 0.5, 0.5, 0.2};
bounds.notify["upper"].connect(() => {
this.ticks = get_ticks();
});
}
}
}