Search in sources :

Example 1 with ChartType

use of com.vaadin.addon.charts.model.ChartType in project charts by vaadin.

the class ChartComponentMapper method tagToComponent.

@Override
public Component tagToComponent(String tagName, Design.ComponentFactory componentFactory, DesignContext context) {
    boolean isChartTag = Pattern.matches("^vaadin-.*-chart$", tagName);
    if (isChartTag) {
        String[] split = tagName.split("-");
        if (split.length != 3) {
            throw new DesignException("Unknown tag: " + tagName);
        }
        String typeName = split[1];
        ChartType chartType = resolveChartTypeFor(typeName);
        if (chartType == null) {
            throw new DesignException("Unknown tag: " + tagName);
        }
        return new Chart(chartType);
    }
    return super.tagToComponent(tagName, componentFactory, context);
}
Also used : DesignException(com.vaadin.ui.declarative.DesignException) ChartType(com.vaadin.addon.charts.model.ChartType) Chart(com.vaadin.addon.charts.Chart)

Aggregations

Chart (com.vaadin.addon.charts.Chart)1 ChartType (com.vaadin.addon.charts.model.ChartType)1 DesignException (com.vaadin.ui.declarative.DesignException)1