Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WHighCharts new bindings #4

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
target
.settings/
.classpath
.project
rebel.xml
3 changes: 0 additions & 3 deletions .settings/org.eclipse.core.resources.prefs

This file was deleted.

5 changes: 0 additions & 5 deletions .settings/org.eclipse.jdt.apt.core.prefs

This file was deleted.

365 changes: 0 additions & 365 deletions .settings/org.eclipse.jdt.core.prefs

This file was deleted.

63 changes: 0 additions & 63 deletions .settings/org.eclipse.jdt.ui.prefs

This file was deleted.

9 changes: 0 additions & 9 deletions .settings/org.eclipse.wst.validation.prefs

This file was deleted.

9 changes: 0 additions & 9 deletions .settings/org.maven.ide.eclipse.prefs

This file was deleted.

20 changes: 11 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
<?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" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>

<prerequisites>
<maven>2.2.1</maven>
</prerequisites>
<prerequisites>
<maven>2.2.1</maven>
</prerequisites>

<groupId>nl.topicus</groupId>
<artifactId>whighcharts</artifactId>
<packaging>jar</packaging>
<version>6.0-SNAPSHOT</version>
<version>6.13.0-aangenieux-highcharts-4.2.5-SNAPSHOT</version>
<name>WHighCharts</name>
<description>WiQuery-HighCharts bindings</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<wicket.version>6.0-SNAPSHOT</wicket.version>
<wiquery.version>6.0-SNAPSHOT</wiquery.version>
<slf4j.version>[1.6,1.6.10]</slf4j.version>
<wicket.version>6.21.0</wicket.version>
<wiquery.version>6.13.0</wiquery.version>
<wiquery-compressor.version>6.9.2</wiquery-compressor.version>
<slf4j.version>1.6.1</slf4j.version>
<junit.version>4.10</junit.version>
<jetty.version>6.1.26</jetty.version>

Expand Down Expand Up @@ -93,7 +95,7 @@
<dependency>
<groupId>org.odlabs.wiquery</groupId>
<artifactId>wiquery-compressor</artifactId>
<version>${wiquery.version}</version>
<version>${wiquery-compressor.version}</version>
</dependency>

<!-- LOGGING DEPENDENCIES - LOG4J -->
Expand Down
61 changes: 31 additions & 30 deletions src/main/java/nl/topicus/whighcharts/components/WHighChart.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,29 @@
import java.io.IOException;
import java.util.Collection;

import nl.topicus.whighcharts.components.modules.WHighChartsExportingJavaScriptResourceReference;
import nl.topicus.whighcharts.options.WHighChartGlobalSettings;
import nl.topicus.whighcharts.options.WHighChartOptions;
import nl.topicus.whighcharts.options.axis.IWHighChartAxisCategoriesProvider;
import nl.topicus.whighcharts.options.series.ISeries;
import nl.topicus.whighcharts.options.series.ISeriesEntry;

import org.apache.wicket.Application;
import org.apache.wicket.RuntimeConfigurationType;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.model.IModel;
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
import org.odlabs.wiquery.core.javascript.JsStatement;

import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

import nl.topicus.whighcharts.components.modules.WHighChartsExportingJavaScriptResourceReference;
import nl.topicus.whighcharts.options.WHighChartGlobalSettings;
import nl.topicus.whighcharts.options.WHighChartOptions;
import nl.topicus.whighcharts.options.axis.IWHighChartAxisCategoriesProvider;
import nl.topicus.whighcharts.options.series.ISeries;
import nl.topicus.whighcharts.options.series.ISeriesEntry;

public class WHighChart<V, E extends ISeriesEntry<V>> extends WebMarkupContainer
{
private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -57,30 +58,31 @@ public WHighChartGlobalSettings getGlobalSettings()
@Override
public void renderHead(IHeaderResponse response)
{
response.render(JavaScriptHeaderItem.forReference(WHighChartsJavaScriptResourceReference
.get()));
response.render(
JavaScriptHeaderItem.forReference(WHighChartsJavaScriptResourceReference.get()));
response.render(
JavaScriptHeaderItem.forReference(WHighChartsExtraJavaScriptResourceReference.get()));
response.render(JavaScriptHeaderItem
.forReference(WHighChartsExtraJavaScriptResourceReference.get()));
.forReference(WHighChartsDefaultsJavaScriptResourceReference.get()));

if (getOptions().getExporting().getEnabled() != null
&& getOptions().getExporting().getEnabled().booleanValue())
response.render(JavaScriptHeaderItem
.forReference(WHighChartsExportingJavaScriptResourceReference.get()));
response.render(JavaScriptHeaderItem.forScript("var " + getMarkupId() + ";", "highchart_"
+ getMarkupId()));
response.render(JavaScriptHeaderItem.forScript("var " + getMarkupId() + ";",
"highchart_" + getMarkupId()));
response.render(OnDomReadyHeaderItem.forScript(statement().render().toString()));
}

public JsStatement statement()
{
ObjectMapper mapper = new ObjectMapper();
mapper.getSerializationConfig().withSerializationInclusion(Inclusion.NON_NULL);
mapper.getSerializationConfig().withSerializationInclusion(Include.NON_NULL);
mapper.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, false);

if (Application.exists()
&& RuntimeConfigurationType.DEVELOPMENT
.equals(Application.get().getConfigurationType()))
mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
if (Application.exists() && RuntimeConfigurationType.DEVELOPMENT
.equals(Application.get().getConfigurationType()))
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);

String optionsStr = "{}";
String globalOptions = "{}";
Expand All @@ -100,15 +102,15 @@ public JsStatement statement()
if (getOptions().getxAxis().getCategories() == null
|| getOptions().getxAxis().getCategories().isEmpty())
{
getOptions().getxAxis().setCategories(
categoriesProvider.getxAxisCategories());
getOptions().getxAxis()
.setCategories(categoriesProvider.getxAxisCategories());
}

if (getOptions().getyAxis().getCategories() == null
|| getOptions().getyAxis().getCategories().isEmpty())
{
getOptions().getyAxis().setCategories(
categoriesProvider.getyAxisCategories());
getOptions().getyAxis()
.setCategories(categoriesProvider.getyAxisCategories());
}
}
}
Expand All @@ -130,9 +132,8 @@ public JsStatement statement()
e.printStackTrace();
}

JsStatement jsStatement =
new JsStatement().append(globalOptions + getMarkupId() + " = new Highcharts.Chart( "
+ optionsStr + " );\n");
JsStatement jsStatement = new JsStatement().append(
globalOptions + getMarkupId() + " = new Highcharts.Chart( " + optionsStr + " );\n");

return jsStatement;
}
Expand Down
Loading