• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How do I embed my JavaFX area chart in a JSP?

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am new to JavaFX and I'm currently working on a project where I have to embed a JavaFX area chart in a Web application using JSP. This is my java code for the area chart which runs perfectly when run as a Java application.



I also packaged the application as a JAR applet which also runs perfectly but when I try to embed it in the JSP using the <applet > tag, it doesn't show up because it is unsigned. All I get is "Error. Click for details" in red.
This is my applet tag





Can someone please explain how I can display this chart on the JSP. Thanks in advance.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Applets are obsolete and disabled by default in most browsers.

Most server-side charting options seem to focus on writing the chart to an image, and then statically displaying that image in an HTML page. This is obviously limiting as it precludes real-time interaction with the chart.

That is why the modern approach is to send the data to the page, where JavaScript can be used to create interactive charts. There are any number of packages that make this pretty easy such as Highcharts, or Flot charts, or a bunch of others that you can search for. If you are somewhat masochistic, you can look at D3.

Why did you choose a desktop technology such as JavaFX if your intent was to show the chart on the web?
 
Eddie Cross
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Applets are obsolete and disabled by default in most browsers.

Most server-side charting options seem to focus on writing the chart to an image, and then statically displaying that image in an HTML page. This is obviously limiting as it precludes real-time interaction with the chart.

That is why the modern approach is to send the data to the page, where JavaScript can be used to create interactive charts. There are any number of packages that make this pretty easy such as Highcharts, or Flot charts, or a bunch of others that you can search for. If you are somewhat masochistic, you can look at D3.

Why did you choose a desktop technology such as JavaFX if your intent was to show the chart on the web?



Hello Bear, thanks for such a quick response. The thing is I've been told to use JavaFX for the chart. I understood what you said completely. I am now thinking about using Jfreecharts. The Javafx code posted earlier plots random number so what I did is I wrote a random number generator in Javascript. This is the script part.



Now can I use this value as the input to my Jfreechart or Highcharts?
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eddie Cross wrote:
Now can I use this value as the input to my Jfreechart or Highcharts?



JFreeChart is a server-side Java solution to create static charts. So, no. This approach is a decade or so so out of date, and not an approach I'd recommend.

JavaScript solutions take data from wherever you get it (very often a REST API) and create interactive charts on the fly using that data. This is the approach I recommend.

Highcharts requires a license for commercial use, but is very versatile and easy to use. There is a large community and tons of online examples.

Others, such as Flot charts are free, but with fewer features and smaller communities.
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And, at least with Highcharts (which is what I have the most experience with), it's easy to update the chart data without needing to refresh anything, or even redraw the entire chart. I assume that's what you intend to do with your 2-second intervals?
 
Eddie Cross
Greenhorn
Posts: 12
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just looked up a few examples on Highcharts. Found exactly what I needed. I also tried it out and it works perfectly!

Thank you Sir Bear Bibeault.
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic