File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Populating x-axis in highcharts dynamically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Populating x-axis in highcharts dynamically " Watch "Populating x-axis in highcharts dynamically " New topic
Author

Populating x-axis in highcharts dynamically

Bora Sabrioglu
Ranch Hand

Joined: Nov 19, 2012
Posts: 86
Hi,

I have some embedded JS-Code in an xhtml-file.

This code uses the highcharts-library to draw a chart.

I would like the x-axis of the chart to have dynamically assigned values.

The syntax goes like this:

categories: [january, 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember']

As you can see, there are hardcoded Strings in there ('Februar', 'März', 'April', 'Mai', 'Juni')...

I defined a variable (january) and tried to invoke the getter of a Bean with which I can dynamically get the String from a database.

But it doesn't work.

I did some research but could not find good answers, only something like "put a hidden button in there and then use its event to invoke the bean on the other side".

Does someone have a clue how to do this?

Below you can see some snippet of the code. Thanks!

<script src="resources/js/highcharts/highcharts.js" type="text/javascript"></script>

(...)

type="text/javascript"></script>

<script>

(...)

var january;

function drawChart() {

(...)

january = ("#{localizationProvider.get('xAxisJanuary')}").text() ;
chart1 = new Highcharts.Chart({

(...)

xAxis: {
title: {
text: 'Monat'
},
categories: [january, 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember']
},

(...)

</script>
Bora Sabrioglu
Ranch Hand

Joined: Nov 19, 2012
Posts: 86
problem solved:

it was just a syntax error...

it has to be written like this:

<script>
var hiddenCode = "#{descriptionSearch.hiddenCode}";
</script>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Populating x-axis in highcharts dynamically