Hi,

What would be the best way to embed a Highcharts chart within the body field of a node? The example on (https://drupal.org/node/1507800) is pretty nice, but it only shows how to return the rendered output of a chart within a block.

Within the body of a certain node, I put an empty div: <div id="target-div" style="width:100%; height:200px"></div>. Without using this module, I would simply add jquery to the page which would target the div. I was thinking that I should call the highcharts_render function within a theme_preprocess_node function, but I'm not sure how to target the "target-div". Am I going about it the right way?

Any help would be much appreciated, thanks!

Comments

yevgeny.ananin’s picture

Ok, I'm going ahead and trying to create a block by following the steps in the example. However, when I manually load my block and do a dsm, I get an array but the content is an empty string. That is, when I call 'content' => theme('highcharts_chart', $attributes) it returns an empty string. And I'm also still confused about what the renderTo should be set to.

yevgeny.ananin’s picture

Ok, so I even took the example code from https://drupal.org/node/1507800 and temporarily replaced my code with it, just to see if I could get it to work. I was still just getting an empty value for the block content. Then I looked at the recent log messages and I noticed that it said "Theme hook highcharts_chart not found." I then realized that the information on the page is outdated, so I in the readme file and noticed that the return value was 'content' => highcharts_render($options, $attributes),, and not what I listed in comment #1. So I updated the code to reflect the readme. I then reloaded the block (still using the example code and not my own), dsm'd the block, and this time the value of the content isn't an empty string, but the following: <div id="container highcharts_523755aebf620" style="height: 200px margin: 0 auto;" class="highcharts-chart"></div>. It creates an empty div with an id that has a space in it. When I try to render the block in the page, I get nothing.

scottrigby’s picture

Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

@yevgeny.ananin Yes theme_highcharts_chart() was removed (and explained) in 6c537c3b. I just noticed the $attributes param documentation for highcharts_render() still refers to that deprecated theme function.

Can you post the code you're using to generate your chart? It may help sort out what is happening.