mdewilde / chart

Java library for use with Chart.js javascript library
Apache License 2.0
112 stars 43 forks source link

Support ScaleLabel on axis #16

Closed bischoffdev closed 5 years ago

bischoffdev commented 6 years ago

In char.js, setting individual labels on each axis is possible. However, I could not find a way to do that in your library.

            "yAxes": [{
                "ticks": {
                    "min": 0
                },
                stacked: true,
                scaleLabel: {
                    display: true,
                    labelString: "Step Runtime"
                }
            }

Am I overseeing something?

Best, Benjamin

yaeljoyas commented 5 years ago

You would have to extend the XAxis and YAxis class to add this functionality.

import be.ceau.chart.options.scales.ScaleLabel; import be.ceau.chart.options.scales.XAxis; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(JsonInclude.Include.NON_EMPTY) @JsonAutoDetect( fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE ) public class ChartXAxis extends XAxis { private ScaleLabel scaleLabel;

public ScaleLabel getScaleLabel() {
    return this.scaleLabel;
}

public XAxis setScaleLabel(ScaleLabel scaleLabel) {
    this.scaleLabel = scaleLabel;
    return super.setDisplay(true);
}

}

Do the same for YAxis and you'll be able to add the scale label

bischoffdev commented 5 years ago

Hi, thanks for your answer. However, I wrote my own charting library in the meantime so this is not required anymore.

DOFandersolsen commented 5 years ago

I just hit the same issue, so I would ask for this to be added to this library :-)