Skip to main content
edited body
Source Link
Lightness Races in Orbit
  • 386.8k
  • 77
  • 670
  • 1.1k

It's evaluate. That was the function I was looking for. It Evaluates the given function in the context of the web page"evaluates the given function in the context of the web page".

Finally, it's working:

page.content = content; 
page.injectJs('lib/d3/d3.min.js');
page.evaluate(function() {
    var svg = d3.select('#graph')
                .append('svg')
                .attr({'width': 100, 'height': 100});   

    var circle = svg
        .append('circle')
        .attr({ 'cx': 10, 'cy': 10, 'r': 10, 'fill': 'blue' });   

    page.render('test.png');
    phantom.exit();
};

It's evaluate. That was the function I was looking for. It Evaluates the given function in the context of the web page.

Finally, it's working:

page.content = content; 
page.injectJs('lib/d3/d3.min.js');
page.evaluate(function() {
    var svg = d3.select('#graph')
                .append('svg')
                .attr({'width': 100, 'height': 100});   

    var circle = svg
        .append('circle')
        .attr({ 'cx': 10, 'cy': 10, 'r': 10, 'fill': 'blue' });   

    page.render('test.png');
    phantom.exit();
};

It's evaluate. That was the function I was looking for. It "evaluates the given function in the context of the web page".

Finally, it's working:

page.content = content; 
page.injectJs('lib/d3/d3.min.js');
page.evaluate(function() {
    var svg = d3.select('#graph')
                .append('svg')
                .attr({'width': 100, 'height': 100});   

    var circle = svg
        .append('circle')
        .attr({ 'cx': 10, 'cy': 10, 'r': 10, 'fill': 'blue' });   

    page.render('test.png');
    phantom.exit();
};
Source Link
yuvi
  • 18.5k
  • 9
  • 63
  • 98

It's evaluate. That was the function I was looking for. It Evaluates the given function in the context of the web page.

Finally, it's working:

page.content = content; 
page.injectJs('lib/d3/d3.min.js');
page.evaluate(function() {
    var svg = d3.select('#graph')
                .append('svg')
                .attr({'width': 100, 'height': 100});   

    var circle = svg
        .append('circle')
        .attr({ 'cx': 10, 'cy': 10, 'r': 10, 'fill': 'blue' });   

    page.render('test.png');
    phantom.exit();
};