score:5
Accepted answer
d3 can't find elements inside a shadowDOM but you look up the element in Dart and pass it to d3's select method.
something like this (not tested)
import 'dart:js' as js;
js.context['d3'].callMethod('select', [shadowRoot.querySelector('.chart')]);
more info about Dart-JS-interop: https://www.dartlang.org/articles/js-dart-interop/
score:1
I wrapped the D3 JS fragment that prints the bar chart in a function and invoked it from Dart as follows:
dart-js.html
var x = function(elt) {
console.log('x');
d3.select(elt)
.selectAll("div")
.data(data)
.enter().append("div")
.style("width", function (d) { return d * 10 + "px"; })
.text(function (d) { return d; });
};
dart_js.dart
import 'package:polymer/polymer.dart';
import 'dart:js' as js;
@CustomTag('dart-js')
class DartJs extends PolymerElement {
/* Life cycle events */
// required -- constructor must call superclass
DartJs.created() : super.created() {
print("dart-js started");
}
@override void enteredView() {
super.enteredView();
print('dart_js entered');
js.context.callMethod('x', [shadowRoot.querySelector('.chart')]);
}
}
Source: stackoverflow.com
Related Query
- How to embed a D3 chart in a Polymer.dart element?
- D3.js how to embed selection into a new element
- How to correctly centre text element on all bars of a nvd3 bar chart
- How can I add a <g> element to my chart
- How to partially fill an SVG element in isotype chart
- Polymer & D3: How to send JSON from element attribute to template
- How to apply box-shadow effect on svg circle by changing svg filter element in D3 chart
- How to access the DOM element that correlates to a D3 SVG object?
- How to select parent element of current element in d3.js
- How to center text in a rect element in d3?
- How to set text color for my d3 chart title?
- How do I get the width of an svg element using d3js?
- D3: How to refresh a chart with new data?
- How to integrate d3.js chart in C# application?
- How to customize color in pie chart of NVD3
- How can I position rotated x-axis labels on column chart using nvd3?
- How to turn a raw DOM element in to a D3 selection?
- MultiBar chart with nvd3 / d3 only shows labels for every other tick on the x-axis. How can I get them all to show up?
- d3js : How to select nth element of a group?
- How to add drop shadow to d3.js pie or donut chart
- How to apply horizontal break to a d3.js bar chart
- how to assign unique id to SVG text element in d3 javascript
- How to embed a d3.js example to the Jekyll blog post?
- How to do wordwrap for chart labels using d3.js
- How do you make an SVG element mouse event bubble up through another element?
- How to update d3.js bar chart with new data
- how to create labels for data in donut chart using d3.js
- How to insert after a sibling element in d3.js
- how to get dynamic value of input element with d3?
- How to use a JavaScript chart library like D3.js or Raphaël in server-side Java
More Query from same tag
- How to bind d3 generated HTML elements to scope?
- Can d3's transition and rotation play well together?
- In D3 force-directed layout, how can I position fixed nodes programmatically, without dragging?
- scale SVG d3.js (no event)
- Multiples with x/y axis and mouseover example - line path shows wrong values
- what means a type like SomeType<T, U, V> in typescript?
- Angular, D3 - Cannot read property 'forEach' of undefined
- Transitions in D3 on load
- d3.js dynamic data from database
- How to hide the tooltip in dimplejs?
- Can we use custom JSON Data on Cubism?
- Number of features by day javascript
- Loop through paths D3 with .each
- read updated data on client from file created by server JSP
- Initial Range selection in DC.js chart
- How to pause d3.js simulation using javascript?
- axis doesn't appear on barchart
- jquery .ready() equivalent in d3js?
- D3 selection.append("image") from a cached response
- How to include libraries through the python local server
- Charge based on size - d3 force layout
- Convert d3 map to high resolution image
- D3.js - browser freezing - too many elements on updating with time?
- NVD3 Logarithmic Y axis with barchart
- NVD3 Cumulative Line Chart : How to save Line Chart as image
- Select a region over an arc
- Zooming and brushing in d3 force directed graph
- D3 - Grid when the axis is in the middle of the page
- How to get an item from d3 collection by index?
- update line when dragging point in grouped multiline chart