{"id":263662,"date":"2015-08-17T00:50:02","date_gmt":"2015-08-16T20:50:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=263662"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=263662","title":{"rendered":"\u041a\u0430\u043a \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c jQuery \u043d\u0430 D3"},"content":{"rendered":"<p>       \u0421\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u043c\u044b \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044e \u0438\u0437 jQuery \u0438 D3. \u041f\u0440\u0438\u0447\u0451\u043c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f D3, \u0430 \u0438\u0437 jQuery \u0431\u0435\u0440\u0443\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0430\u0431\u043e\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u0441 DOM.<\/p>\n<p>  \u0418 \u0445\u043e\u0442\u044f \u0432 D3 \u0435\u0441\u0442\u044c \u043c\u043e\u0449\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u2013 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u044b \u0438 \u043e\u0431\u0451\u0440\u0442\u043a\u0430 \u0434\u043b\u044f ajax, \u0447\u0430\u0441\u0442\u043e \u043d\u0430\u043c \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u0437 jQuery. \u041c\u044b \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c jQuery, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f D3 \u043f\u043e\u0432\u0441\u0435\u043c\u0435\u0441\u0442\u043d\u043e. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0430\u0448 \u043a\u043e\u0434 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u0441\u044f, \u043e\u0431\u044a\u0451\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u0441\u044f, \u0438 \u0432\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u0442\u0435 \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u0430 \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0442\u0430\u043a, \u043a\u0430\u043a \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0432 D3.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0432 \u0447\u0451\u043c \u044d\u0442\u0438 \u0434\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0441\u0445\u043e\u0434\u044f\u0442\u0441\u044f. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u0442 jQuery, \u0438 \u0445\u043e\u0447\u0435\u0442 \u0438\u0437\u0443\u0447\u0438\u0442\u044c D3.<\/p>\n<h4>\u0421\u0445\u043e\u0436\u0435\u0441\u0442\u0438<\/h4>\n<p>  <\/p>\n<h5>\u0421\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u044b<\/h5>\n<p>  \u041e\u0431\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438, \u043d\u043e \u0431\u043e\u0433\u0430\u0442\u044b\u0445 \u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430\u0445. <\/p>\n<p>  jQuery<\/p>\n<pre><code class=\"javascript\">$('.foo').addClass('foobar'); $('.foo').removeClass('foobar'); <\/code><\/pre>\n<p>  D3<\/p>\n<pre><code class=\"javascript\">d3.selectAll('.foo').classed('foobar', true);   d3.selectAll('.foo').classed('foobar', false);  <\/code><\/pre>\n<h5>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0438\u043b\u044f\u043c\u0438 \u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438<\/h5>\n<p>  jQuery<\/p>\n<pre><code class=\"javascript\">$('.foo').attr('data-type', 'foobar'); $('.foo').css('background', '#F00'); <\/code><\/pre>\n<p>  D3<\/p>\n<pre><code class=\"javascript\">d3.selectAll('.foo').attr('data-type', 'foobar');   d3.selectAll('.foo').style('background', '#F00');   <\/code><\/pre>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<h5>Ajax<\/h5>\n<p>  \u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f, \u043d\u043e, \u043a\u0430\u043a \u0443 D3, \u0442\u0430\u043a \u0438 \u0443 jQuery \u0435\u0441\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u043e\u0431\u0451\u0440\u0442\u043a\u0438 \u0434\u043b\u044f <br \/>  ajax.<\/p>\n<p>  jQuery<\/p>\n<pre><code class=\"javascript\">$.getJSON('http:\/\/url-to-resource.json', doSomething); $.ajax({     url: 'http:\/\/url-to-resource.txt',     dataType: 'text',     type: 'GET',     success: doSomething }); <\/code><\/pre>\n<p>  D3<\/p>\n<pre><code class=\"javascript\">d3.json('http:\/\/url-to-resource.json', doSomething);   d3.text('http:\/\/url-to-resource.txt', doSomething);   <\/code><\/pre>\n<h5>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438<\/h5>\n<p>  \u0427\u0430\u0441\u0442\u043e \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 DOM, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441\u0442\u0438\u043b\u0438.<\/p>\n<p>  jQuery<\/p>\n<pre><code class=\"javascript\">$('.foo').addClass('foobar'); $('.foo').removeClass('foobar'); <\/code><\/pre>\n<p>  D3<\/p>\n<pre><code class=\"javascript\">d3.selectAll('.foo').classed('foobar', true);   d3.selectAll('.foo').classed('foobar', false);   <\/code><\/pre>\n<h5>Append \u0438 Prepend<\/h5>\n<p>  \u0412\u0441\u0442\u0430\u0432\u043a\u0430 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u0443\u0437\u043b\u043e\u0432 \u2013 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u0430\u0436\u043d\u0430\u044f, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u043b\u0435\u0433\u043a\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e:<\/p>\n<p>  jQuery<\/p>\n<pre><code class=\"javascript\">$('.foo').append('&lt;div\/&gt;'); $('.foo').prepend('&lt;div\/&gt;'); <\/code><\/pre>\n<p>  D3<\/p>\n<pre><code class=\"javascript\">d3.selectAll('.foo').append('div');   d3.selectAll('.foo').insert('div');   <\/code><\/pre>\n<h5>\u041e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0439<\/h5>\n<p>  \u041e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043d\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445.<\/p>\n<p>  jQuery<\/p>\n<pre><code class=\"javascript\">$('.foo').on('click', clickHandler); <\/code><\/pre>\n<p>  D3<\/p>\n<pre><code class=\"javascript\">d3.selectAll('.foo').on('click', clickHandler);   <\/code><\/pre>\n<h5>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/h5>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437 DOM. \u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f:<\/p>\n<p>  jQuery<\/p>\n<pre><code class=\"javascript\">$('.foo').remove(); <\/code><\/pre>\n<p>  D3<\/p>\n<pre><code class=\"javascript\">d3.selectAll('.foo').remove();   <\/code><\/pre>\n<h5>\u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432<\/h5>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437 \u0431\u043e\u043b\u0435\u0435 \u043a\u0440\u0443\u043f\u043d\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0438<\/p>\n<p>  jQuery<\/p>\n<pre><code class=\"javascript\">$('.foo').find('.bar'); <\/code><\/pre>\n<p>  D3<\/p>\n<pre><code class=\"javascript\">d3.selectAll('.foo').selectAll('.bar');   <\/code><\/pre>\n<h5>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c<\/h5>\n<p>  \u0414\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0443\u0437\u043b\u0430 DOM \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>  jQuery<\/p>\n<pre><code class=\"javascript\">$('.foo').text('Hello World!'); $('.foo').html('&lt;div class=&quot;bar&quot;&gt;Hello&lt;\/div&gt;'); <\/code><\/pre>\n<p>  D3<\/p>\n<pre><code class=\"javascript\">d3.selectAll('.foo').text('Hello World!');   d3.selectAll('.foo').html('&lt;div class=&quot;bar&quot;&gt;Hello&lt;\/div&gt;');   <\/code><\/pre>\n<h4>\u0420\u0430\u0437\u043b\u0438\u0447\u0438\u044f<\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0432 jQuery, \u043d\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 D3. \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u0435\u0451 \u0437\u0430\u043c\u0435\u043d\u0443, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0431\u0449\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432\u0430\u043c \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u0432\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0439 \u0444\u0438\u0440\u043c\u0435\u043d\u043d\u044b\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 D3.<\/p>\n<h5>\u0410\u043a\u0442\u0438\u0432\u0430\u0446\u0438\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438 \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f (trigger events and custom events)<\/h5>\n<p>  \u041e\u0434\u043d\u043e \u0438\u0437 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432 jQuery \u2013 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c\u0438. \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0438\u043b\u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u043e\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0441 \u043d\u0435\u043a\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430, \u0438 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043a\u043e\u0434\u0435:<\/p>\n<pre><code class=\"javascript\">\/\/\u0441\u043b\u0443\u0448\u0430\u0435\u043c $(document).on('dataChange', function(evt, data) {     \/\/do something with evt and data     console.log(data.newData); });  \/\/\u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 $(document).trigger('dataChange', {     newData: 'Hello World!' }); <\/code><\/pre>\n<p>  \u0412 D3 \u044d\u0442\u043e \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u043d\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f. \u041f\u0440\u043e\u0441\u0442\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 (\u0435\u0441\u043b\u0438 \u0432 \u0445\u044d\u043d\u0434\u043b\u0435\u0440\u0435 \u0432\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u043d\u043e d3.event):<\/p>\n<pre><code class=\"javascript\">\/\/\u0441\u043b\u0443\u0448\u0430\u0435\u043c d3.select(document).on('dataChange', function(data) {       console.log(d3.event); \/\/null     console.log(data.newData); });  \/\/\u0432\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0435 d3.select(document).on('dataChange')({       newData: 'Hello World!' }); <\/code><\/pre>\n<p>  \u0411\u043e\u043b\u0435\u0435 \u043e\u0431\u0449\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u2013 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 d3, \u0447\u0442\u043e\u0431\u044b \u0435\u0451 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435.<\/p>\n<pre><code class=\"javascript\">d3.selection.prototype.trigger = function(evtName, data) {     this.on(evtName)(data); } <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 D3 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0432\u0430\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e-\u0442\u0440\u0438\u0433\u0433\u0435\u0440, \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0449\u0443\u044e \u0442\u0430\u043a\u043e\u0432\u0443\u044e \u0432 jQuery, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">d3.select(document).on('dataChange', function(data) {     console.log(data); }); <\/code><\/pre>\n<p>  d3.select(document).trigger(&#8216;dataChange&#8217;, {newData: &#8216;HelloWorld!&#8217;}); <\/p>\n<h5>after() \u0438 before()<\/h5>\n<p>  \u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 jQuery \u043c\u043e\u0436\u043d\u043e \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u044b\u0431\u043e\u0440\u043a\u0438. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u043e\u0434:<\/p>\n<pre><code class=\"html\">&lt;ul&gt;       &lt;li&gt;List&lt;\/li&gt;     &lt;li&gt;List&lt;\/li&gt;     &lt;li&gt;List&lt;\/li&gt; &lt;\/ul&gt;   <\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0432\u0441\u0442\u0430\u0432\u043a\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u043e\u0441\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0441\u043f\u0438\u0441\u043a\u0430:<\/p>\n<pre><code class=\"javascript\">$('li').after('&lt;li&gt;Item&lt;\/li&gt;'); <\/code><\/pre>\n<p>  \u0418 \u0432\u043e\u0442 \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c:<\/p>\n<pre><code class=\"html\">&lt;ul&gt;       &lt;li&gt;List&lt;\/li&gt;     &lt;li&gt;Item&lt;\/li&gt;     &lt;li&gt;List&lt;\/li&gt;     &lt;li&gt;Item&lt;\/li&gt;     &lt;li&gt;List&lt;\/li&gt;     &lt;li&gt;Item&lt;\/li&gt; &lt;\/ul&gt;   <\/code><\/pre>\n<p>  \u0412 D3 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u0432\u0441\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 JavaScript:<\/p>\n<pre><code class=\"javascript\">d3.selectAll('li').each(function() {     var li = document.createElement('li');   li.textContent = 'Item';   this.parentNode.insertBefore(li, this.nextSibling); }) <\/code><\/pre>\n<p>  \u041b\u0443\u0447\u0448\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u2013 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u0431\u0449\u0435\u0433\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0449\u0443\u044e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043c\u0435\u043d\u0438 \u0442\u044d\u0433\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0443\u044e \u043d\u043e\u0432\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0438\u0437 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0442\u0435\u043c \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c:<\/p>\n<pre><code class=\"javascript\">d3.selection.prototype.after = function(tagName) {     var elements = [];    this.each(function() {     var element = document.createElement(tagName);     this.parentNode.insertBefore(element, this.nextSibling);     elements.push(element);   });    return d3.selectAll(elements); } <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0432 \u0432\u0430\u0448 \u043a\u043e\u0434, \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e after() \u043f\u043e\u0447\u0442\u0438 \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432 jQuery:<\/p>\n<pre><code class=\"javascript\">d3.selectAll('li')       .after('li')     .text('Item')     \/\/\u0442\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043e \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0435\u0449\u0451 <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f before() \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u043e\u0447\u0442\u0438 \u0442\u0430\u043a\u0436\u0435, \u0441 \u0442\u043e\u0439 \u043b\u0438\u0448\u044c \u0440\u0430\u0437\u043d\u0438\u0446\u0435\u0439, \u0447\u0442\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0434\u043e \u0432\u044b\u0431\u043e\u0440\u043a\u0438.<\/p>\n<pre><code class=\"javascript\">d3.selection.prototype.before = function(tagName) {     var elements = [];    this.each(function() {     var element = document.createElement(tagName);     this.parentNode.insertBefore(element, this);     elements.push(element);   });    return d3.selectAll(elements); } <\/code><\/pre>\n<h5>empty()<\/h5>\n<p>  \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u0444\u0443\u043d\u043a\u0446\u0438\u044f jQuery \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0432\u0441\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0443\u0437\u043b\u044b \u0432 \u0432\u044b\u0431\u043e\u0440\u043a\u0435.<\/p>\n<ul>\n<li>List-Item<\/li>\n<li>List-Item<\/li>\n<li>List-Item<\/li>\n<\/ul>\n<pre><code class=\"javascript\">$('ul').empty(); <\/code><\/pre>\n<p>  \u0418 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435:<\/p>\n<pre><code class=\"html\">&lt;ul&gt;&lt;\/ul&gt;   <\/code><\/pre>\n<p>  \u0412 D3 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0439 HTML \u0443 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430:<\/p>\n<pre><code class=\"javascript\">d3.selectAll('ul').html('');   <\/code><\/pre>\n<p>  D3 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 SVG. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0442\u0430\u043a\u043e\u0439 \u043a\u043e\u0434 \u043d\u0435 \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0442\u0430\u043c \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044f innerHTML. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c html(), \u0430 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0443\u0437\u043b\u044b \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0438\u0445:<\/p>\n<pre><code class=\"javascript\">d3.selectAll('ul').selectAll('*').remove();   <\/code><\/pre>\n<p>  \u041a\u043e\u0434 \u043e\u0431\u0449\u0435\u0433\u043e \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439. \u042f \u0432\u044b\u0431\u0440\u0430\u043b \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u0440\u0443\u0433\u043e\u0435 \u0438\u043c\u044f, \u043d\u0435\u0436\u0435\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0435 \u0432 jQuery, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 D3 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f empty().<\/p>\n<pre><code class=\"javascript\">d3.selection.prototype.clear = function() {     this.selectAll('*').remove();   return this; } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043e\u0447\u0438\u0449\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u043f\u043e\u0447\u0442\u0438 \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0432 jQuery:<\/p>\n<pre><code class=\"javascript\">d3.selectAll('#foo').clear();   <\/code><\/pre>\n<h5>appendTo()<\/h5>\n<p>  \u0412 jQuery \u044d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0447\u0442\u0438 \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f append() \u0432 D3, \u043d\u043e \u043e\u043d\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443. \u0427\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0432 D3, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0439\u0442\u0438 \u043f\u043e \u0432\u0441\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0432 \u043e\u0431\u043e\u0438\u0445 \u0432\u044b\u0431\u043e\u0440\u043a\u0430\u0445 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u0440\u0443\u0433 \u043a \u0434\u0440\u0443\u0433\u0443. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0446\u0435\u043b\u0435\u0439, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0443, \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0441\u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435, \u0441\u0445\u043e\u0436\u0435\u0435 \u0441 jQuery. \u0412\u043e\u0442 \u0447\u0442\u043e \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c:<\/p>\n<pre><code class=\"javascript\">d3.selection.prototype.appendTo = function(selector) {     var targets = d3.selectAll(selector),       targetCount = targets[0].length,       _this = this,       clones = [];    targets.each(function() {     var currTarget = this;     _this.each(function() {       if(targetCount &gt; 1) {         var clone = this.cloneNode(true);         currTarget.appendChild(clone);         clones.push(clone);       }       else {         currTarget.appendChild(this);       }     });   });    if(targetCount &gt; 1) {     this.remove();   }    return clones.length &gt; 0 ? d3.selectAll(clones) : this; } <\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0435\u0451, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0432 DOM. \u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<pre><code class=\"html\">&lt;div class=&quot;target&quot;&gt;&lt;\/div&gt;   &lt;div class=&quot;target&quot;&gt;&lt;\/div&gt;  &lt;div class=&quot;foo&quot;&gt;some element&lt;\/div&gt;   &lt;div class=&quot;foo&quot;&gt;some other element&lt;\/div&gt;   <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c appendTo() \u043d\u0430 \u0432\u0441\u0435\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0445, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u00abfoo\u00bb, \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0438\u0445 \u043a \u0446\u0435\u043b\u044f\u043c.<\/p>\n<pre><code class=\"javascript\">d3.selectAll('.foo').appendTo('.target');   <\/code><\/pre>\n<p>  \u0427\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432 DOM:<\/p>\n<pre><code class=\"html\">&lt;div class=&quot;target&quot;&gt;       &lt;div class=&quot;foo&quot;&gt;some element&lt;\/div&gt;     &lt;div class=&quot;foo&quot;&gt;some other element&lt;\/div&gt; &lt;\/div&gt;  &lt;div class=&quot;target&quot;&gt;       &lt;div class=&quot;foo&quot;&gt;some element&lt;\/div&gt;     &lt;div class=&quot;foo&quot;&gt;some other element&lt;\/div&gt; &lt;\/div&gt;   <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u0447\u0442\u043e\u0431\u044b \u0441 \u043d\u0438\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0434\u0430\u043b\u0435\u0435. \u041a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0444\u043e\u043d\u0430:<\/p>\n<p>  d3.selectAll(&#8216;.foo&#8217;).appendTo(&#8216;.target&#8217;).style(&#8216;background&#8217;, &#8216;#f00&#8217;); <\/p>\n<h5>length()<\/h5>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u0437\u043d\u0430\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0435\u0441\u0442\u044c \u0432 \u0432\u0430\u0448\u0435\u0439 \u0432\u044b\u0431\u043e\u0440\u043a\u0435. \u0432 jQuery \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u043e \u0438\u043c\u0435\u043d\u0438 length  <\/p>\n<pre><code class=\"html\"> &lt;div class=&quot;.foo&quot;&gt;&lt;\/div&gt;   &lt;div class=&quot;.foo&quot;&gt;&lt;\/div&gt;   <\/code><\/pre>\n<pre><code class=\"javascript\">$('.foo').length; \/\/2 <\/code><\/pre>\n<p>  \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u2013 \u0432 D3:<\/p>\n<pre><code class=\"javascript\">d3.selection.prototype.length = function() {     return this[0].length; } <\/code><\/pre>\n<p>  \u0421 \u0442\u0430\u043a\u0438\u043c \u043a\u043e\u0434\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"javascript\">d3.selectAll('.foo').length() \/\/2   <\/code><\/pre>\n<h5>toggleClass()<\/h5>\n<p>  \u041a\u0430\u043a \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c, \u0432 D3 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e classed, \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432. \u041d\u043e \u0432 D3 \u043d\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438\u043c\u0451\u043d \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0447\u0430\u0441\u0442\u0435\u043d\u044c\u043a\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432 jQuery. \u0415\u0451 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code class=\"javascript\">d3.selection.prototype.toggleClass = function(className) {         this.classed(className, !this.classed(className));       return this; } <\/code><\/pre>\n<h5>eq()<\/h5>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0437\u0435\u043b \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c, \u0432 jQuery \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044e eq(). \u0415\u0451 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0434\u043b\u044f D3. \u0414\u0435\u043b\u0430\u0435\u043c \u043f\u043e\u0434\u0432\u044b\u0431\u043e\u0440\u043a\u0443 \u0438\u0437 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0437\u0430\u043d\u043e\u0432\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043d\u0443\u044e \u0432\u044b\u0431\u043e\u0440\u043a\u0443:<\/p>\n<pre><code class=\"javascript\">d3.selection.prototype.eq = function(index) {     return d3.select(this[0][index]); } <\/code><\/pre>\n<h5>show() \/ hide() \/ toggle()<\/h5>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435. \u041e\u043d\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0435\u043d\u044f\u044e\u0442 \u0441\u0442\u0438\u043b\u0438 \u0443 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0410 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 toggle() \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0432\u0438\u0434\u0435\u043d \u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<p>  \u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043a\u0440\u044b\u0442\u044b\u0439:<\/p>\n<pre><code class=\"javascript\">d3.selection.prototype.show = function() {     this.style('display', 'initial');   return this; } <\/code><\/pre>\n<p>  \u0421\u043f\u0440\u044f\u0442\u0430\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u044b\u0439:<\/p>\n<pre><code class=\"javascript\">d3.selection.prototype.hide = function() {     this.style('display', 'none');   return this; } <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c:<\/p>\n<pre><code class=\"javascript\">d3.selection.prototype.toggle = function() {     var isHidden = this.style('display') == 'none';   return this.style('display', isHidden ? 'inherit' : 'none'); } <\/code><\/pre>\n<h5>moveToFront(), moveToBack()<\/h5>\n<p>  \u042d\u0442\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0447\u0430\u0441\u0442\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0432 D3, \u043d\u043e \u0441 jQuery \u043e\u043d\u0438 \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u044b. D3 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 SVG. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 HTML, \u0432 SVG \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0438\u0445 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0447\u0430\u0441\u0442\u043e \u043d\u0430\u043c \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0432 SVG \u043d\u0430\u0437\u0430\u0434 \u0438\u043b\u0438 \u0432\u043f\u0435\u0440\u0451\u0434.<\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0438\u043c \u0432\u044b\u0431\u043e\u0440\u043a\u0438 D3 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438:<\/p>\n<pre><code class=\"javascript\">d3.selection.prototype.moveToFront = function() {     return this.each(function(){     this.parentNode.appendChild(this);   }); };  d3.selection.prototype.moveToBack = function() {       return this.each(function() {          var firstChild = this.parentNode.firstChild;          if (firstChild) {              this.parentNode.insertBefore(this, firstChild);          }      }); }; <\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u043a\u0440\u0430\u0439\u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u2013 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 svg \u0438 \u0434\u0432\u0438\u0433\u0430\u0435\u043c \u0435\u0433\u043e, \u043a\u0443\u0434\u0430 \u043d\u0443\u0436\u043d\u043e:<\/p>\n<pre><code class=\"javascript\">d3.select('svg rect')       .moveToFront()     .moveToBack(); <\/code><\/pre>\n<p>  \u041d\u0430\u0434\u0435\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u0432 \u0442\u0435\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0438\u0437\u043b\u0438\u0448\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 jQuery \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u043c\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f\u043c\u0438 \u043d\u0430 D3. \u0410 \u0443\u0436\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e D3 \u0441 \u0432\u043a\u043b\u044e\u0447\u0451\u043d\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043d\u0430 GitHub.   \t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/264861\/\"> http:\/\/habrahabr.ru\/post\/264861\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0421\u043e\u0437\u0434\u0430\u0432\u0430\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u043c\u044b \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044e \u0438\u0437 jQuery \u0438 D3. \u041f\u0440\u0438\u0447\u0451\u043c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f D3, \u0430 \u0438\u0437 jQuery \u0431\u0435\u0440\u0443\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043d\u0430\u0431\u043e\u0440 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0439 \u0441 DOM.<\/p>\n<p>  \u0418 \u0445\u043e\u0442\u044f \u0432 D3 \u0435\u0441\u0442\u044c \u043c\u043e\u0449\u043d\u044b\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u2013 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u044b \u0438 \u043e\u0431\u0451\u0440\u0442\u043a\u0430 \u0434\u043b\u044f ajax, \u0447\u0430\u0441\u0442\u043e \u043d\u0430\u043c \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438\u0437 jQuery. \u041c\u044b \u043f\u043e\u043a\u0430\u0436\u0435\u043c, \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c jQuery, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f D3 \u043f\u043e\u0432\u0441\u0435\u043c\u0435\u0441\u0442\u043d\u043e. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432\u0430\u0448 \u043a\u043e\u0434 \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u0441\u044f, \u043e\u0431\u044a\u0451\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u0441\u044f, \u0438 \u0432\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u0442\u0435 \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b, \u0430 \u0431\u0443\u0434\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0442\u0430\u043a, \u043a\u0430\u043a \u043f\u0440\u0438\u043d\u044f\u0442\u043e \u0432 D3.<\/p>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u0432 \u0447\u0451\u043c \u044d\u0442\u0438 \u0434\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0441\u0445\u043e\u0434\u044f\u0442\u0441\u044f. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0443\u0436\u0435 \u0437\u043d\u0430\u0435\u0442 jQuery, \u0438 \u0445\u043e\u0447\u0435\u0442 \u0438\u0437\u0443\u0447\u0438\u0442\u044c D3.<\/p>\n<h4>\u0421\u0445\u043e\u0436\u0435\u0441\u0442\u0438<\/h4>\n<p>  <\/p>\n<h5>\u0421\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u044b<\/h5>\n<p>  \u041e\u0431\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u044b \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438, \u043d\u043e \u0431\u043e\u0433\u0430\u0442\u044b\u0445 \u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0435\u043b\u0435\u043a\u0442\u043e\u0440\u0430\u0445. <\/p>\n<p>  jQuery<\/p>\n<pre><code class=\"javascript\">$('.foo').addClass('foobar'); $('.foo').removeClass('foobar'); <\/code><\/pre>\n<p>  D3<\/p>\n<pre><code class=\"javascript\">d3.selectAll('.foo').classed('foobar', true);   d3.selectAll('.foo').classed('foobar', false);  <\/code><\/pre>\n<h5>\u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0442\u0438\u043b\u044f\u043c\u0438 \u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c\u0438<\/h5>\n<p>  jQuery<\/p>\n<pre><code class=\"javascript\">$('.foo').attr('data-type', 'foobar'); $('.foo').css('background', '#F00'); <\/code><\/pre>\n<p>  D3<\/p>\n<pre><code class=\"javascript\">d3.selectAll('.foo').attr('data-type', 'foobar');   d3.selectAll('.foo').style('background', '#F00');   <\/code><\/pre>\n<p>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-263662","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/263662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=263662"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/263662\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=263662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=263662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=263662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}