Skip to content
This repository has been archived by the owner on Feb 14, 2020. It is now read-only.

Commit

Permalink
+ Different instantiation (!!!) - Take a look at the Code Samples for…
Browse files Browse the repository at this point in the history
… further info!

+ Empty Title
+ Default Background is now transparent
+ LineChart
+ BarChart
+ Margin for Chart
+ Colors interface
+ Changing Chart Colors
+ (JavaDoc)
+ (Demo UI)
  • Loading branch information
downdrown committed Apr 2, 2015
1 parent b82cd6f commit 9f41489
Show file tree
Hide file tree
Showing 32 changed files with 826 additions and 299 deletions.
1 change: 1 addition & 0 deletions highchartsapi-demo/highchartsapi-demo.iml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<configuration>
<descriptors>
<deploymentDescriptor name="context.xml" url="file://$MODULE_DIR$/src/main/webapp/META-INF/context.xml" />
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml" />
</descriptors>
<webroots>
<root url="file://$MODULE_DIR$/src/main/webapp" relative="/" />
Expand Down
4 changes: 2 additions & 2 deletions highchartsapi-demo/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>at.downdrown.vaadinaddons</groupId>
Expand Down Expand Up @@ -75,7 +75,7 @@
<dependency>
<groupId>at.downdrown.vaadinaddons</groupId>
<artifactId>highchartsapi</artifactId>
<version>${version}</version>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package at.downdrown.vaadinaddons.highchartsapi.demo;

import at.downdrown.vaadinaddons.highchartsapi.HighChartsAPI;

import javax.servlet.annotation.WebServlet;

import at.downdrown.vaadinaddons.highchartsapi.Colors;
import at.downdrown.vaadinaddons.highchartsapi.HighChart;
import at.downdrown.vaadinaddons.highchartsapi.HighChartFactory;
import at.downdrown.vaadinaddons.highchartsapi.exceptions.HighChartsException;
import at.downdrown.vaadinaddons.highchartsapi.model.ChartConfiguration;
import at.downdrown.vaadinaddons.highchartsapi.model.ChartType;
import at.downdrown.vaadinaddons.highchartsapi.model.data.PieChartData;
import at.downdrown.vaadinaddons.highchartsapi.model.series.BarChartSeries;
import at.downdrown.vaadinaddons.highchartsapi.model.series.LineChartSeries;
import at.downdrown.vaadinaddons.highchartsapi.model.series.PieChartSeries;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.Title;
import com.vaadin.annotations.VaadinServletConfiguration;
Expand All @@ -13,31 +19,125 @@
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

import javax.servlet.annotation.WebServlet;
import java.util.ArrayList;
import java.util.List;

