charts
charts copied to clipboard
Minor ticks not rendered when the property XAxis.minorTickInterval is set as a number
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
Is there a plan to fix this?
Still a valid issue on version 4.0.5
Still valid, also for 4.1.0.beta1