# DESCRIPTION # Test of d3plus plot # written by Jan Hlavacek (jhlavace@svsu.edu) # ENDDESCRIPTION ## DBsubject('') ## DBchapter('') ## DBsection('') ## KEYWORDS('') ## TitleText1('') ## EditionText1('') ## AuthorText1('') ## Section1('') ## Problem1('') ## Author('Jan Hlavacek') ## Institution('SVSU') DOCUMENT(); HEADER_TEXT(<<'EOF'); <script src="https://www.d3plus.org/js/d3.js"></script> <script src="https://www.d3plus.org/js/d3plus.js"></script> <script language="javascript" type="text/javascript"> <!-- // var data = [ {"year": 1991, "name":"alpha", "value": 15}, {"year": 1992, "name":"alpha", "value": 34}, {"year": 1991, "name":"alpha2", "value": 17}, {"year": 1992, "name":"alpha2", "value": 65}, {"year": 1991, "name":"beta", "value": 10}, {"year": 1992, "name":"beta", "value": 10}, {"year": 1991, "name":"beta2", "value": 40}, {"year": 1992, "name":"beta2", "value": 38}, {"year": 1991, "name":"gamma", "value": 5}, {"year": 1992, "name":"gamma", "value": 10}, {"year": 1991, "name":"gamma2", "value": 20}, {"year": 1992, "name":"gamma2", "value": 34}, {"year": 1991, "name":"delta", "value": 50}, {"year": 1992, "name":"delta", "value": 43}, {"year": 1991, "name":"delta2", "value": 17}, {"year": 1992, "name":"delta2", "value": 35} ] $(document).ready(function(){ var visualization = d3plus.viz() .container("#viz") .data(data) .type("box") .id("name") .x("year") .y("value") .time("year") .ui([{ "label": "Visualization Type", "method": "type", "value": ["scatter","box"] }]) .draw(); }); // --> </script> EOF loadMacros( "PGstandard.pl", "MathObjects.pl", "PGML.pl", "PGcourse.pl", ); Context("Numeric"); # Define variables here: # Actual problem goes here: TEXT(beginproblem()); TEXT( MODES(TeX=>'', HTML=><<END_SCRIPT ) ); <div id="viz"></div> END_SCRIPT BEGIN_PGML blah blah END_PGML # Solution: BEGIN_PGML_SOLUTION *SOLUTION* hkjhkj END_PGML_SOLUTION ENDDOCUMENT();
It is supposed to insert an interactive figure with two box plots, it is just a verbatim copy of an example from the d3plus page. The best I could do was to get a 'd3plus is not defined' in the javascript console at the line where `d3plus.viz` is called. Other things I tried lead either to more serious javascript errors or WeBWorK errors. Is there any way to insert d3, d3plus, jsxgraph, raphael etc visualization into WeBWorK problems?