Comments (15)
Selector support can be added with Sizzle! I'd like it to be optional—if you include Sizzle (before loading D3) then it enables backwards-compatibility via Sizzle, and otherwise it requires the native methods.
The funny thing about the slice
error is that I'm guessing it's occurring in d3_array
, which is already a compatibility routine for converting psuedo-arrays to true arrays. So, it's a shame that's not working. I wonder if the native methods work if they take psuedo-arrays as arguments rather than as this
, say:
var array = [];
array.push.apply(array, psuedoarray);
return array;
Of course, this probably isn't a good idea because there is a limit to the total number of arguments you can pass to a method. (I think around 10,000.) So you could do something like concat
:
return [].concat(psuedoarray);
But it turns out that doesn't work for psuedo-arrays (like arguments
), because the concat
routine's type-inspection for array arguments fails for psuedo-arrays. /facepalm
The funny thing is my original version is based on Mozilla's recommendation, so I'm surprised it doesn't actually work cross-browser:
https://developer.mozilla.org/en/JavaScript/Reference/functions_and_function_scope/arguments
Alternatively, since it's pretty simple, we could do it manually. But then it's slower for the modern browsers:
var i = -1,
n = psuedoarray.length,
array = [];
while (++i < n) array.push(psuedoarray[i]);
return array;
Actually, maybe it's not slower, at least for some browsers:
http://jsperf.com/arguments-slice
from d3.
Cool, I didn't realise D3 supported Sizzle already!
Here's some more info on the error I was getting, namely JScript Object Expected
. It seems that it's implementation-dependent as to whether "host objects" work with this or not.
The good thing is, it seems Sizzle has already encountered this problem as they detect it and provide a fallback:
var makeArray = function( array, results ) {
array = Array.prototype.slice.call( array, 0 );
if ( results ) {
results.push.apply( results, array );
return results;
}
return array;
};
// Perform a simple check to determine if the browser is capable of
// converting a NodeList to an array using builtin methods.
// Also verifies that the returned array holds DOM nodes
// (which is not the case in the Blackberry browser)
try {
Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
// Provide a fallback method if it does not work
} catch( e ) {
makeArray = function( array, results ) {
var i = 0,
ret = results || [];
if ( toString.call(array) === "[object Array]" ) {
Array.prototype.push.apply( ret, array );
} else {
if ( typeof array.length === "number" ) {
for ( var l = array.length; i < l; i++ ) {
ret.push( array[i] );
}
} else {
for ( ; array[i]; i++ ) {
ret.push( array[i] );
}
}
}
return ret;
};
}
from d3.
I haven't plugged in Sizzle support just yet, but that's the plan. I'd love your help if you have the time and are willing!
from d3.
Would love to, watch this space...
from d3.
Just added Sizzle support in 1.0.0. Still need to fix the slice
exception, though.
from d3.
Cool, 1.0.0! Sorry I didn't get a chance to add Sizzle in myself :)
What do you think about copying the Sizzle code above to fix the slice
exception? It uses Array.prototype.slice
if possible so there wouldn't be any performance degradation in the browsers currently supported. The fallback seems a bit gnarly due to using toString
to detect an Array
, but at least it's a starting point. Also, the mention of Blackberry in the comment makes me think they've tested this stuff pretty extensively, which is encouraging!
from d3.
Yep, I'd support that change!
from d3.
Fixed in 1.0.2.
from d3.
Version 1.17.1 is not working in IE8 any more.
Array.map
is not available. Workaround at https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/map
createElementNS
ist not available. Workaround probably is to use createElement
instead.
from d3.
What is the current status of this issue?
I'm getting "Object doesn't support this property or method" with IE8 in d3.js 2.4.2 line 1525:
return this.appendChild(document.createElement.........
when I run the bullet charts example from the d3.js homepage.
What is the history of development of d3 running on IE<9? Plans for future?
from d3.
The current status is this issue is closed. :) There are no plans to support IE8-, as it doesn't have SVG. If someone submitted a pull request which had minimal impact (in terms of code complexity or performance) then I would be willing to merge it to support IE8-, but I have no plans to find and fix these bugs myself.
from d3.
Did anyone experiment using it with svgweb in IE 8-?
from d3.
@lailsonbm We just ran through this at work this week. svgweb
is a nice drop-in solution for SVG, but d3 definitely isn't out-of-the-box compatible with IE even there. Array.map
is the first thing to break, and once you polyfill that, there are some appendChild
things that stop working, but svgweb
fixes those. After that, we started running into code that just wasn't IE compatible.
My assessment is that it's likely possible to get d3 running under IE8, but it's not a trivial amount of work.
from d3.
@mark-rushakoff I see your point. Thanks for the response.
from d3.
I managed to get most of the d3 functionality working in IE using Raphael to handle rendering under svg element selections. Basically I added DOM API's that D3 expects to be present on raphael elements and the paper object. This allows d3 to create selections around Raphael objects without modifying much of D3 at all. In fact, I reference tagged releases of D3 and build out r2d3 by modifying only selection-append and selection-text modules.
I'd love any feedback anyone might have. The goal is that when IE8 support is no longer needed, a user can flip back to D3 with little to no code modifications.
Currently the only major features missing that I'm aware of are the group element and styling via css. You can check out the project here: https://github.com/mhemesath/r2d3
from d3.
Related Issues (20)
- rollup -c fails. es6 bundle
- Query on how to build Custom Scale
- Main license set as ISC, but BSD-3-clause listed in the license file
- .on("dblclick", function) event does not work
- `geoContains(object, point)` returns `true` for a `point` outside the `object` HOT 5
- ReDoS vulnerability on RegExp used in d3js HOT 3
- d3 scaleBand paddingInner combination with paddingOuter(0)
- svg拖动过程中出现白色异常
- NextJS 15.0.3: Unexpected end of JSON input HOT 2
- TrustedTypePolicy.createHTML() in d3.svg HOT 2
- Inconsistency using foreign object with D3 in Chromium
- adding random node to leaf, but after adding new node the zoom level returns to root node,
- How to Modify the Coordinate System with d3-zoom?
- Failed to read the 'value' property from 'SVGLength': Could not resolve relative length.
- LineString am I missing somthing
- Gap between chart bars when daylight savings ends
- Mapping Course Flows in College Degree Programs
- Support links on d3js.org are outdated
- d3 zoom mouse event consumtion question
- [Need feedback] Open source research: d3/d3 edition
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3.