Skip to content

Styling LinearScale needs full config of axis #11

@benweidig

Description

@benweidig

Hi,

I'm trying to style a linear scale (just fontStyle and fontColor) of a LineChart:

LinearTicks ticks = new LinearTicks().setFontStyle(FontStyle.BOLD);
LinearScale axis = new LinearScale().setTicks(ticks);
LinearScales scales = new LinearScales().addxAxis(axis)
LineOptions options = new LineOptions().setScales(scales);

The problem is that the LinearScale always puts the property type: "linear" into the the tick config, and chartjs then wants me to configure all the other stuff for the ticks/scale and no data is displayed if not.

If I remove the the property from the chart JSON config object before initializing the Chart with delete json.options.scales.xAxes[0].type it's formating as expected.

Workaround for me was creating a class TypelessLinearScale extends LinearScale with @JsonIgnore on an overriden getType().

Not sure how to handle this problem "nicely", a type-less Scale would be nice, but setOptions(...) on LineOptions needs a LinearScale and not a Scale<?> or something.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions