Search in sources :

Example 16 with DesignContext

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

the class ChartDesignWriterTest method writeConfiguration_yAxisWithTitle_theYAxisWithTitleIsInTheElement.

@Test
public void writeConfiguration_yAxisWithTitle_theYAxisWithTitleIsInTheElement() {
    DesignContext designContext = new DesignContext();
    Configuration configuration = new Configuration();
    AxisTitle title = new AxisTitle("Temperature");
    configuration.getyAxis().setTitle(title);
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    assertEquals("<y-axis><chart-title text=\"Temperature\"></chart-title></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) AxisTitle(com.vaadin.addon.charts.model.AxisTitle) Test(org.junit.Test)

Example 17 with DesignContext

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

the class ChartDesignWriterTest method writeConfiguration_attributeNameHasMultipleWords_theAttributeValueIsAddedToElement.

@Test
public void writeConfiguration_attributeNameHasMultipleWords_theAttributeValueIsAddedToElement() {
    DesignContext designContext = new DesignContext();
    Configuration configuration = new Configuration();
    configuration.getChart().setMarginLeft(100);
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    assertEquals("<chart margin-left=\"100\"></chart>", parent.child(0).toString());
}
Also used : Configuration(com.vaadin.addon.charts.model.Configuration) Element(org.jsoup.nodes.Element) DesignContext(com.vaadin.ui.declarative.DesignContext) Test(org.junit.Test)

Example 18 with DesignContext

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

the class ChartDesignWriterTest method writeConfiguration_titleWithStyle_theStyleIsInnerElementOfTitle.

@Test
public void writeConfiguration_titleWithStyle_theStyleIsInnerElementOfTitle() {
    DesignContext designContext = new DesignContext();
    Configuration configuration = new Configuration();
    configuration.getTitle().getStyle().setTop("12");
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    assertEquals("<chart-title><chart-style top=\"12\"></chart-style></chart-title>", 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) Test(org.junit.Test)

Example 19 with DesignContext

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

the class ChartDesignWriterTest method writeConfiguration_frameFor3D_theFrameElementHasPrefix.

@Test
public void writeConfiguration_frameFor3D_theFrameElementHasPrefix() {
    DesignContext designContext = new DesignContext();
    Configuration configuration = new Configuration();
    configuration.getChart().getOptions3d().getFrame().getBack().setSize(1);
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    assertEquals("<chart><options3d><chart-frame><back size=\"1\"></back></chart-frame></options3d></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) Test(org.junit.Test)

Example 20 with DesignContext

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

the class ChartDesignWriterTest method writeConfiguration_formulaNode_theFormulaIsAddedToElementAsAttribute.

@Test
public void writeConfiguration_formulaNode_theFormulaIsAddedToElementAsAttribute() {
    DesignContext designContext = new DesignContext();
    Configuration configuration = new Configuration();
    configuration.getTooltip().setFormatter("function() {return '' + this.series.name + ' ' + this.x + ': ' + this.y + '°C';}");
    Element parent = new Element(Tag.valueOf("test"), "");
    ChartDesignWriter.writeConfigurationToElement(configuration, parent, designContext);
    assertEquals("<tooltip formatter=\"function() {return '' + this.series.name + ' ' + this.x + ': ' + this.y + '°C';}\"></tooltip>", 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) 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