Support Forum

Please note that this forum is only available to you in read only mode. In order to contribute to this conversation you will need to renew your subscription.

Using D3 Graphics

zentoolsIf you use Zentools please post a review at the Joomla! Extensions Directory.

I'm trying to use D3 and javascript to create charts on some webpages. The d3 behaves as expected--expected the results show up below the footer, outside the template area. Is there something I'm missing so that I can use d3?
  • Scott Richmond's Avatar
  • Scott Richmond
  • 12 Month basic
  • 50 posts
  • Karma: 0
The administrator has disabled public write access.
D3 meaning svg files?

Cheers
Paul
  • manh's Avatar
  • manh
  • Moderator
  • 45248 posts
  • 2106 Thanks
  • Karma: 603
The administrator has disabled public write access.
Yes. D3 is SVG.
  • Scott Richmond's Avatar
  • Scott Richmond
  • 12 Month basic
  • 50 posts
  • Karma: 0
The administrator has disabled public write access.
Don't think this has cropped up before

Do you have a link for an example?

Cheers
Paul
  • manh's Avatar
  • manh
  • Moderator
  • 45248 posts
  • 2106 Thanks
  • Karma: 603
The administrator has disabled public write access.
www.west-fly-fishing.com/index.php/tides/856-test-chart


Scroll to the very bottom, way past the footer.
  • Scott Richmond's Avatar
  • Scott Richmond
  • 12 Month basic
  • 50 posts
  • Karma: 0
The administrator has disabled public write access.
How are you loading the content? is it via an article or module?

Cheers
Paul
  • manh's Avatar
  • manh
  • Moderator
  • 45248 posts
  • 2106 Thanks
  • Karma: 603
The administrator has disabled public write access.
Via an article. The article contents are:

{source}
<?php

echo '{zen-row}{zen-12}';
include 'tides/testT.php';
echo '{/zen-12}{/zen-row}';
echo '{zen-row}{zen-8}';
include 'tides/testL.php';
include 'tides/testL.js';
echo '{/zen-8}{zen-4}';
include 'tides/testR.php';
echo '{/zen-4}{/zen-row}';


?>
{/source}

the php "include" files simply print Top, Left, and Right as placeholders. The graphics are in tides/testL.js
  • Scott Richmond's Avatar
  • Scott Richmond
  • 12 Month basic
  • 50 posts
  • Karma: 0
The administrator has disabled public write access.
Hi,

I'm not sure how loading a php file in an article content would work. You would need to check with the makers of the plugin you are using. If you are echoing content it's probably being outputted before the content even gets to the template.

It seems to be the same with the protostar template: www.west-fly-fishing.com/index.php/tides/856-test-chart?template=protostar

Since D3 is a js library, I would probably think the best way to use it would be to ad a div with an id into your content and then include a javascript file with you d3 code in the template that targets your div id.

Regards,

Rob
  • Robert Went's Avatar
  • Robert Went
  • Moderator
  • 2210 posts
  • 196 Thanks
  • Karma: 90
The administrator has disabled public write access.
Looking at the file here: www.west-fly-fishing.com/tides/test.js

You are targeting the body tag and then inserting the svg at the end of it:
var svg = d3.select("body").append("svg").attr("height","100%").attr("width","100%");

You can use the add scripts area of the template to include your standard d3.js file, bu you need to adjust you custom code to target an element that you have added where you want the graph to show.

Regards,

Rob
  • Robert Went's Avatar
  • Robert Went
  • Moderator
  • 2210 posts
  • 196 Thanks
  • Karma: 90
The administrator has disabled public write access.

zentoolsIf you use Zentools please post a review at the Joomla! Extensions Directory.

Happy Campers