Search in sources :

Example 11 with DesignContext

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

the class ChartDesignWriterTest method writeConfiguration_plotOptionsWithReservedPropertyWord_prefixIsWrittenToReservedProperty.

@Test
public void writeConfiguration_plotOptionsWithReservedPropertyWord_prefixIsWrittenToReservedProperty() {
    DesignContext designContext = new DesignContext();
    Configuration configuration = new Configuration();
    PlotOptionsFlags plotOptionsFlags = new PlotOptionsFlags();
    // plotOptionsFlags.setAllowPointSelect(true);
    plotOptionsFlags.setOnSeries("dataseries");
    configuration.addPlotOptions(plotOptionsFlags);
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    assertEquals("<plot-options><flags draw-on-series=\"dataseries\"></flags></plot-options>", 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) PlotOptionsFlags(com.vaadin.addon.charts.model.PlotOptionsFlags) Test(org.junit.Test)

Example 12 with DesignContext

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

the class ChartDesignTest method readAndWriteConfiguration_basicLineChart_theOutputHtmlIsTheSameAsInput.

@Test
public void readAndWriteConfiguration_basicLineChart_theOutputHtmlIsTheSameAsInput() {
    String testHtml = "<chart margin-bottom=\"25\" margin-right=\"130\"></chart>\n" + // "<legend align=\"right\" border-width=\"0\" layout=\"vertical\" vertical-align=\"top\" x=\"-10\" y=\"100\"></legend>\n" +
    "<plot-options>\n" + " <line>\n" + "  <data-labels enabled=''></data-labels>\n" + " </line>\n" + "</plot-options>";
    Elements elements = createElements(testHtml);
    Configuration configuration = new Configuration();
    Element parent = new Element(Tag.valueOf("test"), "");
    DesignContext designContext = new DesignContext();
    ChartDesignReader.readConfigurationFromElements(elements, configuration);
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    // Workaround for https://github.com/vaadin/framework/issues/10703
    assertEquals(testHtml.replaceAll("=''", ""), parent.html());
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Element(org.jsoup.nodes.Element) DesignContext(com.vaadin.ui.declarative.DesignContext) Elements(org.jsoup.select.Elements) Test(org.junit.Test)

Example 13 with DesignContext

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

the class ChartDesignTest method readAndWriteConfiguration_compareMultipleSeries_theOutputHtmlIsTheSameAsInput.

@Test
public void readAndWriteConfiguration_compareMultipleSeries_theOutputHtmlIsTheSameAsInput() {
    String testHtml = "<chart-title text=\"AAPL Stock Price\"></chart-title>\n" + "<y-axis>\n" + " <labels formatter=\"function() {return (this.value > 0 ? ' + ' : '') + this.value + '%';}\"></labels>\n" + " <plot-lines value=\"0\" width=\"2\"></plot-lines>\n" + "</y-axis>\n" + "<tooltip point-format=\"<span style=&quot;color:{series.color}&quot;>{series.name}</span>: <b>{point.y}</b>\n" + "({point.change}%)<br/>\" value-decimals=\"2\"></tooltip>\n" + "<plot-options>\n" + " <series compare=\"percent\"></series>\n" + "</plot-options>\n" + "<range-selector selected=\"4\"></range-selector>";
    Elements elements = createElements(testHtml);
    Configuration configuration = new Configuration();
    Element parent = new Element(Tag.valueOf("test"), "");
    DesignContext designContext = new DesignContext();
    ChartDesignReader.readConfigurationFromElements(elements, configuration);
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    assertEquals(testHtml, parent.html());
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Element(org.jsoup.nodes.Element) DesignContext(com.vaadin.ui.declarative.DesignContext) Elements(org.jsoup.select.Elements) Test(org.junit.Test)

Example 14 with DesignContext

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

the class ChartDesignTest method readAndWriteConfiguration_treemapWithLevels_theOutputHtmlIsTheSameAsInput.

@Test
public void readAndWriteConfiguration_treemapWithLevels_theOutputHtmlIsTheSameAsInput() {
    String testHtml = "<chart-title text=\"Fruit consumption\"></chart-title>\n" + "<plot-options>\n" + " <treemap alternate-starting-direction='' layout-algorithm=\"stripes\">\n" + "  <levels layout-algorithm=\"sliceanddice\" level=\"1\">\n" + "   <data-labels align=\"left\" enabled='' vertical-align=\"top\">\n" + "    <chart-style font-weight=\"bold\" font-size=\"15px\"></chart-style>\n" + "   </data-labels>\n" + "  </levels>\n" + " </treemap>\n" + "</plot-options>";
    Elements elements = createElements(testHtml);
    Configuration configuration = new Configuration();
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignReader.readConfigurationFromElements(elements, configuration);
    DesignContext designContext = new DesignContext();
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    // Workaround for https://github.com/vaadin/framework/issues/10703
    assertEquals(testHtml.replaceAll("=''", ""), parent.html());
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Element(org.jsoup.nodes.Element) DesignContext(com.vaadin.ui.declarative.DesignContext) Elements(org.jsoup.select.Elements) Test(org.junit.Test)

Example 15 with DesignContext

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

the class ChartDesignWriterTest method writeConfiguration_plotOptionsWithReservedWord_prefixIsWrittenToReservedTagName.

@Test
public void writeConfiguration_plotOptionsWithReservedWord_prefixIsWrittenToReservedTagName() {
    DesignContext designContext = new DesignContext();
    Configuration configuration = new Configuration();
    PlotOptionsArea plotOptionsArea = new PlotOptionsArea();
    plotOptionsArea.setAnimation(false);
    configuration.addPlotOptions(plotOptionsArea);
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    assertEquals("<plot-options><chart-area animation=\"false\"></chart-area></plot-options>", removeWhitespacesBetweenTags(parent.child(0).toString()));
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsArea(com.vaadin.addon.charts.model.PlotOptionsArea) 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