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()));
}
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());
}
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="color:{series.color}">{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());
}
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());
}
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()));
}
Aggregations