Search in sources :

Example 26 with GradientColor

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

Example 27 with GradientColor

use of com.vaadin.addon.charts.model.style.GradientColor in project charts by vaadin.

the class ColorFactoryTests method create_noColorInStops_DesignExceptionIsThrown.

@Test(expected = DesignException.class)
public void create_noColorInStops_DesignExceptionIsThrown() {
    Element element = createColorElement("<background-color><linear-gradient x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"></linear-gradient>" + "<stops position=\"0\"></stops>" + "<stops position=\"1\" color=\"black\"></stops>" + "</background-color>");
    GradientColor color = ColorFactory.createGradient(element);
}
Also used : GradientColor(com.vaadin.addon.charts.model.style.GradientColor) Element(org.jsoup.nodes.Element) Test(org.junit.Test)

Example 28 with GradientColor

use of com.vaadin.addon.charts.model.style.GradientColor in project charts by vaadin.

the class ColorFactoryTests method create_linearColor_colorIsCreatedWithCorrectParametersAndStops.

@Test
public void create_linearColor_colorIsCreatedWithCorrectParametersAndStops() {
    Element element = createColorElement("<background-color><linear-gradient x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"></linear-gradient>" + "<stops position=\"0\" color=\"white\"></stops>" + "<stops position=\"1\" color=\"black\"></stops>" + "</background-color>");
    GradientColor color = ColorFactory.createGradient(element);
    assertNotNull(color.getLinearGradient());
    assertNull(color.getRadialGradient());
    assertEquals(0d, color.getLinearGradient().getX1());
    assertEquals(0d, color.getLinearGradient().getY1());
    assertEquals(1d, color.getLinearGradient().getX2());
    assertEquals(1d, color.getLinearGradient().getY2());
}
Also used : GradientColor(com.vaadin.addon.charts.model.style.GradientColor) Element(org.jsoup.nodes.Element) Test(org.junit.Test)

Example 29 with GradientColor

use of com.vaadin.addon.charts.model.style.GradientColor in project charts by vaadin.

the class ColorFactoryTests method create_doubleNotParsable_DesignExceptionIsThrown.

@Test(expected = DesignException.class)
public void create_doubleNotParsable_DesignExceptionIsThrown() {
    Element element = createColorElement("<background-color><linear-gradient x1=\"abc\" y1=\"0\" x2=\"1\" y2=\"1\"></linear-gradient>" + "<stops position=\"0\" color=\"white\"></stops>" + "<stops position=\"1\" color=\"black\"></stops>" + "</background-color>");
    GradientColor color = ColorFactory.createGradient(element);
}
Also used : GradientColor(com.vaadin.addon.charts.model.style.GradientColor) Element(org.jsoup.nodes.Element) Test(org.junit.Test)

Aggregations

GradientColor (com.vaadin.addon.charts.model.style.GradientColor)29 Configuration (com.vaadin.addon.charts.model.Configuration)18 Chart (com.vaadin.addon.charts.Chart)15 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)15 YAxis (com.vaadin.addon.charts.model.YAxis)13 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)9 Test (org.junit.Test)9 ListSeries (com.vaadin.addon.charts.model.ListSeries)8 Marker (com.vaadin.addon.charts.model.Marker)8 PlotOptionsArea (com.vaadin.addon.charts.model.PlotOptionsArea)7 Element (org.jsoup.nodes.Element)7 Hover (com.vaadin.addon.charts.model.Hover)6 DataLabels (com.vaadin.addon.charts.model.DataLabels)5 DataSeries (com.vaadin.addon.charts.model.DataSeries)5 Labels (com.vaadin.addon.charts.model.Labels)5 PlotOptionsGauge (com.vaadin.addon.charts.model.PlotOptionsGauge)5 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)4 States (com.vaadin.addon.charts.model.States)4 Background (com.vaadin.addon.charts.model.Background)3 Dial (com.vaadin.addon.charts.model.Dial)3