How to show data graphically in Java? - java

I am developing an application in Java. I got a requirement to show data in graphical form.
In ASP.NET we can use Chart Controls to show data graphically. Likewise, how can we show the data graphically in Java. I am using Eclipse Ganymede. How to show data graphically from a database.

There are many such libraries, some of them listed in various SO posts such as JAVA Library for charts- JFreeChart?.
I personally used Gral to draw some simple plots, it was perfect for my purposes. There are some examples of the look and feel on their web site.

There are several free java apis available to show data graphically in the form of charts like: For Java standalone application you can use jFreeChart
http://www.jfree.org/jfreechart/devguide.html
for java web application you can use highcharts(for non-comercial use)
http://www.highcharts.com/

Related

Project: Create a java webapp in Vaadin (to-do-list)

To improve my programming skills I would like to set up a little project for my work. I would like to create a kind of to do list, with several columns (Note, PO Order, Shipping, Done (as a Checkbox), ect.).
At the end of a day, I want to be able to click on the checkbox for every row which is done and save them in a data file. Also I would like to create this as a web application, running on the server in the company.
Since I would like to improve especially my java skills I would like to do this (if possible) mostly in java and to get in touch with frameworks, so I started to read about Vaadin.
My question is, if you guys could give maybe some experience about a project like this and if it's in general possible to realise this with Vaadin.
To improve my programming skills
If you want to build web apps using pure Java on the server-side, Vaadin fits the bill.
You describe the layout and widgets you want to appear in the user interface using Java code. Then, at runtime, Vaadin automatically generates the necessary HTML, CSS, JavaScript, DOM, AJAX, WebSocket, and Push code needed to render that UI on the client-side in the user’s web browser.
The beautiful part is that you get all the benefits of using those web standards technologies without having to learn them or code them.
create a kind of to do list, with several columns (Note, PO Order, Shipping, Done (as a Checkbox), ect.).
Vaadin provides a powerful and well-designed data-grid widget, Vaadin Grid, that can display such columns including the checkbox.
I want to be able to click on the checkbox for every row
The Vaadin Grid tool has an interactive mode that allows the user to directly edit the row, including clicking on the checkbox.
You could alternatively let the user select several rows and click a button (that you programmed) than would mark them as done, checking the checkboxes of the group at once.
Also, Grid has a built-in feature where it displays a column of checkboxes to be clicked en masse as an alternative to selecting rows. This helps the many users who are not adept at maneuvering through a multi-row selection with mouse-and-keyboard gestures.
I would like to create this as a web application, running on the server in the company.
Your Vaadin-based web app is built on standard Java Servlet technology. So you can deploy to your choice of any of a dozen or more web containers such as Apache Tomcat, Eclipse Jetty, Glassfish, Wildfly, and many more.
I would like to do this (if possible) mostly in java
You can build your web app entirely with Java code by using Vaadin. All Java on the server-side, no Java on the client-side.
You may eventually want to learn a bit of CSS to tweak the fonts and colors and such. But this is optional.
if it's in general possible to realise this with Vaadin.
Indeed, this project sounds like an ideal match to Vaadin.
In contrast, where Vaadin is contraindicated would be:
For web sites with crazy complicated layouts such as slick magazine sites. Vaadin is aimed at business-oriented data-entry apps.
For programmers who want to grapple directly with the HTML, CSS, JavaScript, etc. rather than avoid it.

JFreeChart on Web

First, I am a final year student. We are creating a KPI and we saw JFree chart can be used to display charts. Now we have a problem about deciding whether the software is web based or not (Major votes came for a Desktop application. Only 1 is there for web based solution. ).
However, this what we have to do;
Display data using Charts
Colors of the areas of the chart MUST change during run time (eg: if < 90% attendance 'RED', if > 90% attendance 'GREEN')
When the user clicks on the particular area of the chart, display all the relevant data as a 'Tool Tip Text Box' or something. When mouse over, display some summary.
There will be 6 KPI's in the dashboard.
KPI's are belong to 2 categories, HR and PROJECTS.
Now my question is, what is the easy way of doing it? Web Based or Desktop? Will JFreeChart support these functions when it is in web? Please help!
First the long answer, then the short one. If you are using JFreeChart on the web, you have two options:
Display the charts in an applet, which will allow you to do basically all the stuff that JFreeChart supports, including the ones you mentioned above.
Use JFreeChart on the server side to generate images that will be served by the server. In this case, #2 will be difficult because you will have to refresh pages, #3 will be very hard or even almost impossible
Given the above, the short answer is: I suggest you build a desktop application, it will be easier to deal with charting.
From my experience is better use a Javascript Library to generate a gantt chart and later integrate with any framework Java Web. You could use some libraries for example:
Twproject Gantt
JQuery Gantt
JSGantt Improved
JQuery.Gantt
Finally There is an option with cost: Daylot Gantt
If you want to use JFreechart It can be used to render an image and post it on the page, you also could use some form of jquery based chart ploting. Either way you would have to take control of refreshing the data. In standalone app it might be somewhat easier.
you can use these JFreeCharts the requirements you have specified.
JFree charts will display the charts as images. But there are some methods which will display the tooltips and the summary, You have to implement those methods based on your requirements.

embedding and interacting with a browser like view in a Java application

I was wondering how I could embed a browser like view in a Java client application, at the same time that I can interact with it by means of JavaScript.
The problem that triggered this question is the following:
The interface of my application consists of a (Google) map and some svg stuff.
This is easy to do in a browser.
However, I also need access to some special Java libraries that can process some information from the map (e.g., certain coordinates in the map) and that answers values that should influence the browser view (e.g., a path should be drawn over the map).
My first idea was to implement the Java side behaviour as a REST web service, so from JavaScript I will invoke this webservice sending relevant information about the map and using the answer to update the map. Nevertheless, for my current needs (this is only a prototype) using webservices is a bit too much of infrastructure.
Is there a way I could just:
embed a browser like view in my Java application.
Interact from the Java side with this view by means of JavaScript functions implemented in the web page displayed in the browser view (such as these functions will influence the rendering of the page in the browser like view) ?.
I found other questions related to how to embed a browser in a swing application (e.g., Embedding web browser window in Java) and JDIC seems to be able to do this. Although some people report it is difficult to make it work in OSX (the OS I use) and do not mention if it is possible to interact with the browser by means of JavaScript.
It seems to me that in Android it is possible to make JavaScript calls from the Java (Android) side, so probably this is also possible in plain Java.
Thanks for any pointer !
With Java FX 2 you can. You get a webkit webview there. Can interact with it back and forth with java<->javascript.
For an example embedding google maps see: http://java-buddy.blogspot.se/2012/03/embed-google-maps-in-javafx-webview.html
You can embed java fx in swing with JFXPanel if you don't want to go with 100% JavaFX yet.
If you can use swt, take a look at SWT Browser widget
For javascript you can use
http://www.mozilla.org/rhino/

GWT or JavaFX webpage dilemma

Im trying to resolve following dilemma. I have to develop whole webpage system(with user friendly content management, it should look like very simple Drupal or Joomla) as a project to school. The webpage should have function of adding and removing articles, editing menus, editing whole webpage layout(header position, menu position etc).
Im in phase of deciding which system would be the best for this purpose. I wrote several applications in GWT. It's very quick to develop something, it works on Tomcat etc. So it could be very good adept for this task. But recently I got an idea of writing whole webpage system in JavaFX 2.0 (webpage would open inside the browser).
What is your opinion about this fact ? Should I use JavaFX or GWT? I'm not sure if whole webpage will be quick enough in JavaFX. If the users that will be visiting this page wont have problems with launching this page etc. I havent found any information about this on the internet.
Thanks for your answers :)
Go for GWT (also consider using Vaadin or SmartGWT). It does not require a Java Virtual Machine to be installed on the client. Also, GWT allows the client to download only small pieces of the application, and not the whole thing.
You cited two Content Management Systems like Drupal and Joomla that are written in PHP, so maybe the best solution for you is a CMS written in java like Alfresco or Magnolia.
do you want to do a web page or an applicatin for one plugin ? GWT of course.
GWT
GWT follows a most innovative approach: you write the entire application in Java. But it’s executed in Javascript. A good portion of your code is cross-compiled to Javascript and uploaded to the client.
Judging from the presentations I’ve seen, this approach works surprisingly good. In former times the GWT compiler used to be slow, but today, they seem to have solved (or at least alleviated) the problem. As far as I can see, GWT is an excellent choice
javafx
JavaFX 2.0 is a pretty new GUI framework. So expect a few glitches. The good news is that it’s likely to improve over the years. And I suppose people will start to write JavaFX component frameworks if JavaFX is going to be popular.
There’s a video showing the domain of JavaFX very clearly.
Container terminal monitoring with 3D JavaFX
Source

Interactive Charts for web application

We are working on a web based application (implemented in JAVA) on commodity prices and one part of it is interactive charting. I provide a simplified example here. We have a table in Mysql database where we have information on commodity prices in US states and counties. One aspect of the application is to create interactive plots based on user choice. For example, if the user needs to see the price density in Oregon and Linn county then she chooses it from the menu in a webpage and it is rendered on fly with accompanying quantile information in a table. As the user changes state and county these plots and table change on fly.For our computational need we are using R (and use rjava to integrate it to our web application) and I know that if interactivity is not an issue this is a piece of cake in ggplot2, but I am not aware of any interactive version of R graphics framework (like lattice, ggplot2). We are exploring google visualization API but I am not sure we can have the statistical power we need in some of the plots.Please help.
You can absolutely do what you describe by making a call to R after each change in your web application. That's what Jeroen Ooms's application does. Or have a look at Jaime Love's R-Node application for an example of an R webapp that uses RServe.
R does not have any complete "interactive web graphics package" at this point in time. You can look at the webvis package for R/Protovis integration, but this doesn't include any interactivity yet.
Maybe a Javascript solution like protovis or humblefinance, maybe in combination with the brew package, might do the trick?
I don't know if it is powerful enough to suit your needs, but the gWidgetsWWW package can be used to make interactive graphics quite easily. Some examples and link to their source can be found here:
http://www.math.csi.cuny.edu/gWidgetsWWW/run/ex-index
--John

Categories

Resources