shutterstock / rickshaw

JavaScript toolkit for creating interactive real-time graphs
https://shutterstock.github.io/rickshaw
MIT License
6.53k stars 941 forks source link

Safari TypeError #468

Open mikebronner opened 10 years ago

mikebronner commented 10 years ago

Getting the following error in Safari:

TypeError: 'undefined' is not a function (evaluating 'this.graph.onUpdate(function(){self.render()})')
rickshaw.min.js:1:27073
Time

Using the following code:

    <div id="gl_whs_chart_container">
        <div id="y_axis"></div>
        <div id="chart"></div>
    </div>

    <script>
        var graph = new Rickshaw.Graph.Ajax( {
            element: document.querySelector("#chart"),
            renderer: 'line',
            dataURL: 'myajax.php',
            width: 580,
            height: 250,
            onError: function (error) {console.log(error);},
            series: [ {
                name: 'Ambient Temperature'
            } ]
        } );
        var x_axis = new Rickshaw.Graph.Axis.Time({ graph: graph } );
        graph.request();
    </script>
mikebronner commented 10 years ago

This error went away after including the vendor files as used in the examples. (I had previously included the d3 files from the wordpress plugin.)

mikebronner commented 10 years ago

Ah, correction: this wasn't down to the includes. This was happening for AJAX charts, but not for static charts (I had reverted back to static for testing).

davidjb commented 9 years ago

Just hit the same issue. The cause is your x axis declaration -- it needs to be placed into an onComplete callback like so:

var graph = new Rickshaw.Graph.Ajax( {
    ...
    onComplete: function(transport) {
        var graph = transport.graph;
        var x_axis = new Rickshaw.Graph.Axis.Time({ graph: graph } );
    }

An example for HoverDetail is at http://code.shutterstock.com/rickshaw/guide/ajax-1.html, but the idea is the same.