charts icon indicating copy to clipboard operation
charts copied to clipboard

Minor ticks not rendered when the property XAxis.minorTickInterval is set as a number

Open vaadin-bot opened this issue 8 years ago • 3 comments

Originally by stanik


Setting the attribute 'minorTickInterval' other then 'auto' causes incorrect rendering of the minor ticks. Sometimes only the first minor tick is rendered sometimes non is rendered.

The following code demonstrates the problem:

import com.vaadin.addon.charts.Chart;
import com.vaadin.addon.charts.examples.AbstractVaadinChartExample;
import com.vaadin.addon.charts.model.ChartType;
import com.vaadin.addon.charts.model.Configuration;
import com.vaadin.addon.charts.model.ListSeries;
import com.vaadin.addon.charts.model.XAxis;
import com.vaadin.ui.Component;

public class BasicLine extends AbstractVaadinChartExample {

    @Override
    public String getDescription() {
        return "Basic Line With Data Labels";
    }

     @Override
        protected Component getChart() {
            final Chart chart = new Chart();
            chart.setHeight("450px");
            chart.setWidth("100%");

            final Configuration configuration = chart.getConfiguration();
            configuration.setTitle("MinorTickInterval");

            configuration.getChart().setType(ChartType.SPLINE);

            final ListSeries series = new ListSeries(29.9, 71.5, 106.4, 129.2,
                    144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4);
            configuration.setSeries(series);

            XAxis xAxis = configuration.getxAxis();
            xAxis.setTickInterval(1);
            xAxis.setMinorTickInterval("0.2");
            xAxis.setMinorTickWidth(1);

            chart.drawChart(configuration);


            return chart;

        }

}

The source of this problem is that the numerical values are serialized in JSON as strings:

"minorTickInterval": "0.2"

If they were serialized as numbers then the chart would be rendered correctly:

"minorTickInterval": 0.2

Imported from https://dev.vaadin.com/ issue #20163

vaadin-bot avatar Aug 17 '16 12:08 vaadin-bot

Is there a plan to fix this?

SomMeri avatar Dec 11 '17 14:12 SomMeri

Still a valid issue on version 4.0.5

tepi avatar Aug 03 '18 11:08 tepi

Still valid, also for 4.1.0.beta1

seremel avatar Jan 30 '19 16:01 seremel