Search in sources :

Example 1 with DesignContext

use of com.vaadin.ui.declarative.DesignContext in project charts by vaadin.

the class ChartDesignWriterTest method writeConfiguration_arrayNode_theValuesInArrayAreSeparatedWithComma.

@Test
public void writeConfiguration_arrayNode_theValuesInArrayAreSeparatedWithComma() {
    DesignContext designContext = new DesignContext();
    Configuration configuration = new Configuration();
    configuration.getxAxis().setCategories("Jan", "Feb", "Mar");
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    assertEquals("<x-axis><categories>Jan, Feb, Mar</categories></x-axis>", removeWhitespacesBetweenTags(parent.child(0).toString()));
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Element(org.jsoup.nodes.Element) DesignContext(com.vaadin.ui.declarative.DesignContext) Test(org.junit.Test)

Example 2 with DesignContext

use of com.vaadin.ui.declarative.DesignContext in project charts by vaadin.

the class ChartDesignWriterTest method writeConfiguration_axisPropertyIsSet_theValueIsAddedAsAttribute.

@Test
public void writeConfiguration_axisPropertyIsSet_theValueIsAddedAsAttribute() {
    DesignContext designContext = new DesignContext();
    Configuration configuration = new Configuration();
    configuration.getyAxis().setMin(-5);
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    assertEquals("<y-axis min=\"-5\"></y-axis>", parent.child(0).toString());
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Element(org.jsoup.nodes.Element) DesignContext(com.vaadin.ui.declarative.DesignContext) Test(org.junit.Test)

Example 3 with DesignContext

use of com.vaadin.ui.declarative.DesignContext in project charts by vaadin.

the class ChartDesignWriterTest method writeConfiguration_multiplePlotOptions_allPlotOptionsAreChildrenOfPlotOptionsTag.

@Test
public void writeConfiguration_multiplePlotOptions_allPlotOptionsAreChildrenOfPlotOptionsTag() {
    DesignContext designContext = new DesignContext();
    Configuration configuration = new Configuration();
    PlotOptionsLine plotOptionsLine = new PlotOptionsLine();
    plotOptionsLine.setAnimation(false);
    PlotOptionsSpline plotOptionsSpline = new PlotOptionsSpline();
    plotOptionsSpline.setVisible(false);
    configuration.setPlotOptions(plotOptionsLine, plotOptionsSpline);
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    // Expected (the order of plot options is unknown):
    // "<plot-options>
    // <line animation=\"false\">
    // </line>
    // <spline visible=\"false\">
    // </spline>
    // </plot-options>"
    assertEquals("plot-options", parent.child(0).tagName());
    Elements plotOptions = parent.child(0).children();
    assertEquals(2, plotOptions.size());
    assertPlotOptions("line", "animation", "false", plotOptions);
    assertPlotOptions("spline", "visible", "false", plotOptions);
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) Element(org.jsoup.nodes.Element) DesignContext(com.vaadin.ui.declarative.DesignContext) PlotOptionsSpline(com.vaadin.addon.charts.model.PlotOptionsSpline) Elements(org.jsoup.select.Elements) Test(org.junit.Test)

Example 4 with DesignContext

use of com.vaadin.ui.declarative.DesignContext in project charts by vaadin.

the class ChartDesignWriterTest method writeConfiguration_enableDataLabelsInPlotoptions_plotOptionsElementHasInnerTypeElement.

@Test
public void writeConfiguration_enableDataLabelsInPlotoptions_plotOptionsElementHasInnerTypeElement() {
    DesignContext designContext = new DesignContext();
    Configuration configuration = new Configuration();
    DataLabels dataLabels = new DataLabels(true);
    PlotOptionsLine plotOptionsLine = new PlotOptionsLine();
    plotOptionsLine.setDataLabels(dataLabels);
    configuration.setPlotOptions(plotOptionsLine);
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    assertEquals("<plot-options><line><data-labels enabled></data-labels></line></plot-options>", removeWhitespacesBetweenTags(parent.child(0).toString()));
}
Also used : DataLabels(com.vaadin.addon.charts.model.DataLabels) Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) Element(org.jsoup.nodes.Element) DesignContext(com.vaadin.ui.declarative.DesignContext) Test(org.junit.Test)

Example 5 with DesignContext

use of com.vaadin.ui.declarative.DesignContext in project charts by vaadin.

the class ChartDesignWriterTest method writeConfiguration_enumValueDefinedInConfiguration_theValueIsAddedAsAttribute.

@Test
public void writeConfiguration_enumValueDefinedInConfiguration_theValueIsAddedAsAttribute() {
    DesignContext designContext = new DesignContext();
    Configuration configuration = new Configuration();
    Legend legend = new Legend();
    legend.setLayout(LayoutDirection.VERTICAL);
    configuration.setLegend(legend);
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    assertEquals("<legend layout=\"vertical\"></legend>", parent.child(0).toString());
}
Also used : Legend(com.vaadin.addon.charts.model.Legend) Configuration(com.vaadin.addon.charts.model.Configuration) Element(org.jsoup.nodes.Element) DesignContext(com.vaadin.ui.declarative.DesignContext) Test(org.junit.Test)

Aggregations

Configuration (com.vaadin.addon.charts.model.Configuration)22 DesignContext (com.vaadin.ui.declarative.DesignContext)22 Element (org.jsoup.nodes.Element)22 Test (org.junit.Test)22 Elements (org.jsoup.select.Elements)4 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)3 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)2 Legend (com.vaadin.addon.charts.model.Legend)2 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)2 GradientColor (com.vaadin.addon.charts.model.style.GradientColor)2 DataLabels (com.vaadin.addon.charts.model.DataLabels)1 PlotLine (com.vaadin.addon.charts.model.PlotLine)1 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)1 PlotOptionsFlags (com.vaadin.addon.charts.model.PlotOptionsFlags)1 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)1 Title (com.vaadin.addon.charts.model.Title)1