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

537 remove jquery and update demos #539

Merged
merged 7 commits into from
Sep 12, 2018
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,6 @@ public interface HighchartResources extends ClientBundle {
@Source("vaadintheme.js")
TextResource defaultTheme();

/**
* @return
* @deprecated use {@link #standaloneframework()} instead
*/
@Source("jquery.min.js")
@Deprecated
TextResource jquery();

@Source("standalone-framework.js")
TextResource standaloneframework();

@Source("exporting.js")
TextResource exporting();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ public static void ensureInjected() {
}

protected void injectResources() {
// As jquery is so popular, inject it conditionally
if (!hasJQuery()) {
inject(HighchartResources.INSTANCE.standaloneframework().getText());
}
// Inject highcharts only if not already injected
if (!hasHighcharts()) {
inject(HighchartResources.INSTANCE.highstock().getText());
Expand All @@ -70,13 +66,6 @@ protected void injectResources() {
}
}

protected native static boolean hasJQuery()
/*-{
if($wnd.jQuery)
return true;
return false;
}-*/;

protected native static boolean hasHighcharts()
/*-{
if($wnd.Highcharts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ private static void writeTemporaryFileContents() {
JS_STUFF.deleteOnExit();
}
FileOutputStream out = new FileOutputStream(JS_STUFF);
String[] scripts = new String[] { "jquery.min.js", "highstock.js",
String[] scripts = new String[] { "highstock.js",
"highcharts-more.js", "funnel.js", "exporting.js",
"heatmap.js", "solid-gauge.js", "highcharts-3d.js",
"vaadintheme.js", "treemap.js" };
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,15 @@ function render(configstr, themeStr, langStr, width, height, timeline) {

// dynamic script insertion
function loadScript(varStr, codeStr) {
var $script = $('<script>').attr('type', 'text/javascript');
$script.html('var ' + varStr + ' = ' + codeStr);
document.getElementsByTagName("head")[0].appendChild($script[0]);
}
var script = document.createElement('script');
script.type = 'text/javascript';

var code = 'var ' + varStr + ' = ' + codeStr + ';';
var inlineScript = document.createTextNode(code);
script.appendChild(inlineScript) ;

document.getElementsByTagName('head')[0].appendChild(script);
}

// are all images loaded in time?
function logCounter(counter) {
Expand All @@ -143,19 +148,19 @@ function render(configstr, themeStr, langStr, width, height, timeline) {

function loadImages() {
// are images loaded?
var $images = $('svg image'), counter, i, img;
var images = document.querySelectorAll('svg image'), counter, i, img;

if ($images.length > 0) {
if (images.length > 0) {

counter = $images.length;
counter = images.length;

for (i = 0; i < $images.length; i += 1) {
for (i = 0; i < images.length; i += 1) {
img = new Image();
img.onload = logCounter(counter);
/*
* force loading of images by setting the src attr.
*/
img.src = $images[i].getAttribute('href');
img.src = images[i].getAttribute('href');
}
} else {
// no images set property to all images
Expand Down
17 changes: 8 additions & 9 deletions chart-export-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<vaadin.version>7.3.6</vaadin.version>
<vaadin.version>8.3.1</vaadin.version>
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
<vaadin.charts.version>3.0-SNAPSHOT</vaadin.charts.version>
<vaadin.charts.version>4.1-SNAPSHOT</vaadin.charts.version>
<batik.version>1.7</batik.version>
</properties>
<repositories>
Expand Down Expand Up @@ -131,8 +131,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- As we are doing "inplace" GWT compilation, ensure the widgetset -->
Expand Down Expand Up @@ -184,11 +184,10 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.8.v20121106</version>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
</plugin>
</plugins>
<pluginManagement>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.vaadin.addon.charts.model.ChartType;
import com.vaadin.addon.charts.model.Configuration;
import com.vaadin.addon.charts.model.Cursor;
import com.vaadin.addon.charts.model.DataLabels;
import com.vaadin.addon.charts.model.DataSeries;
import com.vaadin.addon.charts.model.DataSeriesItem;
import com.vaadin.addon.charts.model.Labels;
Expand All @@ -24,7 +25,7 @@
import com.vaadin.server.FileDownloader;
import com.vaadin.server.StreamResource;
import com.vaadin.server.StreamResource.StreamSource;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
Expand Down Expand Up @@ -161,7 +162,7 @@ private static Configuration createChartConf() {

PlotOptionsPie plotOptions = new PlotOptionsPie();
plotOptions.setCursor(Cursor.POINTER);
Labels dataLabels = new Labels();
DataLabels dataLabels = new DataLabels();
dataLabels.setEnabled(true);
dataLabels.setColor(new SolidColor(0, 0, 0));
dataLabels.setConnectorColor(new SolidColor(0, 0, 0));
Expand Down
16 changes: 8 additions & 8 deletions chart-plugin-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<vaadin.version>7.3.6</vaadin.version>
<vaadin.version>8.3.1</vaadin.version>
<vaadin.plugin.version>${vaadin.version}</vaadin.plugin.version>
<vaadin.charts.version>2.0.0.rc1</vaadin.charts.version>
<vaadin.charts.version>4.1-SNAPSHOT</vaadin.charts.version>
</properties>
<repositories>
<repository>
Expand Down Expand Up @@ -83,8 +83,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- As we are doing "inplace" GWT compilation, ensure the widgetset -->
Expand Down Expand Up @@ -136,10 +136,10 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
</plugin>
</plugins>
<pluginManagement>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.vaadin.addon.charts.Chart;
import com.vaadin.addon.charts.model.ChartModel;
import com.vaadin.addon.charts.model.Configuration;
import com.vaadin.addon.charts.model.DataSeries;
import com.vaadin.addon.charts.model.DataSeriesItem;
import com.vaadin.addon.charts.model.HorizontalAlign;
import com.vaadin.addon.charts.model.LayoutDirection;
Expand All @@ -19,8 +18,7 @@
import com.vaadin.demo.chartplugin.model.CustomChartTypes;
import com.vaadin.demo.chartplugin.model.MapSeries;
import com.vaadin.demo.chartplugin.model.ValueRange;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Component;
import com.vaadin.shared.ui.ContentMode;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;

Expand Down Expand Up @@ -77,7 +75,7 @@ public static Chart createHeatMap() {
yAxis.setReversed(true);

Legend legend = configuration.getLegend();
legend.setHorizontalAlign(HorizontalAlign.LEFT);
legend.setAlign(HorizontalAlign.LEFT);
legend.setVerticalAlign(VerticalAlign.BOTTOM);
legend.setFloating(true);
legend.setLayout(LayoutDirection.VERTICAL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,7 @@ public interface HighchartPluginResources extends ClientBundle {
@Source("map.src.js")
TextResource mapSrcJs();

@Source("highcharts.js")
TextResource highcharts3();

@Source("highcharts-more.js")
TextResource more3();

@Source("funnel.js")
TextResource funnel();

@Source("exporting.js")
TextResource exporting3();
@Source("data.src.js")
TextResource dataSrcJs();

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,37 @@ public class HighchartsPluginScriptLoader extends HighchartsScriptLoader {

@Override
protected void injectResources() {
// As jquery is so popular, inject it conditionally
if (!hasJQuery()) {
inject(HighchartResources.INSTANCE.jquery().getText());

// Inject highcharts only if not already injected
if (!hasHighcharts()) {
inject(HighchartResources.INSTANCE.highstock().getText());
}
// Load heatmap before treemap
if (!hasHeatmap()) {
inject(HighchartResources.INSTANCE.heatmap().getText());
}
// Inject highchartsmore only if not already injected
if (!hasHighchartsMore()) {
inject(HighchartResources.INSTANCE.highchartsMore().getText());
}
// This would be default, but we also demo using newer highcharts version
// inject(HighchartResources.INSTANCE.highcharts().getText());

inject(HighchartPluginResources.INSTANCE.highcharts3().getText());

// Map plugin needs to be injected before defaultTheme and after jquery
// and highcharts
// Map plugin needs to be injected before defaultTheme and after highcharts
inject(HighchartPluginResources.INSTANCE.worldMapShapes().getText());
inject(HighchartPluginResources.INSTANCE.mapSrcJs().getText());
inject(HighchartPluginResources.INSTANCE.dataSrcJs().getText());

// This is new extra module in HC3
inject(HighchartPluginResources.INSTANCE.funnel().getText());

// inject(HighchartResources.INSTANCE.highchartsMore().getText());
// inject(HighchartResources.INSTANCE.exporting().getText());
inject(HighchartPluginResources.INSTANCE.more3().getText());
inject(HighchartPluginResources.INSTANCE.exporting3().getText());
inject(HighchartResources.INSTANCE.defaultTheme().getText());
// Inject other resources only if not already injected
if (!hasExtraImports()) {
inject(HighchartResources.INSTANCE.noData().getText());
inject(HighchartResources.INSTANCE.funnel().getText());
inject(HighchartResources.INSTANCE.exporting().getText());
inject(HighchartResources.INSTANCE.defaultTheme().getText());
inject(HighchartResources.INSTANCE.highcharts3d().getText());
inject(HighchartResources.INSTANCE.solidGauge().getText());
inject(HighchartResources.INSTANCE.treemap().getText());
inject(HighchartResources.INSTANCE.drilldown().getText());
}
}


}
Loading