Concepts of D3.js
- Allowing Effective Interaction
- Manipulation of DOM
- Working with charts and data
- Allowing perfect transition among with UI (User Interface) states.
D3.js contains the concept of web standards that helps you to create the visualization. These web standards are listed below-
- HTML (Hypertext Markup Language)
- DOM (Document Object Model)
- CSS (Cascading Style Sheet)
- SVG (Scalable Vector Graphics)
Now, we are going to discuss each web standard in detail.
HTML (Hypertext Markup Languages)
HTML language helps us to provide structure to the content displayed on a webpage. You can store the HTML file with the help of the “.html” extension.
Here, a basic example of HTML code is given below.
<html lang = “en”>
<meta charset = “UTF – 8”>
DOM (Document Object Model)
DOM is a language-independent and cross-platform interface that deals with the HTML and XML documents as tree a structure in which each node of an object present a part of a document.
When you load a page on a browser, then it is transformed into a hierarchical structure. In HTML language, tags are transformed in Document Object Model (DOM) with a parent-child hierarchy. This specific transformation makes your code logically structured. When you create a DOM, then it helps you to manipulate the contents on the page. It includes adding, modifying, and removing the elements.
Here, we have an example of HTML to understand the above concept.
<html lang = “en”>
<title> Hello D3.js </title>
<p>Welcome to the world of D3.js</p> </div>
The hierarchical document object model for the above given HTML code is as follows:
CSS (Cascading Style Sheet)
HTML language helps to provide a specific structure to the webpage, while CSS helps to make your web page more interactive and good looking. CSS (Cascading Style Sheet) is referred to as a stylesheet language which determines the document representation coded in HTML or XML (Extensible Markup Language). It also involves the XML dialects such as XHTML (Extensible Hypertext Markup Language), and SVG (Scalable Vector Graphics). CSS also determines that how you can deliver an element or content on a webpage.
SVG (Scalable Vector Graphics)
SVG is an XML based image format used for two-dimensional graphics that supports animation and interactivity. It is an open-source standard introduced by the World Wide Web consortium in 1999. The behavior and Scalable vector graphics images are determined in XML files.
SVG is a way that describes how to deliver an image on the webpage. SVG does not directly consideration of an image. It is just a way to draw an image with the help of text. It is considered as a scalable vector because SVG scales itself according to the browser’s size. It helps you to resize your browser, and in this situation, your image will not be deceived.
You can execute SVG on any browser except Internet Explorer 8. The data visualization process is referred to as the presentation of data in a visual format. SVG helps you to deliver visualizations with the help of D3.js.
Here, we consider SVG as a canvas, on which we can paint various shapes of different sizes. So first of all, you are required to create an SVG tag as follows:
<svg width = “400” height = “400”></svg>
If you declare SVG in its default measurement, that is a pixel, you don’t need to classify it separately, and if you want to draw a rectangle, you are required to write the following code:
<svg width = “400” height = “400”>
<rect a = “0” b = “0” width = “200” height = “100” fill = “red”></rect>
After the execution of the above code, you will get the following shape as an output: