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

Take prefix/suffix TickSettings into account and add format option #1146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public String toString() {

/** Controls the display of prefixes, suffixes, and exponents on ticks */
public enum DisplayRules {
ALL("outside"),
ALL("all"),
FIRST("first"),
LAST("last"),
NONE("none");
Expand Down Expand Up @@ -132,6 +132,7 @@ public String toString() {
private final int angle;
private final String prefix;
private final String suffix;
private final String format;
private final boolean autoMargin;
private final DisplayRules showPrefix;
private final DisplayRules showSuffix;
Expand Down Expand Up @@ -167,6 +168,7 @@ private TickSettings(TickSettingsBuilder builder) {
angle = builder.angle;
prefix = builder.prefix;
suffix = builder.suffix;
format = builder.format;
mirror = builder.mirror;
separateThousands = builder.separateThousands;
}
Expand Down Expand Up @@ -204,6 +206,7 @@ protected void updateContext(Map<String, Object> context) {
context.put("suffix", suffix);
context.put("showPrefix", showPrefix);
context.put("showSuffix", showSuffix);
context.put("format", format);
context.put("angle", angle);
context.put("autoMargin", autoMargin);
context.put("tickMode", tickMode);
Expand Down Expand Up @@ -239,6 +242,7 @@ public static class TickSettingsBuilder {
private boolean autoMargin = true;
private DisplayRules showPrefix = ALL;
private DisplayRules showSuffix = ALL;
private String format;
private Mirror mirror;
private boolean separateThousands;

Expand Down Expand Up @@ -399,6 +403,11 @@ public TickSettings.TickSettingsBuilder suffix(String suffix) {
return this;
}

public TickSettings.TickSettingsBuilder format(String format) {
this.format = format;
return this;
}

/**
* TODO: this is pretty hack-y. Add a separate method for dealing with dates and maybe clean up
* logs too
Expand Down
15 changes: 15 additions & 0 deletions jsplot/src/main/resources/axis_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@
{% if tick0 is not null %}
tick0: '{{tick0}}',
{% endif %}
{% if showPrefix is not null %}
showtickprefix: '{{showPrefix}}',
{% endif %}
{% if showSuffix is not null %}
showticksuffix: '{{showSuffix}}',
{% endif %}
{% if prefix is not null %}
tickprefix: '{{prefix}}',
{% endif %}
{% if suffix is not null %}
ticksuffix: '{{suffix}}',
{% endif %}
{% if format is not null %}
tickformat: '{{format}}',
{% endif %}
{% if showExponent is not null %}
showExponent: '{{showExponent}}',
{% endif %}
Expand Down