Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Populating x-axis in highcharts dynamically

 
Bora Sabrioglu
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
problem solved:

it was just a syntax error...

it has to be written like this:

<script>
var hiddenCode = "#{descriptionSearch.hiddenCode}";
</script>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic