SlideShare uma empresa Scribd logo
1 de 41
Baixar para ler offline
Welcome!
“Networking”
There is a “networking table” near
the entrance to the lecture room,
where you can put your business
cards and prospects :-)
KAROL
DEPKA
– Woody Allen
“80% percent of success
is showing up.”
About the presentation
• As interactive as possible
• Questions welcome
• Feel free to interrupt at any time
• We can spend as much time as you want, on any slide
• I assume that the most active audience members are the most
interested and therefor should be able to control the
presentation flow
KAROL
DEPKA
A little poll
• On SVG:
• who has used SVG?
• who considers themselves proficient with SVG?
• who has plans to learn / use SVG?
• On D3
• who has used D3?
• who considers themselves proficient with D3?
• who has plans to learn / use D3?
H
ands
up
please!
KAROL
DEPKA
D3.js
DATA
DRIVEN
DOCUMENTS
KAROL
DEPKA
Data-to-Documents
DATA DOCUMENT
SVG
SCALABLE
VECTOR
GRAPHICS
KAROL
DEPKA
Why should you care about
D3 and why is it better?
• Interactive, unlike static images
• Open-source
• Good merits and Eye-candy
• Super flexible
KAROL
DEPKA
Why should you care about
SVG and why is it better?
• Web standard (unlike Flash)
• Runs in the browser without a plugin
(unlike Flash)
• Scales well
KAROL
DEPKA
Scaling & Resolutions
KAROL
DEPKA
Zoom in
The final product that we want to achieve
KAROL
DEPKA
The features that we want to achieve
• Physics-based automatic layout
• Drag-and-drop
• Automatic layout
• Zoom
• Pan
• Mouse-over highlight
KAROL
DEPKA
Our example is on GitHub
https://github.com/karol-depka/D3SVGTechnologyGraph
KAROL
DEPKA
https://bl.ocks.org/mbostock/4062045
Force layout
KAROL
DEPKA
D3 modules visualized in D3 :-D
KAROL
DEPKA
http://bl.ocks.org/alisd23/5762cc5912253c4febeb
Animated SVG
How do I animate SVG?
KAROL
DEPKA
Declaring nodes
// …
JavaScript: {

id: JavaScript,

body: "viewBox="0 0 256 256" v
"<path d="M67.311746,21
"</svg>n",

sizeMult: 1.2

},
KAROL
DEPKA
Declaring nodes, part 2
Inkscape: {id: Inkscape},

Illustrator: {id: Illustrator},

AffinityDesigner: {id: AffinityDesigner,
html: "Affinity<br/>Designer"},

// …
var nodesWebOnly = [

nodes.SVG,

// …

nodes.NodeJS,

nodes.JavaScript,

];
KAROL
DEPKA
Declaring links between nodes
var linksWebOnly = [

{source: HTML5, target: Angular2},

{source: Ionic, target: Angular2},

{source: HTML5, target: Angular2},

{source: D3, target: SVG},

{source: JavaScript, target: HTML5},

{source: JavaScript, target: TypeScript},

{source: JavaScript, target: jQuery},
// …

{source: Angular2, target: TypeScript},

{source: jQuery, target: HTML5},

{source: HTML5, target: CSS, thick: 10},

{source: SVG, target: HTML5, thick: 10,
distance: 1.5},

];
Setting up the D3 force
simulation
/* Base Example:
Force-Directed Graph:
https://bl.ocks.org/mbostock/4062045 */


var simulation = d3.forceSimulation()

// .force("gravity", 3)

.force("link",

d3.forceLink().id(function(d) { return d.id; })

.strength(function(d) {

return 3;

}))

.force("charge", d3.forceManyBody().strength(-1000))

.force("center", d3.forceCenter(width / 2, height / 2));

