Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • 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
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

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>
 
There's a hole in the bucket, dear Liza, dear Liza, a hole in the bucket, dear liza, a tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic