Search in sources :

Example 81 with SolidColor

use of com.vaadin.addon.charts.model.style.SolidColor 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 82 with SolidColor

use of com.vaadin.addon.charts.model.style.SolidColor 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

SolidColor (com.vaadin.addon.charts.model.style.SolidColor)82 Configuration (com.vaadin.addon.charts.model.Configuration)55 Chart (com.vaadin.addon.charts.Chart)54 YAxis (com.vaadin.addon.charts.model.YAxis)40 DataSeries (com.vaadin.addon.charts.model.DataSeries)27 ListSeries (com.vaadin.addon.charts.model.ListSeries)26 XAxis (com.vaadin.addon.charts.model.XAxis)26 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)25 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)19 DataLabels (com.vaadin.addon.charts.model.DataLabels)18 Legend (com.vaadin.addon.charts.model.Legend)17 GradientColor (com.vaadin.addon.charts.model.style.GradientColor)15 Marker (com.vaadin.addon.charts.model.Marker)14 Tooltip (com.vaadin.addon.charts.model.Tooltip)14 Style (com.vaadin.addon.charts.model.style.Style)14 Labels (com.vaadin.addon.charts.model.Labels)12 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)11 Random (java.util.Random)10 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)9 PlotOptionsSpline (com.vaadin.addon.charts.model.PlotOptionsSpline)8