KAROL
DEPKA
Where to handle mouse events
Layer for drag&drop
and mouse-over
KAROL
DEPKA
Add drag&drop
https://github.com/d3/d3-drag
KAROL
DEPKA
Add drag&drop
function dragStarted(d) {

isDragging = true;

if (!d3.event.active) {

simulation.alphaTarget(0.3).restart();

}

d.fx = d.x;

d.fy = d.y;

}



function dragged(d) {

isDragging = true;

d.fx = d3.event.x;

d.fy = d3.event.y;

}



function dragEnded(d) {

isDragging = false;

unHighlightHover()



if (!d3.event.active) {

simulation.alphaTarget(0);

}

d.fx = null;

d.fy = null;

}
Add drag&drop
nodeCircleOverlay.call(

d3.drag()

.on("start", dragStarted)

.on("drag", dragged)

.on("end", dragEnded));
KAROL
DEPKA
Add SVG icons
perNodeMainGroup.append("g").html(function(d) {

var bodyText = d.body || "";

var size = d.sizeMult ? d.sizeMult * defaultSize

: defaultSize;



if (bodyText.trim().endsWith("</svg>")) {

const htmlContent = '<svg '

+ 'width="' + size + 'px" '

+ 'height="' + size + 'px" '

+ 'x="' + (-size/2) + '" '

+ 'y="' + (-size/2) + '" '

+ bodyText /* also contains </svg> */;

return htmlContent;

} else {

return "";

}

});
Add HTML foreignObject
perNodeMainGroup.append("foreignObject")

.attr("style", "pointer-events:none;")

.attr("width", foreignObjectW)

.attr("height", foreignObjectH)

.attr("height", foreignObjectH)

.attr("x", -foreignObjectW/2)

.attr("y", -foreignObjectH/2)

.style("font", "9px 'Helvetica Neue'")

.html(function(d) {

if ( d.body ) {

return ""; // has icon: no need for text

}

var bodyText = d.html || d.id;

return "<div style='display: table;" +

"text-align:center;" +

"height:100%; width:100%'>" +

"<p style='display: table-cell; " +

"vertical-align: middle'>" +

bodyText + "</p></div>";

});
ticked() function
function ticked() {

link

.attr("x1", function(d) { return d.source.x; })

.attr("y1", function(d) { return d.source.y; })

.attr("x2", function(d) { return d.target.x; })

.attr("y2", function(d) { return d.target.y; });



nodeG1.attr("transform", function(d) {

return "translate(" + d.x + "," + d.y + ")";

});

}
KAROL
DEPKA
Tested on browsers
• Chrome
• Firefox
• Safari
• Opera
• Edge
• Internet Explorer
Browsers, Browsers,
Browsers!
• Who here uses IE as their main browser?
• Who here uses IE as their main browser and is not
afraid to admit it?
• Who here uses Microsoft Edge as their main
browser?
H
ands
up
please!
https://github.com/eisman/neo4jd3
KAROL
DEPKA
Cool D3 Examples
https://bl.ocks.org/mbostock/
2990a882e007f8384b04827617752738
Cool D3 Examples
• http://bl.ocks.org/rkirsling/5001347 - directed graph
editor
KAROL
DEPKA
Gallery of
D3
Examples
URL:
Alternatives to SVG
• Font Awesome (only monochrome?)
• Canvas? (not scalable?)
• Adobe Flash? ;-)
• PDF
KAROL
DEPKA
A little poll - after the
presentation
• On SVG:
• who has plans to learn / use SVG?
• On D3
• who has plans to learn / use D3?
H
ands
up
please!
KAROL
DEPKA
Q
und
A
THANKS TO
Ewa, Rafa
Antonio, Guillermo, Abigail
Ania, Greg

Mais conteúdo relacionado

Mais procurados

Write Less Do More
Write Less Do MoreWrite Less Do More
Write Less Do MoreRemy Sharp
 
jQuery Fundamentals
jQuery FundamentalsjQuery Fundamentals
jQuery FundamentalsGil Fink
 
jQuery Presentation
jQuery PresentationjQuery Presentation
jQuery PresentationRod Johnson
 
