Search in sources :

Example 31 with Configuration

use of com.vaadin.addon.charts.model.Configuration in project charts by vaadin.

the class ChartDesignWriterTest method writeConfiguration_plotLines_thePlotLinesAreTheElement.

@Test
public void writeConfiguration_plotLines_thePlotLinesAreTheElement() {
    DesignContext designContext = new DesignContext();
    Configuration configuration = new Configuration();
    PlotLine plotLine = new PlotLine();
    plotLine.setValue(0);
    plotLine.setWidth(2);
    configuration.getyAxis().setPlotLines(plotLine);
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    assertEquals("<y-axis><plot-lines value=\"0\" width=\"2\"></plot-lines></y-axis>", 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) PlotLine(com.vaadin.addon.charts.model.PlotLine) Test(org.junit.Test)

Example 32 with Configuration

use of com.vaadin.addon.charts.model.Configuration 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 33 with Configuration

use of com.vaadin.addon.charts.model.Configuration in project charts by vaadin.

the class ChartDesignReaderTest method readConfiguration_axisTitleHasTextOnlyContent_theContentIsSetAsTitleText.

@Test
public void readConfiguration_axisTitleHasTextOnlyContent_theContentIsSetAsTitleText() {
    Elements elements = createElements("<y-axis><chart-title>my title</chart-title></y-axis>");
    Configuration configuration = new Configuration();
    ChartDesignReader.readConfigurationFromElements(elements, configuration);
    assertEquals("my title", configuration.getyAxis().getTitle().getText());
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Elements(org.jsoup.select.Elements) Test(org.junit.Test)

Example 34 with Configuration

use of com.vaadin.addon.charts.model.Configuration in project charts by vaadin.

the class ChartDesignReaderTest method readConfiguration_multiplePlotOptions_attributesAreReadToCorrectPlotOptions.

@Test
public void readConfiguration_multiplePlotOptions_attributesAreReadToCorrectPlotOptions() {
    Elements elements = createElements("<plot-options>" + "<line animation=\"true\"></line>" + "<spline animation=\"false\"></spline>" + "</plot-options>");
    Configuration configuration = new Configuration();
    ChartDesignReader.readConfigurationFromElements(elements, configuration);
    PlotOptionsLine line = (PlotOptionsLine) configuration.getPlotOptions(ChartType.LINE);
    PlotOptionsSpline spline = (PlotOptionsSpline) configuration.getPlotOptions(ChartType.SPLINE);
    assertFalse(spline.getAnimation());
    assertTrue(line.getAnimation());
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) Elements(org.jsoup.select.Elements) PlotOptionsSpline(com.vaadin.addon.charts.model.PlotOptionsSpline) Test(org.junit.Test)

Example 35 with Configuration

use of com.vaadin.addon.charts.model.Configuration in project charts by vaadin.

the class ChartDesignReaderTest method readConfiguration_multiplePlotOptions_plotOptionsLineIsAddedToConfiguration.

@Test
public void readConfiguration_multiplePlotOptions_plotOptionsLineIsAddedToConfiguration() {
    Elements elements = createElements("<plot-options><line></line><spline></spline></plot-options>");
    Configuration configuration = new Configuration();
    ChartDesignReader.readConfigurationFromElements(elements, configuration);
    assertEquals(2, configuration.getPlotOptions().size());
    assertThat(configuration.getPlotOptions(ChartType.LINE), instanceOf(PlotOptionsLine.class));
    assertThat(configuration.getPlotOptions(ChartType.SPLINE), instanceOf(PlotOptionsSpline.class));
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) PlotOptionsLine(com.vaadin.addon.charts.model.PlotOptionsLine) Elements(org.jsoup.select.Elements) PlotOptionsSpline(com.vaadin.addon.charts.model.PlotOptionsSpline) Test(org.junit.Test)

Aggregations

Configuration (com.vaadin.addon.charts.model.Configuration)257 Chart (com.vaadin.addon.charts.Chart)196 YAxis (com.vaadin.addon.charts.model.YAxis)100 DataSeries (com.vaadin.addon.charts.model.DataSeries)72 ListSeries (com.vaadin.addon.charts.model.ListSeries)70 XAxis (com.vaadin.addon.charts.model.XAxis)65 Test (org.junit.Test)58 SolidColor (com.vaadin.addon.charts.model.style.SolidColor)56 AxisTitle (com.vaadin.addon.charts.model.AxisTitle)54 DataSeriesItem (com.vaadin.addon.charts.model.DataSeriesItem)51 Tooltip (com.vaadin.addon.charts.model.Tooltip)42 DataLabels (com.vaadin.addon.charts.model.DataLabels)41 Legend (com.vaadin.addon.charts.model.Legend)30 PlotOptionsColumn (com.vaadin.addon.charts.model.PlotOptionsColumn)30 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)27 Elements (org.jsoup.select.Elements)27 Marker (com.vaadin.addon.charts.model.Marker)22 DesignContext (com.vaadin.ui.declarative.DesignContext)22 Element (org.jsoup.nodes.Element)22 PlotOptionsPie (com.vaadin.addon.charts.model.PlotOptionsPie)20