Search in sources :

Example 21 with DesignContext

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

the class ChartDesignWriterTest method writeConfiguration_chartHasSolidColor_theSolidColorIsWrittenAsAttribute.

@Test
public void writeConfiguration_chartHasSolidColor_theSolidColorIsWrittenAsAttribute() {
    DesignContext designContext = new DesignContext();
    Configuration configuration = new Configuration();
    configuration.getChart().setBackgroundColor(new SolidColor("black"));
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    assertEquals("<chart background-color=\"black\"></chart>", 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) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) Test(org.junit.Test)

Example 22 with DesignContext

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

the class ChartDesignWriterTest method writeConfiguration_chartHasRadialGradientBackgroundColor_theRadialGradientIsWrittenAsElement.

@Test
public void writeConfiguration_chartHasRadialGradientBackgroundColor_theRadialGradientIsWrittenAsElement() {
    Configuration configuration = new Configuration();
    DesignContext designContext = new DesignContext();
    GradientColor gradientColor = GradientColor.createRadial(0.5, 0.3, 0.7);
    gradientColor.addColorStop(0, new SolidColor("black"));
    gradientColor.addColorStop(1, new SolidColor("white"));
    configuration.getChart().setBackgroundColor(gradientColor);
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    assertEquals("<chart><background-color><radial-gradient cx=\"0.5\" cy=\"0.3\" r=\"0.7\"></radial-gradient>" + "<stops position=\"0\" color=\"black\"></stops>" + "<stops position=\"1\" color=\"white\"></stops>" + "</background-color></chart>", removeWhitespacesBetweenTags(parent.child(0).toString()));
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) GradientColor(com.vaadin.addon.charts.model.style.GradientColor) Element(org.jsoup.nodes.Element) DesignContext(com.vaadin.ui.declarative.DesignContext) SolidColor(com.vaadin.addon.charts.model.style.SolidColor) 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