jQuery Loves Developers - Oredev 2009
jQuery Loves Developers - Oredev 2009jQuery Loves Developers - Oredev 2009
jQuery Loves Developers - Oredev 2009Remy Sharp
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutesSimon Willison
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginningAnis Ahmad
 
JavaScript and jQuery Basics
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery BasicsKaloyan Kosev
 
Unobtrusive javascript with jQuery
Unobtrusive javascript with jQueryUnobtrusive javascript with jQuery
Unobtrusive javascript with jQueryAngel Ruiz
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoiddmethvin
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsEPAM Systems
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery EssentialsMark Rackley
 
J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012ghnash
 
Learning jQuery made exciting in an interactive session by one of our team me...
Learning jQuery made exciting in an interactive session by one of our team me...Learning jQuery made exciting in an interactive session by one of our team me...
Learning jQuery made exciting in an interactive session by one of our team me...Thinqloud
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practicesmanugoel2003
 

Mais procurados (20)

Write Less Do More
Write Less Do MoreWrite Less Do More
Write Less Do More
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
jQuery Fundamentals
jQuery FundamentalsjQuery Fundamentals
jQuery Fundamentals
 
jQuery Presentation
jQuery PresentationjQuery Presentation
jQuery Presentation
 
jQuery Loves Developers - Oredev 2009
jQuery Loves Developers - Oredev 2009jQuery Loves Developers - Oredev 2009
jQuery Loves Developers - Oredev 2009
 
Learning jQuery in 30 minutes
Learning jQuery in 30 minutesLearning jQuery in 30 minutes
Learning jQuery in 30 minutes
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 
jQuery
jQueryjQuery
jQuery
 
jQuery Essentials
jQuery EssentialsjQuery Essentials
jQuery Essentials
 
jQuery from the very beginning
jQuery from the very beginningjQuery from the very beginning
jQuery from the very beginning
 
JavaScript and jQuery Basics
JavaScript and jQuery BasicsJavaScript and jQuery Basics
JavaScript and jQuery Basics
 
jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
 
Unobtrusive javascript with jQuery
Unobtrusive javascript with jQueryUnobtrusive javascript with jQuery
Unobtrusive javascript with jQuery
 
jQuery Features to Avoid
jQuery Features to AvoidjQuery Features to Avoid
jQuery Features to Avoid
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript Basics
 
jQuery
jQueryjQuery
jQuery
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery Essentials
 
J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012J query b_dotnet_ug_meet_12_may_2012
J query b_dotnet_ug_meet_12_may_2012
 
Learning jQuery made exciting in an interactive session by one of our team me...
Learning jQuery made exciting in an interactive session by one of our team me...Learning jQuery made exciting in an interactive session by one of our team me...
Learning jQuery made exciting in an interactive session by one of our team me...
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 

Semelhante a D3.js and SVG

Accessibility Hacks Version 2
Accessibility Hacks Version 2Accessibility Hacks Version 2
Accessibility Hacks Version 2Graham Armfield
 
Accessibility Hacks version 2
Accessibility Hacks version 2Accessibility Hacks version 2
Accessibility Hacks version 2Graham Armfield
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)Oswald Campesato
 
Accessibility Hacks Wordcamp Manchester October 2018
Accessibility Hacks Wordcamp Manchester October 2018Accessibility Hacks Wordcamp Manchester October 2018
Accessibility Hacks Wordcamp Manchester October 2018Graham Armfield
 
