moberwasserlechner / vaadin-chartjs Goto Github PK
View Code? Open in Web Editor NEWVaadin 8 wrapper for ChartJS v2.x library
License: MIT License
Vaadin 8 wrapper for ChartJS v2.x library
License: MIT License
Hi, nice add-on!
I observed some stranger behavior on "download as PNG" feature:
http://vaadin-demos.qqjtxeeuih.eu-central-1.elasticbeanstalk.com:5600/#!pie-chart-download
On Chrome I don't need to make nothing (press the download button), only use second mouse button and use "Save image" option.
On Safari (MacOS 10.12.1) I couldn't download, and demo notifications never disappears.
What is the correct behavior for this example?
http://www.chartjs.org/docs/#chart-configuration-element-configuration
window.onload = function() {
var ctx = document.getElementById("canvas").getContext("2d");
window.myBar = new Chart(ctx, {
type: 'bar',
data: barChartData,
options: {
// Elements options apply to all of the options unless overridden in a dataset
// In this case, we are setting the border of each bar to be 2px wide and green
elements: {
rectangle: {
borderWidth: 2,
borderColor: 'rgb(0, 255, 0)',
borderSkipped: 'bottom'
}
},
responsive: true,
legend: {
position: 'top',
},
title: {
display: true,
text: 'Chart.js Bar Chart'
}
}
});
};
Include on Ticks config the userCallback property:
Example:
A user wants to download the current chart by clicking a button (vaadin button).
It looks like I have to call a js function on the connector using com.vaadin.ui.AbstractJavaScriptComponent.callFunction(String, Object...)
and then call the server with a function registered by com.vaadin.ui.AbstractJavaScriptComponent.addFunction(String, JavaScriptFunction)
I havenot found a method, which can retrieve the return value of a javascript function.
Resources:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL
https://github.com/chartjs/Chart.js/search?utf8=%E2%9C%93&q=toBase64Image
this.getImageDataUrl= function() {
// call on function registered by server side component
self.sendImageDataUrl(chartjs.toBase64Image());
}
I think Vaadin and Jelastic ended their cooperation for addon devs because there isn't anything on this cooperation on Vaadin's website anymore.
When set the chart size using setSizeFull(), i expect to see the chart sized correctly, but instead it overflows and some part is not seen on the screen.
How to build a chart with mixed multiple series? Example bar+line chart is here
https://jsfiddle.net/carnecro/0xzgmkav/.
If I construct the ChartJs component on init of the view using @PostConstruct (Vaadin Spring). I'm not able to add Datasets when the actual data is availiable.
Therefore the configuration will be resolve in the components attach() method.
Furthermore I added a default constructor for ChartJs and configure method to set the ChartConfig implementation.
The icons are missing at http://moberwasserlechner.jelastic.servint.net/vaadin-chartjs/
Maybe its vaadin 7.7.0
When I trigger refreshData() chart is is stretched.
Browser refresh, browser resize ... all is perfect.
What am I dooing wrong?
Vaadin 7.7.9
vaadin-chartjs 0.4.0
A bit of source code
private void buildChart() {
configChart = new LineChartConfig();
configChart.data()
.addDataset(new LineDataset().label("qwerty").backgroundColor("rgba(151,187,145,0.5)"))
.and()
.options()
.responsive(true)
.title()
.display(true)
.and()
.tooltips()
.and()
.scales()
.add(Axis.X, new DefaultScale()
.stacked(true))
.add(Axis.Y, new DefaultScale()
.stacked(true))
.and()
.done();
Dataset<?, ?> ds = configChart.data().getDatasetAtIndex(0);
chartLineDataSet = (LineDataset) ds;
chart = new ChartJs(configChart);
chart.setJsLoggingEnabled(true);
chart.setSizeFull();
}
private void chartDataRefresh(Long offset) {
dataSNR = crDrI122Repo.getAllSnrs();
dataTaskDateString = Util.dateArrayToStringarray(crDrI122Repo.getAllTaskDates());
configChart.data().labels(dataTaskDateString);
chartLineDataSet.dataAsList(Util.floatListToDoubleList(dataSNR));
chart.configure(configChart);
chart.refreshData();
}
ps. vaadin chart js = great job
Nearly every configuration in Chartjs can be set globally and is therefore assigned to every chart on the page.
See http://www.chartjs.org/docs/#chart-configuration-global-configuration as starting point.
Hello, First of all a BIG thank you for the add-on. It is Great.
I have one question, where I can find the "ChartUtils", where are included. I can import all the libraries
except this one.
Thanks again
Elias
Chart.js 2.6 added the possibility to fill between data in a more advanced way.
Not deprecated but replaced because 1.0.0 already has breaking changes.
HI,
When trying to deploy an application on a HA environment, Vaadin-Chartjs configuration objects complain about non-serializable objects.
Caused by: org.springframework.core.serializer.support.SerializationFailedException: Failed to serialize object using DefaultSerializer; nested exception is java.io.NotSerializableException: com.byteowls.vaadin.chartjs.config.BarChartConfig
at org.springframework.core.serializer.support.SerializingConverter.convert(SerializingConverter.java:68) ~[spring-core-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.core.serializer.support.SerializingConverter.convert(SerializingConverter.java:35) ~[spring-core-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.data.redis.serializer.JdkSerializationRedisSerializer.serialize(JdkSerializationRedisSerializer.java:90) ~[spring-data-redis-1.7.7.RELEASE.jar:na]
... 38 common frames omitted
Caused by: java.io.NotSerializableException: com.byteowls.vaadin.chartjs.config.BarChartConfig
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184) ~[na:1.8.0_121]
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548) ~[na:1.8.0_121]
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509) ~[na:1.8.0_121]
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432) ~[na:1.8.0_121]
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178) ~[na:1.8.0_121]
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348) ~[na:1.8.0_121]
at java.util.HashMap.internalWriteEntries(HashMap.java:1784) ~[na:1.8.0_121]
at java.util.HashMap.writeObject(HashMap.java:1362) ~[na:1.8.0_121]
at sun.reflect.GeneratedMethodAccessor123.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:1028) ~[na:1.8.0_121]
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496) ~[na:1.8.0_121]
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432) ~[na:1.8.0_121]
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178) ~[na:1.8.0_121]
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548) ~[na:1.8.0_121]
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509) ~[na:1.8.0_121]
Is the system prepared for view serialization ?
This includes
Hi,
Is there currently a way to do this kind of customization, directly or using an override? I need to display dates without hours in the scale but the full label in the tooltip.
See the jsfiddle below, someone did something similar in javascript, but I don't think that your wrapper implements tooltipTemplate yet.
https://jsfiddle.net/7z1s1feg/
Thanks in advance.
Because the demo example code only shows a part of the class a Link should bring the user to the full class on Github.
Configuring this variant of a line chart is not supported in the initial release.
Use a algorithm like the ones described in http://devmag.org.za/2012/07/29/how-to-choose-colours-procedurally-algorithms/
Base the demo on spring boot because its easier to debug and develop.
Some plugins, like this:
http://jsfiddle.net/s9tu1c9y/55/
,needs to work with custom structures/properties.
This is a enhancement request.
Implement features according to release notes or changelog.
Since Java 7 is not getting any public updates for nearly 1,5 years, I think its save to base addons on Java 8
Hello!, sorry for ask this on the issue section, but I don't know where to ask you a question.
Is there a way of how to show the data values ON the chart? for example:
This can be archived with javascript but I don't know how to do it on vaadin.
image taken from this link: http://stackoverflow.com/questions/31631354/how-to-display-data-values-on-chart-js/31632707
Option was never supported and has no effect on the chart.
ChartJsWidgetset-0.js:21863 Sun Jul 31 20:54:08 GMT+200 2016 com.vaadin.client.ApplicationConfiguration
SEVERE: (RangeError) : Maximum call stack size exceededcom.google.gwt.core.client.JavaScriptException: (RangeError) : Maximum call stack size exceeded
at Unknown.emptyMethod(ChartJsWidgetset-0.js)
at Unknown.hasTypeMarker(ChartJsWidgetset-0.js)
at Unknown.hasJavaObjectVirtualDispatch(ChartJsWidgetset-0.js)
at Unknown.$init__V__devirtual$(ChartJsWidgetset-0.js)
at Unknown.Object_0(ChartJsWidgetset-0.js)
at Unknown.AbstractMap(ChartJsWidgetset-0.js)
at Unknown.AbstractHashMap(ChartJsWidgetset-0.js)
at Unknown.HashMap(ChartJsWidgetset-0.js)
at Unknown.$init_257(ChartJsWidgetset-0.js)
at Unknown.SimpleEventBus_0(ChartJsWidgetset-0.js)
at Unknown.HandlerManager$Bus(ChartJsWidgetset-0.js)
at Unknown.HandlerManager_0(ChartJsWidgetset-0.js)
at Unknown.HandlerManager(ChartJsWidgetset-0.js)
at Unknown.createHandlerManager(ChartJsWidgetset-0.js)
at Unknown.ensureHandlers(ChartJsWidgetset-0.js)
at Unknown.addDomHandler(ChartJsWidgetset-0.js)
at Unknown.SimpleTree(ChartJsWidgetset-0.js)
at Unknown.SimpleTree_0(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_1(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_1(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_1(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_1(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_1(ChartJsWidgetset-0.js)
at Unknown.dir_3(ChartJsWidgetset-0.js)
at Unknown.dir_2(ChartJsWidgetset-0.js)
If I want to show the status feedback of a transactional email service like Amazon's SES in a chart I could either create a separate chart data structure, run through the list of feedback objects and extract the labels from there or integrate some helpers to the addon:
Advise the addon to extract labels from the first dataset:
DonutChartConfig config = new DonutChartConfig();
config.data()
.extractLabelsFromDataset(true)
.addDataset(dataset);
We create a donut chart config and adivse the chart to extractLabelsFromDataset(true)
as soon as the datasets are send to the client side.
Dynamically create a dataset labels
PieDataset dataset = new PieDataset();
// dataset.randomBackgroundColors(true);
String successfullSent = i18n.get("messaging.status.feedback.success");
for (EmailFeedback f : feedbackList) {
String desc = f.getFeedbackDescription();
if (desc == null) {
desc = successfullSent;
}
dataset.addLabeledData(desc, 1d);
}
Using dataset.addLabeledData(labelName, value);
the value will be added to a"label-value map". In case of double data based dataset (like Bar, Line, Polar, Radar and Pie) the value will be added to a existing value and does not replace it.
Right now there these problems:
Is it possible to change fill parameter to string?
LineDataset.java
public LineDataset fill(boolean fill) {
this.fill = fill;
return this;
}
This functionality is good to implement :
http://www.chartjs.org/samples/latest/charts/area/line-datasets.html
I want to be able to configure all line chart samples from Chart.js except the ones using configured callbacks functions.
Version 2.5 should be release very soon. See https://github.com/chartjs/Chart.js/releases/tag/v2.5.0
I think below js code does not works as expected.
canvas.setAttribute('width', "100%");
Will investigate.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.