@Theme("demo")
@Title("HighChartsAPI Add-on Demo")
@SuppressWarnings("serial")
public class DemoUI extends UI
{

@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = DemoUI.class, widgetset = "at.downdrown.vaadinaddons.highchartsapi.demo.DemoWidgetSet")
public static class Servlet extends VaadinServlet {
}
public class DemoUI extends UI {

@Override
protected void init(VaadinRequest request) {

// Initialize our new UI component
final HighChartsAPI component = new HighChartsAPI();

// Show it in the middle of the screen
final VerticalLayout layout = new VerticalLayout();
layout.setStyleName("demoContentLayout");
layout.setSizeFull();
layout.addComponent(component);
layout.setComponentAlignment(component, Alignment.MIDDLE_CENTER);

// *** PIE ***
ChartConfiguration pieConfiguration = new ChartConfiguration();
pieConfiguration.setTitle("TestPie");
pieConfiguration.setChartType(ChartType.PIE);
pieConfiguration.setBackgroundColor(Colors.WHITE);

PieChartSeries pieFruits = new PieChartSeries("Fruits");
PieChartData bananas = new PieChartData("Bananas", 33.2);
PieChartData melons = new PieChartData("Melons", 6.21);
PieChartData apples = new PieChartData("Apples", 3.44);

pieFruits.getData().add(bananas);
pieFruits.getData().add(melons);
pieFruits.getData().add(apples);


pieConfiguration.getSeriesList().add(pieFruits);
try {
HighChart pieChart = HighChartFactory.renderChart(pieConfiguration);
pieChart.setHeight(80, Unit.PERCENTAGE);
pieChart.setWidth(80, Unit.PERCENTAGE);
System.out.println("PieChart Script : " + pieConfiguration.getHighChartValue());
layout.addComponent(pieChart);
layout.setComponentAlignment(pieChart, Alignment.MIDDLE_CENTER);
} catch (HighChartsException e) {
e.printStackTrace();
}


// *** LINE ***
ChartConfiguration lineConfiguration = new ChartConfiguration();
lineConfiguration.setTitle("TestLine");
lineConfiguration.setChartType(ChartType.LINE);
lineConfiguration.setBackgroundColor(Colors.WHITE);

List<Object> bananaValues = new ArrayList<Object>();
bananaValues.add(11.3);
bananaValues.add(25.1);
bananaValues.add(32.7);

LineChartSeries bananaLine = new LineChartSeries("Bananas", bananaValues);

List<Object> sweetValues = new ArrayList<Object>();
sweetValues.add(33.65);
sweetValues.add(63.24);
sweetValues.add(21.52);

LineChartSeries choclateLine = new LineChartSeries("Choclate", sweetValues);

lineConfiguration.getSeriesList().add(bananaLine);
lineConfiguration.getSeriesList().add(choclateLine);

try {
HighChart lineChart = HighChartFactory.renderChart(lineConfiguration);
lineChart.setHeight(80, Unit.PERCENTAGE);
lineChart.setWidth(80, Unit.PERCENTAGE);
System.out.println("LineChart Script : " + lineConfiguration.getHighChartValue());
layout.addComponent(lineChart);
layout.setComponentAlignment(lineChart, Alignment.MIDDLE_CENTER);

} catch (HighChartsException e) {
e.printStackTrace();
}
setContent(layout);


// *** BAR ***
ChartConfiguration barConfiguration = new ChartConfiguration();
barConfiguration.setTitle("TestBar");
barConfiguration.setChartType(ChartType.BAR);
barConfiguration.setBackgroundColor(Colors.WHITE);

List<Object> bananaBarValues = new ArrayList<Object>();
bananaBarValues.add(11.3);
bananaBarValues.add(25.1);
bananaBarValues.add(32.7);

BarChartSeries bananaBar = new BarChartSeries("Bananas", bananaValues);

List<Object> sweetBarValues = new ArrayList<Object>();
sweetBarValues.add(33.65);
sweetBarValues.add(63.24);
sweetBarValues.add(21.52);

BarChartSeries choclateBar = new BarChartSeries("Choclate", sweetValues);

barConfiguration.getSeriesList().add(bananaBar);
barConfiguration.getSeriesList().add(choclateBar);

try {
HighChart barChart = HighChartFactory.renderChart(barConfiguration);
barChart.setHeight(80, Unit.PERCENTAGE);
barChart.setWidth(80, Unit.PERCENTAGE);
System.out.println("BarChart Script : " + barConfiguration.getHighChartValue());
layout.addComponent(barChart);
layout.setComponentAlignment(barChart, Alignment.MIDDLE_CENTER);

} catch (HighChartsException e) {
e.printStackTrace();
}
setContent(layout);
}

@WebServlet(value = {"/demo/*", "/VAADIN/*"}, asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = DemoUI.class, widgetset = "at.downdrown.vaadinaddons.highchartsapi.demo.DemoWidgetSet")
public static class Servlet extends VaadinServlet {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@
-->
<!-- <set-configuration-property name="devModeRedirectEnabled" value="true" /> -->


<inherits name="com.vaadin.DefaultWidgetSet"/>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $darkgreen: darken($green, 30%);

// You can style your demo app right here
.demoContentLayout {
background-color: $gray;
background-color: white;
background-image: url(images/radial-gradient.png);
background-size: 90%;
background-position: center center;
Expand Down
46 changes: 46 additions & 0 deletions highchartsapi-demo/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2015 by Manfred Huber.
-->

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="ProjectTemplate" version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
<description>Produktionsmodus</description>
<param-name>productionMode</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<description>Heartbeat Intervall.</description>
<param-name>heartbeatInterval</param-name>
<param-value>300</param-value>
</context-param>
<servlet>
<servlet-name>Demo</servlet-name>
<servlet-class>com.vaadin.server.VaadinServlet</servlet-class>
<init-param>
<param-name>UIProvider</param-name>
<param-value>com.vaadin.server.DefaultUIProvider</param-value>
</init-param>
<init-param>
<param-name>UI</param-name>
<param-value>at.downdrown.vaadinaddons.highchartsapi.demo.DemoUI</param-value>
</init-param>
<init-param>
<param-name>widgetset</param-name>
<param-value>at.downdrown.vaadinaddons.highchartsapi.demo.DemoWidgetSet</param-value>
</init-param>
<init-param>
<param-name>closeIdleSessions</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Demo</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
4 changes: 2 additions & 2 deletions highchartsapi/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>at.downdrown.vaadinaddons</groupId>
<artifactId>highchartsapi</artifactId>
<packaging>jar</packaging>
<version>1.5</version>
<version>1.6</version>
<name>HighChartsAPI Add-on</name>
<inceptionYear>2015</inceptionYear>

Expand Down
Loading

0 comments on commit 9f41489

Please sign in to comment.