Sara Soueidan: Styling and Animating Scalable Vector Graphics with CSS [CSSCo...
Sara Soueidan: Styling and Animating Scalable Vector Graphics with CSS [CSSCo...Sara Soueidan: Styling and Animating Scalable Vector Graphics with CSS [CSSCo...
Sara Soueidan: Styling and Animating Scalable Vector Graphics with CSS [CSSCo...Guillaume Kossi
 
Thats Not Flash?
Thats Not Flash?Thats Not Flash?
Thats Not Flash?Mike Wilcox
 
Илья Пухальский (EPAM Systems)
Илья Пухальский (EPAM Systems)Илья Пухальский (EPAM Systems)
Илья Пухальский (EPAM Systems)Ontico
 
HTML5 and SVG
HTML5 and SVGHTML5 and SVG
HTML5 and SVGyarcub
 
Transforming public data into thematic maps (TDC2019 presentation)
Transforming public data into thematic maps (TDC2019 presentation)Transforming public data into thematic maps (TDC2019 presentation)
Transforming public data into thematic maps (TDC2019 presentation)Helder da Rocha
 
Make your own Print & Play card game using SVG and JavaScript
Make your own Print & Play card game using SVG and JavaScriptMake your own Print & Play card game using SVG and JavaScript
Make your own Print & Play card game using SVG and JavaScriptKevin Hakanson
 
JavaONE 2012 Using Java with HTML5 and CSS3
JavaONE 2012 Using Java with HTML5 and CSS3JavaONE 2012 Using Java with HTML5 and CSS3
JavaONE 2012 Using Java with HTML5 and CSS3Helder da Rocha
 
Professional reports with SVG
Professional reports with SVGProfessional reports with SVG
Professional reports with SVGSpeedPartner GmbH
 
Implementing Awesome: An HTML5/CSS3 Workshop
Implementing Awesome: An HTML5/CSS3 WorkshopImplementing Awesome: An HTML5/CSS3 Workshop
Implementing Awesome: An HTML5/CSS3 WorkshopShoshi Roberts
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSNaga Harish M
 
Top 10 HTML5 features
Top 10 HTML5 featuresTop 10 HTML5 features
Top 10 HTML5 featuresGill Cleeren
 

Semelhante a D3.js and SVG (20)

Accessibility Hacks Version 2
Accessibility Hacks Version 2Accessibility Hacks Version 2
Accessibility Hacks Version 2
 
Accessibility Hacks version 2
Accessibility Hacks version 2Accessibility Hacks version 2
Accessibility Hacks version 2
 
Svcc 2013-d3
Svcc 2013-d3Svcc 2013-d3
Svcc 2013-d3
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)
 
Accessibility Hacks Wordcamp Manchester October 2018
Accessibility Hacks Wordcamp Manchester October 2018Accessibility Hacks Wordcamp Manchester October 2018
Accessibility Hacks Wordcamp Manchester October 2018
 
Sara Soueidan: Styling and Animating Scalable Vector Graphics with CSS [CSSCo...
Sara Soueidan: Styling and Animating Scalable Vector Graphics with CSS [CSSCo...Sara Soueidan: Styling and Animating Scalable Vector Graphics with CSS [CSSCo...
Sara Soueidan: Styling and Animating Scalable Vector Graphics with CSS [CSSCo...
 
Thats Not Flash?
Thats Not Flash?Thats Not Flash?
Thats Not Flash?
 
HTML5 - A Whirlwind tour
HTML5 - A Whirlwind tourHTML5 - A Whirlwind tour
HTML5 - A Whirlwind tour
 
Html5 more than just html5 v final
Html5  more than just html5 v finalHtml5  more than just html5 v final
Html5 more than just html5 v final
 
Илья Пухальский (EPAM Systems)
Илья Пухальский (EPAM Systems)Илья Пухальский (EPAM Systems)
Илья Пухальский (EPAM Systems)
 
SVGD3Angular2React
SVGD3Angular2ReactSVGD3Angular2React
SVGD3Angular2React
 
HTML5 and SVG
HTML5 and SVGHTML5 and SVG
HTML5 and SVG
 
Transforming public data into thematic maps (TDC2019 presentation)
Transforming public data into thematic maps (TDC2019 presentation)Transforming public data into thematic maps (TDC2019 presentation)
Transforming public data into thematic maps (TDC2019 presentation)
 
Make your own Print & Play card game using SVG and JavaScript
Make your own Print & Play card game using SVG and JavaScriptMake your own Print & Play card game using SVG and JavaScript
Make your own Print & Play card game using SVG and JavaScript
 
JavaONE 2012 Using Java with HTML5 and CSS3
JavaONE 2012 Using Java with HTML5 and CSS3JavaONE 2012 Using Java with HTML5 and CSS3
JavaONE 2012 Using Java with HTML5 and CSS3
 
Professional reports with SVG
Professional reports with SVGProfessional reports with SVG
Professional reports with SVG
 
Implementing Awesome: An HTML5/CSS3 Workshop
Implementing Awesome: An HTML5/CSS3 WorkshopImplementing Awesome: An HTML5/CSS3 Workshop
Implementing Awesome: An HTML5/CSS3 Workshop
 
About Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JSAbout Best friends - HTML, CSS and JS
About Best friends - HTML, CSS and JS
 
Top 10 HTML5 features
Top 10 HTML5 featuresTop 10 HTML5 features
Top 10 HTML5 features
 
Next generation Graphics: SVG
Next generation Graphics: SVGNext generation Graphics: SVG
Next generation Graphics: SVG
 

Último

Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 

Último (20)

Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 

D3.js and SVG

  • 2. “Networking” There is a “networking table” near the entrance to the lecture room, where you can put your business cards and prospects :-) KAROL DEPKA
  • 3.
  • 4. – Woody Allen “80% percent of success is showing up.”
  • 5. About the presentation • As interactive as possible • Questions welcome • Feel free to interrupt at any time • We can spend as much time as you want, on any slide • I assume that the most active audience members are the most interested and therefor should be able to control the presentation flow KAROL DEPKA
  • 6. A little poll • On SVG: • who has used SVG? • who considers themselves proficient with SVG? • who has plans to learn / use SVG? • On D3 • who has used D3? • who considers themselves proficient with D3? • who has plans to learn / use D3? H ands up please! KAROL DEPKA
  • 10. Why should you care about D3 and why is it better? • Interactive, unlike static images • Open-source • Good merits and Eye-candy • Super flexible KAROL DEPKA
  • 11. Why should you care about SVG and why is it better? • Web standard (unlike Flash) • Runs in the browser without a plugin (unlike Flash) • Scales well KAROL DEPKA
  • 14. The final product that we want to achieve KAROL DEPKA
  • 15. The features that we want to achieve • Physics-based automatic layout • Drag-and-drop • Automatic layout • Zoom • Pan • Mouse-over highlight KAROL DEPKA
  • 16. Our example is on GitHub https://github.com/karol-depka/D3SVGTechnologyGraph KAROL DEPKA
  • 18. D3 modules visualized in D3 :-D KAROL DEPKA http://bl.ocks.org/alisd23/5762cc5912253c4febeb
  • 19. Animated SVG How do I animate SVG? KAROL DEPKA
  • 20. Declaring nodes // … JavaScript: {
 id: JavaScript,
 body: "viewBox="0 0 256 256" v "<path d="M67.311746,21 "</svg>n",
 sizeMult: 1.2
 }, KAROL DEPKA
  • 21. Declaring nodes, part 2 Inkscape: {id: Inkscape},
 Illustrator: {id: Illustrator},
 AffinityDesigner: {id: AffinityDesigner, html: "Affinity<br/>Designer"},
 // … var nodesWebOnly = [
 nodes.SVG,
 // …
 nodes.NodeJS,
 nodes.JavaScript,
 ]; KAROL DEPKA
  • 22. Declaring links between nodes var linksWebOnly = [
 {source: HTML5, target: Angular2},
 {source: Ionic, target: Angular2},
 {source: HTML5, target: Angular2},
 {source: D3, target: SVG},
 {source: JavaScript, target: HTML5},
 {source: JavaScript, target: TypeScript},
 {source: JavaScript, target: jQuery}, // …
 {source: Angular2, target: TypeScript},
 {source: jQuery, target: HTML5},
 {source: HTML5, target: CSS, thick: 10},
 {source: SVG, target: HTML5, thick: 10, distance: 1.5},
 ];
  • 23. Setting up the D3 force simulation /* Base Example: Force-Directed Graph: https://bl.ocks.org/mbostock/4062045 */ 
 var simulation = d3.forceSimulation()
 // .force("gravity", 3)
 .force("link",
 d3.forceLink().id(function(d) { return d.id; })
 .strength(function(d) {
 return 3;
 }))
 .force("charge", d3.forceManyBody().strength(-1000))
 .force("center", d3.forceCenter(width / 2, height / 2));
 KAROL DEPKA
  • 24. Where to handle mouse events Layer for drag&drop and mouse-over KAROL DEPKA
  • 26. Add drag&drop function dragStarted(d) {
 isDragging = true;
 if (!d3.event.active) {
 simulation.alphaTarget(0.3).restart();
 }
 d.fx = d.x;
 d.fy = d.y;
 }
 
 function dragged(d) {
 isDragging = true;
 d.fx = d3.event.x;
 d.fy = d3.event.y;
 }
 
 function dragEnded(d) {
 isDragging = false;
 unHighlightHover()
 
 if (!d3.event.active) {
 simulation.alphaTarget(0);
 }
 d.fx = null;
 d.fy = null;
 }
  • 28. Add SVG icons perNodeMainGroup.append("g").html(function(d) {
 var bodyText = d.body || "";
 var size = d.sizeMult ? d.sizeMult * defaultSize
 : defaultSize;
 
 if (bodyText.trim().endsWith("</svg>")) {
 const htmlContent = '<svg '
 + 'width="' + size + 'px" '
 + 'height="' + size + 'px" '
 + 'x="' + (-size/2) + '" '
 + 'y="' + (-size/2) + '" '
 + bodyText /* also contains </svg> */;
 return htmlContent;
 } else {
 return "";
 }
 });
  • 29. Add HTML foreignObject perNodeMainGroup.append("foreignObject")
 .attr("style", "pointer-events:none;")
 .attr("width", foreignObjectW)
 .attr("height", foreignObjectH)
 .attr("height", foreignObjectH)
 .attr("x", -foreignObjectW/2)
 .attr("y", -foreignObjectH/2)
 .style("font", "9px 'Helvetica Neue'")
 .html(function(d) {
 if ( d.body ) {
 return ""; // has icon: no need for text
 }
 var bodyText = d.html || d.id;
 return "<div style='display: table;" +
 "text-align:center;" +
 "height:100%; width:100%'>" +
 "<p style='display: table-cell; " +
 "vertical-align: middle'>" +
 bodyText + "</p></div>";
 });
  • 30. ticked() function function ticked() {
 link
 .attr("x1", function(d) { return d.source.x; })
 .attr("y1", function(d) { return d.source.y; })
 .attr("x2", function(d) { return d.target.x; })
 .attr("y2", function(d) { return d.target.y; });
 
 nodeG1.attr("transform", function(d) {
 return "translate(" + d.x + "," + d.y + ")";
 });
 } KAROL DEPKA
  • 31. Tested on browsers • Chrome • Firefox • Safari • Opera • Edge • Internet Explorer
  • 32.
  • 33. Browsers, Browsers, Browsers! • Who here uses IE as their main browser? • Who here uses IE as their main browser and is not afraid to admit it? • Who here uses Microsoft Edge as their main browser? H ands up please!
  • 36. Cool D3 Examples • http://bl.ocks.org/rkirsling/5001347 - directed graph editor KAROL DEPKA
  • 38. Alternatives to SVG • Font Awesome (only monochrome?) • Canvas? (not scalable?) • Adobe Flash? ;-) • PDF KAROL DEPKA
  • 39. A little poll - after the presentation • On SVG: • who has plans to learn / use SVG? • On D3 • who has plans to learn / use D3? H ands up please! KAROL DEPKA
  • 41. THANKS TO Ewa, Rafa Antonio, Guillermo, Abigail Ania, Greg