• 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

Populating x-axis in highcharts dynamically

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic