5 #ifndef __SELECTION_H__ 6 #define __SELECTION_H__ 18 #include "../../base/assert.h" 19 #include "../js_utils.h" 20 #include "../JSWrap.h" 24 extern int n_objects();
38 template <
typename DERIVED>
47 DERIVED
Select(std::string selector)
const {
51 var new_selection = js.objects[$0].select(Pointer_stringify($1));
52 js.objects[$2] = new_selection;
53 }, this->
id, selector.c_str(), new_id);
55 return DERIVED(new_id);
65 var new_selection = js.objects[$0].selectAll(Pointer_stringify($1));
66 js.objects[$2] = new_selection;
67 }, this->
id, selector.c_str(), new_id);
69 return DERIVED(new_id);
80 DERIVED&
Call(std::string
function){
82 var func_string = Pointer_stringify($1);
83 if (typeof window[func_string] ===
"function") {
84 func_string = window[func_string];
85 }
else if (typeof window[
"emp"][func_string] ===
"function") {
86 func_string = window[
"emp"][func_string];
87 }
else if (typeof window[
"d3"][func_string] ===
"function") {
88 func_string = window[
"d3"][func_string];
91 emp.__new_object = js.objects[$0].call(
function(sel){
return func_string($0);});
92 }, this->
id,
function.c_str());
94 return *(
static_cast<DERIVED *
>(
this));
102 uint32_t fun_id = emp::JSWrap(
function,
"",
false);
104 emp.__new_object = js.objects[$0].call(
function(selection) {
105 return emp.Callback($1, $0);
107 }, this->
id, fun_id);
108 emp::JSDelete(fun_id);
110 return *(
static_cast<DERIVED *
>(
this));
122 DERIVED
Filter(std::string selector)
const {
127 return DERIVED(new_id);
132 template <
typename T>
134 Filter(T selector)
const {
139 return DERIVED(new_id);
148 DERIVED&
Each(std::string
function){
150 return *(
static_cast<DERIVED *
>(
this));
155 template <
typename T>
159 return *(
static_cast<DERIVED *
>(
this));
167 EM_ASM_ARGS({js.objects[$0].remove()},
175 js.objects[$2] = js.objects[$0].merge(js.objects[$1]);
177 }, this->
id, other.GetID(), new_id);
178 return DERIVED(new_id);
208 DERIVED&
SetAttr(std::string name, std::string value) {
211 return *(static_cast<DERIVED *>(
this));
218 template <
typename T>
219 typename std::enable_if<std::is_fundamental<T>::value, DERIVED&>::type
220 SetAttr(std::string name, T value) {
222 EM_ASM_ARGS({js.objects[$0].attr(Pointer_stringify($1), $2)},
223 this->
id, name.c_str(), value);
224 return *(
static_cast<DERIVED *
>(
this));
230 template <
typename T>
232 SetAttr(std::string name, T value) {
235 uint32_t fun_id = emp::JSWrap(value,
"",
false);
238 js.objects[$0].attr(Pointer_stringify($1),
function(d, i, k) {
239 return emp.Callback($2, d, i, k);
241 }, this->
id, name.c_str(), fun_id);
243 emp::JSDelete(fun_id);
245 return *(
static_cast<DERIVED *
>(
this));
252 DERIVED&
SetAttr(std::string name,
const char * value) {
255 return *(static_cast<DERIVED *>(
this));
259 template <
typename T>
260 typename std::enable_if<T::value_type !=
"", DERIVED&>::type
261 SetAttr(std::string name, T value) {
265 js.objects[$0].attr(Pointer_stringify($1), emp_i.__incoming_array);
266 }, this->
id, name.c_str());
268 return *(
static_cast<DERIVED *
>(
this));
284 DERIVED&
SetStyle(std::string name, std::string value,
bool priority=
false){
287 var func_string = Pointer_stringify($2);
288 if (typeof window[func_string] ===
"function") {
289 func_string = window[func_string];
291 for (name in {d3:
"d3",
emp:
"emp"}) {
292 if (typeof window[name][func_string] ===
"function") {
293 func_string = window[name][func_string];
296 js.objects[$0].style(Pointer_stringify($1), in_string,
"important");
297 }, this->
id, name.c_str(), value.c_str());
301 return *(static_cast<DERIVED *>(
this));
308 DERIVED&
SetStyle(std::string name,
const char* value,
bool priority=
false){
311 var func_string = Pointer_stringify($2);
312 if (typeof window[func_string] ===
"function") {
313 func_string = window[func_string];
315 for (name in {d3:
"d3",
emp:
"emp"}) {
316 if (typeof window[name][func_string] ===
"function") {
317 func_string = window[name][func_string];
320 js.objects[$0].style(Pointer_stringify($1), in_string,
"important");
321 }, this->
id, name.c_str(), value);
325 return *(static_cast<DERIVED *>(
this));
331 template <
typename T>
333 SetStyle(std::string name, T value) {
335 return *(
static_cast<DERIVED *
>(
this));
339 template <
typename T>
340 typename std::enable_if<std::is_fundamental<T>::value, DERIVED&>::type
341 SetStyle(std::string name, T value,
bool priority=
false){
343 EM_ASM_ARGS({js.objects[$0].style(Pointer_stringify($1), $2,
"important")},
344 this->
id, name.c_str(), value);
347 EM_ASM_ARGS({js.objects[$0].style(Pointer_stringify($1), $2)},
348 this->
id, name.c_str(), value);
350 return *(
static_cast<DERIVED *
>(
this));
359 return *(static_cast<DERIVED *>(
this));
364 template <
typename T>
368 return *(
static_cast<DERIVED *
>(
this));
375 #ifdef DOXYGEN_RUNNING 385 DERIVED&
SetProperty(std::string name, std::string value) {
return *(
static_cast<DERIVED *
>(
this));}
392 DERIVED&
SetHtml(std::string value) {
return *(
static_cast<DERIVED *
>(
this));}
400 DERIVED&
SetClassed(std::string classname,
bool value) {
return *(
static_cast<DERIVED *
>(
this));}
426 char * buffer = (
char *)EM_ASM_INT({
427 var text = js.objects[$0].attr(Pointer_stringify($1));
428 var buffer = Module._malloc(text.length+1);
429 Module.writeStringToMemory(text, buffer);
431 }, this->
id, name.c_str());
433 std::string result = std::string(buffer);
441 return js.objects[$0].attr(Pointer_stringify($1));
442 }, this->
id, name.c_str());
447 return EM_ASM_DOUBLE({
448 return js.objects[$0].attr(Pointer_stringify($1));
449 }, this->
id, name.c_str());
454 char * buffer = (
char *)EM_ASM_INT({
455 var text = js.objects[$0].style(Pointer_stringify($1));
456 var buffer = Module._malloc(text.length+1);
457 Module.writeStringToMemory(text, buffer);
459 }, this->
id, name.c_str());
461 std::string result = std::string(buffer);
469 return js.objects[$0].style(Pointer_stringify($1));
470 }, this->
id, name.c_str());
475 return EM_ASM_DOUBLE({
476 return js.objects[$0].style(Pointer_stringify($1));
477 }, this->
id, name.c_str());
483 char * buffer = (
char *)EM_ASM_INT({
484 var text = js.objects[$0].text();
485 var buffer = Module._malloc(text.length+1);
486 Module.writeStringToMemory(text, buffer);
490 std::string result = std::string(buffer);
498 #ifdef DOXYGEN_RUNNING 528 int empty = EM_ASM_INT({
return Number(js.objects[$0].empty())},
535 return EM_ASM_INT({
return js.objects[$0].size()},
574 var transition = js.objects[$0].transition(Pointer_stringify($1));
575 js.objects[$2] = transition;
576 }, this->
id, name.c_str(), new_id);
581 #ifndef DOXYGEN_RUNNING 600 Transition& On(std::string type, std::string listener=
"null",
bool capture=
false){
604 var func_string = Pointer_stringify($0);
605 if (func_string ==
"null") {
608 if (typeof window[func_string] ===
"function") {
609 func_string = window[func_string];
611 for (name in {d3:
"d3",
emp:
"emp"}) {
612 if (typeof window[name][func_string] ===
"function") {
613 func_string = window[name][func_string];
616 return (typeof func_string ===
"function");
617 }, listener.c_str()) \
618 &&
"String passed to On is not s Javascript function or null", listener);
623 var func_string = Pointer_stringify($2);
624 if (typeof window[func_string] ===
"function") {
625 func_string = window[func_string];
627 for (name in {d3:
"d3",
emp:
"emp"}) {
628 if (typeof window[name][func_string] ===
"function") {
629 func_string = window[name][func_string];
633 if (typeof func_string ===
"function") {
634 js.objects[$0].on(Pointer_stringify($1),
637 js.objects[$0].on(Pointer_stringify($1), null);
640 }, this->
id, type.c_str(), listener.c_str(), capture, new_id);
648 template <
typename T>
650 On(std::string type, T listener,
bool capture=
false){
652 uint32_t fun_id = emp::JSWrap(listener,
"",
false);
656 js.objects[$0].on(Pointer_stringify($1),
658 js.objects[$4] = d3.select(
this);
659 emp.Callback($2, d, i, $4);}, $3);
660 }, this->
id, type.c_str(), fun_id, capture, new_id);
662 emp::JSDelete(fun_id);
670 js.objects[$0].duration($1);
682 var arg1 = Pointer_stringify($1); \
683 var func_string = Pointer_stringify($2);
684 if (typeof window[func_string] ===
"function") {
685 func_string = window[func_string];
687 for (name in {d3:
"d3",
emp:
"emp"}) {
688 if (typeof window[name][func_string] ===
"function") {
689 func_string = window[name][func_string];
692 js.objects[$0].each(
"end",
function(){
693 d3.select(
this).property(arg1, func_string);
695 }, name.c_str(), value.c_str());
704 var arg1 = Pointer_stringify($1); \
705 var func_string = Pointer_stringify($2);
706 if (typeof window[func_string] ===
"function") {
707 func_string = window[func_string];
709 for (name in {d3:
"d3",
emp:
"emp"}) {
710 if (typeof window[name][func_string] ===
"function") {
711 func_string = window[name][func_string];
714 js.objects[$0].each(
"end",
function(){
715 d3.select(
this).property(arg1, func_string);
717 }, name.c_str(), value);
722 template <
typename T>
723 typename std::enable_if<std::is_fundamental<T>::value,
Transition&>::type
726 js.objects[$0].each(
"end",
function() {
727 d3.select(
this).property(Pointer_stringify($1), $2);
729 }, this->
id, name.c_str());
736 template <
typename T>
739 uint32_t fun_id = emp::JSWrap(value,
"",
false);
741 js.objects[$0].each(
"end",
function(){
742 d3.select(
this).property(Pointer_stringify($1),
744 return emp.Callback($2, d, i, j);
747 }, this->
id, name.c_str(), fun_id);
748 emp::JSDelete(fun_id);
758 var func_string = Pointer_stringify($1);
759 if (typeof window[func_string] ===
"function") {
760 func_string = window[func_string];
762 for (name in {d3:
"d3",
emp:
"emp"}) {
763 if (typeof window[name][func_string] ===
"function") {
764 func_string = window[name][func_string];
767 js.objects[$0].each(
"end",
function(){
768 d3.select(
this).html(func_string);
770 }, this->
id, value.c_str());
776 template <
typename T>
779 uint32_t fun_id = emp::JSWrap(func,
"",
false);
781 js.objects[$0].each(
"end",
function(){
782 d3.select(
this).html(
function(d, i, j) {
783 return emp.Callback($1, d, i, j);
786 }, this->
id, fun_id);
787 emp::JSDelete(fun_id);
798 js.objects[$0].each(
"end",
function(){
799 d3.select(
this).classed(Pointer_stringify($1), $2);
801 }, this->
id, classname.c_str(), value);
808 template <
typename T>
810 SetClassed(std::string, std::string classname, T func){
811 uint32_t fun_id = emp::JSWrap(func,
"",
false);
813 js.objects[$0].each(
"end",
function(){
814 d3.select(
this).classed(Pointer_stringify($1),
816 return emp.Callback($2, d, i, j);
819 }, this->
id, classname.c_str(), fun_id);
820 emp::JSDelete(fun_id);
828 var func_string = Pointer_stringify($0);
829 if (typeof window[func_string] ===
"function") {
830 func_string = window[func_string];
832 for (name in {d3:
"d3",
emp:
"emp"}) {
833 if (typeof window[name][func_string] ===
"function") {
834 func_string = window[name][func_string];
837 return (typeof func_string ===
"function");
838 }, value.c_str()) &&
"String passed to SetClassed is not a Javascript function", value);
841 var arg1 = Pointer_stringify($1); \
842 var func_string = Pointer_stringify($2);
843 if (typeof window[func_string] ===
"function") {
844 func_string = window[func_string];
846 for (name in {d3:
"d3",
emp:
"emp"}) {
847 if (typeof window[name][func_string] ===
"function") {
848 func_string = window[name][func_string];
851 js.objects[$0].each(
"end",
function(){
852 d3.select(
this).classed(arg1, func_string);
854 }, classname.c_str(), value.c_str());
883 char * buffer = (
char *)EM_ASM_INT({
884 var text = d3.select(js.objects[$0]).html();
885 var buffer = Module._malloc(text.length+1);
886 Module.writeStringToMemory(text, buffer);
890 std::string result = std::string(buffer);
897 char * buffer = (
char *)EM_ASM_INT({
898 var text = d3.select(js.objects[$0]).property(Pointer_stringify($1));
899 var buffer = Module._malloc(text.length+1);
900 Module.writeStringToMemory(text, buffer);
902 }, this->
id, name.c_str());
904 std::string result = std::string(buffer);
912 return d3.select(js.objects[$0]).property(Pointer_stringify($1));
913 }, this->
id, name.c_str());
918 return EM_ASM_DOUBLE({
919 return d3.select(js.objects[$0]).property(Pointer_stringify($1));
920 }, this->
id, name.c_str());
947 EM_ASM_ARGS({js.objects[$0] = d3.selection();}, this->
id);
972 js.objects[$0] = d3.selectAll(Pointer_stringify($1));
973 }, this->
id, selector.c_str());
977 js.objects[$0] = d3.select(Pointer_stringify($1));
978 }, this->
id, selector.c_str());
1014 var in_string = Pointer_stringify($1);
1015 var fn = window[
"emp"][in_string];
1016 if (typeof fn ===
"function"){
1017 var update_sel = js.objects[$0].data(js.objects[$2], fn);
1018 }
else if (typeof window[
"d3"][in_string] ===
"function") {
1019 var update_sel = js.objects[$0].data(js.objects[$2],
1020 window[
"d3"][in_string]);
1021 }
else if (typeof window[in_string] ===
"function") {
1022 var update_sel = js.objects[$0].data(js.objects[$2],
1025 var update_sel = js.objects[$0].data(js.objects[$2]);
1028 js.objects[$3] = update_sel;
1029 },this->
id, key.c_str(), values.
GetID(), update_id);
1038 template<
typename T>
1040 Data(
Dataset & values, T key){
1042 uint32_t fun_id = emp::JSWrap(key,
"",
false);
1045 var update_sel = js.objects[$0].data(js.objects[$2],
1047 return emp.Callback($1, d, i);
1049 js.objects[$3] = update_sel;
1051 }, this->
id, fun_id, values.
GetID(), update_id);
1053 emp::JSDelete(fun_id);
1078 template<
typename C,
class =
typename C::value_type>
1080 Selection Data(C values, std::string key=
""){
1088 var in_string = Pointer_stringify($1);
1089 var fn = window[
"emp"][in_string];
1090 if (typeof fn ===
"function"){
1091 var update_sel = js.objects[$0].data(emp_i.__incoming_array, fn);
1092 }
else if (typeof window[
"d3"][in_string] ===
"function") {
1093 var update_sel = js.objects[$0].data(emp_i.__incoming_array,
1094 window[
"d3"][in_string]);
1095 }
else if (typeof window[in_string] ===
"function") {
1096 var update_sel = js.objects[$0].data(emp_i.__incoming_array,
1099 var update_sel = js.objects[$0].data(emp_i.__incoming_array);
1102 js.objects[$2] = update_sel;
1103 }, this->
id, key.c_str(), update_id);
1110 template<
typename C,
class =
typename C::value_type,
typename T>
1112 Data(C values, T key){
1115 uint32_t fun_id = emp::JSWrap(key,
"",
false);
1118 var update_sel = js.objects[$0].data(emp_i.__incoming_array,
1120 return emp.Callback($1, d, i, k);
1122 js.objects[$2] = update_sel;
1123 }, this->
id, fun_id, update_id);
1125 emp::JSDelete(fun_id);
1136 js.objects[$1] = [js.objects[$0].data()];
1137 }, this->
id, new_id);
1152 var append_selection = js.objects[$0].enter()
1153 .append(Pointer_stringify($1));
1154 js.objects[$2] = append_selection;
1155 }, this->
id, type.c_str(), new_id);
1167 if (before.c_str()){
1169 var new_sel = js.objects[$0].enter().insert(Pointer_stringify($1),
1170 Pointer_stringify($2));
1171 js.objects[$3] = new_sel;
1172 }, this->
id, name.c_str(), before.c_str(), new_id);
1175 var new_sel = js.objects[$0].enter().insert(Pointer_stringify($1));
1176 js.objects[$2] = new_sel;
1177 }, this->
id, name.c_str(), new_id);
1193 var enter_selection = js.objects[$0].enter();
1194 js.objects[$1] = enter_selection;
1195 }, this->
id, new_id);
1209 var exit_selection = js.objects[$0].exit().remove();
1210 js.objects[$1] = exit_selection;
1211 }, this->
id, new_id);
1225 var exit_selection = js.objects[$0].exit();
1226 js.objects[$1] = exit_selection;
1227 }, this->
id, new_id);
1234 #ifndef DOXYGEN_RUNNING 1272 template <
typename T>
1273 typename std::enable_if<std::is_fundamental<T>::value,
Selection&>::type
1275 EM_ASM_ARGS({js.objects[$0].property(Pointer_stringify($1),
1276 $2)}, this->
id, name.c_str());
1283 template <
typename T>
1301 template <
typename T>
1315 js.objects[$0].classed(Pointer_stringify($1), $2);
1316 }, this->
id, classname.c_str(), value);
1323 template <
typename T>
1325 SetClassed(std::string, std::string classname, T func){
1333 var func_string = Pointer_stringify($0);
1334 if (typeof window[func_string] ===
"function") {
1335 func_string = window[func_string];
1337 for (name in {d3:
"d3",
emp:
"emp"}) {
1338 if (typeof window[name][func_string] ===
"function") {
1339 func_string = window[name][func_string];
1342 return (typeof func_string ===
"function");
1343 }, value.c_str()) &&
"String passed to SetClassed is not a Javascript function", value);
1372 char * buffer = (
char *)EM_ASM_INT({
1373 var text = js.objects[$0].html();
1374 var buffer = Module._malloc(text.length+1);
1375 Module.writeStringToMemory(text, buffer);
1379 std::string result = std::string(buffer);
1386 char * buffer = (
char *)EM_ASM_INT({
1387 var text = js.objects[$0].property(Pointer_stringify($1));
1388 var buffer = Module._malloc(text.length+1);
1389 Module.writeStringToMemory(text, buffer);
1391 }, this->
id, name.c_str());
1393 std::string result = std::string(buffer);
1401 return js.objects[$0].property(Pointer_stringify($1));
1402 }, this->
id, name.c_str());
1407 return EM_ASM_DOUBLE({
1408 return js.objects[$0].property(Pointer_stringify($1));
1409 }, this->
id, name.c_str());
1421 var new_selection = js.objects[$0].append(Pointer_stringify($1));
1422 js.objects[$2] = new_selection;
1423 }, this->
id, name.c_str(), new_id);
1435 if (before.c_str()){
1437 var new_sel = js.objects[$0].insert(Pointer_stringify($1),
1438 Pointer_stringify($2));
1439 js.objects[$3] = new_sel;
1440 }, this->
id, name.c_str(), before.c_str(), new_id);
1443 var new_sel = js.objects[$0].insert(Pointer_stringify($1));
1444 js.objects[$2] = new_sel;
1445 }, this->
id, name.c_str(), new_id);
1455 var transition = js.objects[$0].transition(Pointer_stringify($1));
1456 js.objects[$2] = transition;
1457 }, this->
id, name.c_str(), new_id);
1465 var transition = js.objects[$0].transition(js.objects[$1]);
1466 js.objects[$2] = transition;
1467 }, this->
id, t.
GetID(), new_id);
1476 js.objects[$0].interrupt(Pointer_stringify($1));
1477 }, this->
id, name.c_str());
1488 js.objects[$0].attr(
"transform",
"translate("+$1+
","+$2+
")");
1499 js.objects[$0].attr(
"transform",
"rotate("+$1+
")");
1500 }, this->
id, degrees);
1506 EM_ASM_ARGS({js.objects[$0].order()},
1512 EM_ASM_ARGS({js.objects[$0].raise();}, this->
id);
1517 EM_ASM_ARGS({js.objects[$0].lower();}, this->
id);
1533 Selection&
On(std::string type, std::string listener=
"null",
bool capture=
false){
1537 var func_string = Pointer_stringify($0);
1538 if (func_string ==
"null") {
1541 if (typeof window[func_string] ===
"function") {
1542 func_string = window[func_string];
1544 for (name in {d3:
"d3",
emp:
"emp"}) {
1545 if (typeof window[name][func_string] ===
"function") {
1546 func_string = window[name][func_string];
1549 return (typeof func_string ===
"function");
1550 }, listener.c_str()) \
1551 &&
"String passed to On is not s Javascript function or null", listener);
1556 var func_string = Pointer_stringify($2);
1557 if (typeof window[func_string] ===
"function") {
1558 func_string = window[func_string];
1560 for (name in {d3:
"d3",
emp:
"emp"}) {
1561 if (typeof window[name][func_string] ===
"function") {
1562 func_string = window[name][func_string];
1566 if (typeof func_string ===
"function") {
1567 js.objects[$0].on(Pointer_stringify($1),
1569 js.objects[$4] = d3.select(
this);
1570 func_string(d, i, $4);},
1573 js.objects[$0].on(Pointer_stringify($1), null);
1576 }, this->
id, type.c_str(), listener.c_str(), capture, new_id);
1584 template <
typename T>
1586 On(std::string type, T listener,
bool capture=
false){
1588 uint32_t fun_id = emp::JSWrap(listener,
"",
false);
1592 js.objects[$0].on(Pointer_stringify($1),
1594 js.objects[$4] = d3.select(
this);
1595 emp.Callback($2, d, i, $4);}, $3);
1596 }, this->
id, type.c_str(), fun_id, capture, new_id);
1598 emp::JSDelete(fun_id);
1620 template <
typename T>
1635 void SetupToolTip(
ToolTip & tip) {
1637 js.objects[$0].call(js.objects[$1]);
1642 void BindToolTipMouseover(
ToolTip & tip) {
1644 js.objects[$0].on(
"mouseover", js.objects[$1].show)
1645 .on(
"mouseout", js.objects[$1].hide);
1654 BindToolTipMouseover(tip);
1682 template<
typename T>
1692 template<
typename T>
Selection()
Default constructor - constructs empty selection.
Definition: selection.h:946
DERIVED Merge(DERIVED &other)
Definition: selection.h:171
int GetPropertyInt(std::string name)
Definition: selection.h:516
DERIVED SelectAll(std::string selector) const
Definition: selection.h:60
Selection Enter()
Definition: selection.h:1188
void Sort(emp::vector< T > &v, Ts...args)
A quick shortcut for sorting a vector.
Definition: vector_utils.h:94
std::string GetStyleString(std::string name) const
Get the value of this object's [name] style when it's a string.
Definition: selection.h:453
bool Empty() const
Returns true if there are no elements in this selection (or all elements are null) ...
Definition: selection.h:527
SelectionOrTransition()
Definition: selection.h:41
REAL_TYPE sfinae_decoy
Definition: meta.h:93
DERIVED & Call(std::string function)
Definition: selection.h:80
SelectionOrTransition(const SelectionOrTransition< DERIVED > &s)
Definition: selection.h:43
Transition MakeTransition(Transition &t)
Definition: selection.h:1462
Selection(const Selection &s)
Definition: selection.h:957
Selection & Sort(std::string comparator="ascending")
Definition: selection.h:1613
DERIVED & SetStyle(std::string name, std::string value, bool priority=false)
Definition: selection.h:284
#define D3_CALLBACK_METHOD_CPP_FUNCTION_1_ARG(FUNC, CPP_FUN)
Definition: utils.h:132
DERIVED & SetText(std::string text)
Definition: selection.h:357
void Remove()
Definition: selection.h:166
std::string GetHtml()
Definition: selection.h:504
DERIVED & SetAttr(std::string name, std::string value)
Definition: selection.h:208
#define D3_CALLBACK_METHOD_2_ARGS(FUNC, ARG1, ARG2)
Definition: utils.h:101
int id
Definition: d3_init.h:45
Definition: selection.h:547
void StoreNewObject(int id)
Definition: utils.h:142
double GetPropertyDouble(std::string name)
Definition: selection.h:522
Selection ShapesFromData(T values, std::string shape)
Definition: selection.h:1683
Selection & On(std::string type, std::string listener="null", bool capture=false)
Definition: selection.h:1533
DERIVED & SetProperty(std::string name, std::string value)
Definition: selection.h:385
DERIVED & SetHtml(std::string value)
Definition: selection.h:392
int GetAttrInt(std::string name) const
Get the value of this object's [name] attribute when it's an int.
Definition: selection.h:439
Selection EnterAppend(std::string type)
Definition: selection.h:1147
DERIVED Filter(std::string selector) const
Definition: selection.h:122
Definition: selection.h:39
Transition MakeTransition(std::string name="")
Definition: selection.h:1452
Definition: selection.h:936
Selection & Lower()
Definition: selection.h:1516
int NextD3ID()
Definition: d3_init.h:31
std::string GetAttrString(std::string name) const
Get the value of this object's [name] attribute when it's a string.
Definition: selection.h:425
Selection & Order()
Change the order of elements in the document to match their order in this selection.
Definition: selection.h:1505
double GetAttrDouble(std::string name) const
Get the value of this object's [name] attribute when it's a double.
Definition: selection.h:446
std::string GetText() const
Get this object's text.
Definition: selection.h:481
Dataset GetData() const
Definition: selection.h:1133
void AddToolTip(ToolTip &tip)
Add the ToolTip [tip] to the current selection.
Definition: selection.h:1652
DERIVED & SetClassed(std::string classname, bool value)
Definition: selection.h:400
If we are in emscripten, make sure to include the header.
Definition: array.h:37
Selection & Raise()
Definition: selection.h:1511
Selection EnterInsert(std::string name, std::string before=NULL)
Definition: selection.h:1164
Selection(int id)
Definition: selection.h:954
#define emp_assert(...)
Definition: assert.h:199
typename internal::ip_sort< T >::result sort
Definition: IntPack.h:193
Transition(int id)
Advanced: Construct new transition pointing to the [id]th element in js.objects.
Definition: selection.h:563
int GetStyleInt(std::string name) const
Get the value of this object's [name] style when it's an int.
Definition: selection.h:467
std::string GetPropertyString(std::string name)
Definition: selection.h:510
DERIVED & Each(std::string function)
Definition: selection.h:148
Selection & Move(int x, int y)
Definition: selection.h:1486
SelectionOrTransition(int id)
Definition: selection.h:42
Selection(std::string selector, bool all=false)
Definition: selection.h:969
Selection Insert(std::string name, std::string before=NULL)
Definition: selection.h:1432
#define D3_CALLBACK_METHOD_1_ARG(FUNC, ARG1)
Definition: utils.h:115
Selection & Rotate(int degrees)
Definition: selection.h:1497
DERIVED Select(std::string selector) const
Definition: selection.h:47
Selection & Interrupt(std::string name="")
Interrupt the transition with the name [name] on the current selection.
Definition: selection.h:1474
void ExitRemove()
Selection must have an exit selection (i.e. have just had data bound to it).
Definition: selection.h:1204
Selection Exit()
Definition: selection.h:1220
Selection Data(Dataset &values, std::string key="")
Definition: selection.h:1008
Selection Append(std::string name)
Append DOM element(s) of the type specified by [name] to this selection.
Definition: selection.h:1417
double GetStyleDouble(std::string name) const
Get the value of this object's [name] style when it's a double.
Definition: selection.h:474
Tools to maintain data in D3.
int GetID() const
Definition: d3_init.h:96
void pass_array_to_javascript(C values)
Definition: js_utils.h:212
int Size() const
Returns number of elements in this selection.
Definition: selection.h:534
~Selection()
Destructor.
Definition: selection.h:983
#define D3_CALLBACK_METHOD_CPP_FUNCTION_2_ARGS(FUNC, ARG1, CPP_FUN)
Definition: utils.h:120
Transition NewTransition(std::string name="") const
Definition: selection.h:571