Author Archives: Dr. Darrin

Add/Subtract Rational Expressions Different Denominators VIDEO

Add/Subtract Rational Expressions with Different Denominators

 

 

1Checkout ERT online math courses

 

Advertisements

Force-Directed Graph with D3.js

Network visualizations involve displaying interconnected nodes commonly associated with social networks. D3.js has powerful capabilities to create these visualizations. In this post, we will learn how to make a simple force-directed graph.

A force directed graph uses an algorithm that spaces the nodes in the graph away from each other based on a value you set. There are several different ways to determine how the force influences the distance of the nodes from each other that will be explored somewhat in this post.

1.jpg

The Data

To make the visualization it is necessary to have data. We will use a simple json file that has nodes and edges. Below is the code

{

"nodes": [

{ "name": "Tom" },

{ "name": "Sue" },

{ "name": "Jina" },

{ "name": "Soli" },

{ "name": "Lala" }

],

"edges": [

{ "source": 0, "target": 1 },

{ "source": 0, "target": 4 },

{ "source": 0, "target": 3 },

{ "source": 0, "target": 4 },

{ "source": 0, "target": 2 },

{ "source": 1, "target": 2 }

]

}

The nodes in this situation will represent the circles that we will make. In this case, the nodes have names. However, we will not print the names in the visualization for the sake of simplicity. The edges represent the lines that will connect the circles/nodes. The source number is the origin of the line and the target number is where the line ends at. For example, “source: 0” represents Tom and “Target”: 1 means draw a line from Tom to Sue.

Setup

To begin the visualization we have to create the svg element inside our html doc. Lines 6-17 do this as shown below.

1.png

Next, we need to create the layout of the graph. The .node() and the .link() functions affect the location of the nodes and links. The .size() affects the gravitational center and initial position of the visualization. There is also some code that is commented out in below that will be discussed later. Below are lines 18-25 of our code.

1

Now we can write the code that will render or draw our object. We need to append the edges and nodes, indicate color for both, as well as the radius of the circles of the nodes. All of this is captured in lines 26-44

1

The final step is to handle the ticks. To put it simply, the ticks handles recalculating the position of the nodes. Below is the code for this.

1

We can finally see are visual as shown below

You can clearly see that the nodes are on top of each other. This is because we need to adjust the use of the force in the force-directed graph. There are many ways to adjust this, but we will look at two functions. These are .linkDistance() and .charge().

The .linkDistance() function indicates how far nodes are from each other at the end of the simulation. To add this to our code you need to remove the comments on line22 as shown below.

1

Below is an update of what our visualization  looks like.

Things are better but the nodes are still on top of each other. The real differences is that the edges are longer. To fix this, we need to use the .charge() function. The .charge() function indicates how much nodes are attracted to each other or repel each other. To use this function you need to remove the comments on line 23 as shown below.

1

The negative charge will cause the nodes to push away from each other. Below is what this looks like.

You can see that as the nodes were moved around the stayed far from each other. This is because of the negative charge. Off course, there are other ways to modify this visualization but this is enough for now.

Conclusion

Force-directed graphs are a  powerful tool for conveying what could be a large amount of information. This post provided some simple ways that this visualization can be developed and utilized for practical purposes.

Essentialist Teacher

Essentialism was an educational philosophy that was reacting to the superficiality of instruction that was associated with progressivism and the aristocratic air that was linked with perennialism. Essentialism was a call to teach the basics. This position of providing a no frill basic education for employment is the primary position of most educational positions in the world.

1Background

Starting in the 1930’s, essentialism is based on the philosophies of idealism and realism. Essentialism supporters have stressed the need to return to a more subject centered approach vs child centered position. Transmission of knowledge is more important than transforming society.

There were two major moments in American history that propelled essentialism to the forefront of education. The first, happened in 1957 when the Russians launch the Sputnik satellite. Critics of progressivism stated that all this child-centered teaching had crippled an entire generation who lacked basic skills in math and science to compete with the Russians. This was a major blow to progressivism as schools refocused on teaching math and science and having a subject centered curriculum.

In essentialism was not already triumphant it certainly was by the 1980’s when the article “A Nation at Risk” was published. This article stated that American education was mediocre and lead to schools needing to focus on the five basics. By the 1990’s such ideas as “core knowledge” or “common core” was being pushed. Such ideas demonstrate how there are basic truths and ideas that supposedly all students need to have.

Philosophy

School is a place where students master basic skills in preparation for working in society. This includes the three R’s (reading, writing, arithmetic) and some of the humanities. The subject matter cannot always be interesting or even immediately relevant for students.

The mind needs to be trained and some memorization is required. However, there is  less of a focus on raw intellectualism such as is found in perennialism. The center of learning is the teacher and the students are there to follow the teacher.

Essentialism has similarities to perennialism. However, there are differences such as the idea that Essentialism does not have a problem with adapting ideas from progressivism for their on own purposes.   There is also a general indifference to time honor classics  in the humanities for the training of the mind.

In Education

An essentialist teacher is going to focus on developing skills and competency rather the learning knowledge for the sake of knowledge. There will be a focus on the basics of education and the classroom will be subject centered. There will not be much tolerance for meeting needs or understanding differences among students.

Focus on job skills and training towards employment would also be stressed. The focus of the education is in training people to be equipped for the workplace and not for personal fulfillment. If students enjoy what they learn this is an added bonus but not necessarily critical for the learning experience.

Conclusion

Essentialism was in many ways a working-class version of perennialism. Stripped of the humanities and focused on developing job skills, essentialism is the engine of education in many parts of American education. As long as the economy and employment are most important to people we will continue to see a continued support for essentialism.

Perennialist Teacher

Perennialism was a strong educational movement in the early part of the 20th century. It pushed a call to return to older ways of learning and instruction in order to strengthen the man in preparation for life. In this post, we will look briefly at the history, philosophy, and how a teacher with a perennialist perspective may approach their classroom.
1.jpg
Background

Perennialism came about as a strong reaction against progressivism. The emotional focus of the child-centered approach of progressivism was seen as anti-intellectual by perennialists. In place of child- center focus was a call for return to long establish truth and time honored classics.

Supporters of perennialism wanted a liberal education, which implies an education rich with the classical works of man. The purpose of education was the development of the mind rather than the learning of a specific job skill. This position has often been seen as elitist and has clashed with what the working class need for the education of  their children to be in a more practical manner.

A major influencer of perennialism is neo-scholasticism, which is also a supporter of classical studies and was based  on idealism. Perennialism was originally focused higher education and high school but by the 1980’s its influence had spread to elementary education. Prominent supporters of this style include Motimer Adler and Maynard Hutchins.

Philosophical Position

Perennialism believes that people are rational rather than primarily emotional beings. This is the opposite of progressivism which is always worried about feelings. Furthermore, human nature is steady and predictable which allows for everyone to have the same education. Thus, the individual is lost in a strong perennial classroom.

The focus of the classroom is not on the student but rather on the subject matter. The classroom is preparation for life and not design for real-life situations as in progressivism. The mind needs to be developed properly before taking action. Through the study of the greats it is assumed this will help the student become great.

Perennialism and Education

A perennialist teacher would have a classroom in which all the students are treated the same way. Material is taught and delivered to the students whether they like it or not. This is because material is taught that is good for them rather than what they like.

This material would include ancient time tested ideas because that is where truth is and exposure to this great minds would make  great mind. The learning experiences would be mostly theoretical in nature because training in this manner allows for intellectual development.

The classroom might actually be a little cold by the progressivist’standard that focuses on group work and interaction. This is because of the rational focus of perennialism. When the assumption is everyone  is rational and only needed exposure to the content with or without an emotional experience.

Conclusion

Reacting is not always the best way to push for change. Yet this is exactly what brought perennialism into existence. Seeing the lost of absolute truth and long held traditions, perennialism strove to protect these pillars of education. There are some problems. For example, their emphasis on the rational nature of man seems strange as the average person is lacking in the ability to reason and control their emotions. In  addition, the one-size fits all when it comes to education is obviously not true as we need people who have a classic education but also people who can build a house or fix a car. In other words, we need vocational training as well in order to have a balanced society.

Another problem is the fallacy of the appeal to tradition. Just because something is a classic does not make it truth or worthy of study. This simply allow the traditions of the past to rule the present. If all people do is look at the past how will they develop relevant ideas for the present or future?

The main benefit of these different schools of thought is that through these conflicts of opinion a balanced approach to learning can take place for students.

Pie Charts with D3.js

Pie charts are one of many visualizations that you can create using D3.js. We are going to learn how to do the following in this post.

  • Make a circle
  • Make a donut
  • Make a pie wedge
  • Make a segment
  • Make a pie chart

Most of these examples require just a minor adjustment in a standard piece of code. This  will make more sense in a minute.

Make a Circle

Making a circle involves using the .arc() method. In this method there are four parameters that you manipulate to get different shapes. They are explained below

  • .innerRadius() This parameter makes a whole in your circle to give the appearance of a donut
  • .outerRadius() Determines the size of your circle
  • .startAngle() is used in combination with .endAngle() to make a pie wedge

Therefore, to make several different shapes we manipulate these different parameters. In the code below, we create the svg element first (lines 7-10)  then our circle (lines 11-15). Lastly, we append the path to the svg element (lines 16-21). Below is the code and picture.

12

The rest of the examples primarily deal with manipulating the existing code.

Donut

To make the donut, you need to change the value inside the .innerRadius() parameter. The larger the value the bigger the hole in the middle of the circle will become. In order to generate the donut below you need to change the value found in line 12 of  the code to 100.

1.png

Pie Wedge

To make a wedge you need to replace lines 14-15 of the code with the following

.startAngle(0*Math.PI * 2/360)

.endAngle(90*Math.PI * 2/360);

This is telling d3.js to start the angle at 0 degrees and stop at 90 degrees. This is another way of saying making a wedge of 1/4 of the circle. Doing this will create the following.

1

Segment

In order to make the segment you keep the code the same as above for the pie wedge but at a change to the .innerRadius() parameter. AS shown below,

.innerRadius(100)

.outerRadius(170)

.startAngle(0*Math.PI * 2/360)

.endAngle(90*Math.PI * 2/360);

1

Pie Chart

A pie chart is just a more complex version of what we have already done. You still need to set up your svg element. This is don in lines 7-14. Notice that we also had to add a g element and a transform attribute.

Line 16 contains the data for making the pie chat. This is hard coded but we can also use other forms of data. Line 17 uses the .pie() method with the data to set the stage for our pie chart.

Lines 19-27 are for generating the arc. This code is mostly the same except for the functions that are used for the .startAngle() and .end Angle() methods. Line 29 sets the color and Lines 30-42 draw the paths for creating the image. The code with the // will be explained in a moment. Below is the code and the pie chart.

12

Pie Chart Variation

Below is the same pie chart but with some different features.

  • It now has a donut (line 20 change .innerRadius(0) to .innerRadius(50))
  • There are now separations between the different segments to give the appearance that it is pulling apart. Remove the // in lines 36-37 to activate this.

Below is the pie chart

1.png

You can perhaps now see that the possibilities are endless with this.

Conclusion

Pie charts and their related visualizations are another option for communicating insights of data

Progressive Teacher

Progressivsim is an educational philosophy that in many ways is the foundation of educational theory in the United States. In this post, we will look at the background of progressivism as well as the beliefs and how it may be practiced by a teacher.
1.jpg
Background

Progressivsim is yet another reaction to traditional teacher. The era in which this philosophy was developed was the late 19th to early 20th century. This was a time of rapid change and the development of the philosophy called pragmatism, which had a strong influence on progressivism.

Pragmatism had such beliefs as that there was no fixed truth and that whatever works is true. Progressivism adapted and expended on this idea in the context of education. Another major source of influence on progressivism was the work of Freud who encourage self-expression in his writings.

The primary movers in propagating progressivism includes William Kilpatrick, George Counts, John Dewey, and others. This movement dominated educational theory in America from the 1920’s to the 1950’s until the launching of the Sputnik satellite by Russian moved Americans away from child centered self expressive education to an education focused on the essentials in order to compete in a global competition.

Philosophical Position

In the classroom progressivism does not support a teacher-centered approach, nor a heavy focus on textbooks or memorization. there is even concerns with the classroom environment in that the use of fear or physical punishment is discouraged.

The child is the centered of learning rather than the subject. This means that the interest of the child should be taken into consideration when developing learning experiences. Of course, there is a limit to the child’s input as the teacher has a certain responsibility for the learning. However, to even consider the child’s opinion on learning was somewhat revolutionary at the time.

Students need to be active rather than passive. This  means that lectures are unusually because the student not active when listening. Learning by doing is a primary assumption of progressivism. The teacher and the student interact and learn from action rather than from listening.

In order to establish active learning, problem solving is one of the primary tools for teaching. Problem-solving leads to a whole lot of thinking in a systematic manner in ways that are tied to reality rather than to theory.

Lastly, progressivism supports the idea of a democratic classroom. This means that everyone is a learner, including the teacher, and the learning environment encourages discussion and debate. The motive behind this is preparing students to participate in a democratic world.

Progressivism in the Classroom

There is little here to add that was not already mentioned. A progressive teacher is going to support a warm and engaging classroom. The teacher will see themselves as a facilitator of knowledge rather than as a dictator of it. Students will work in groups or alone depending on interest and the content learned  will have input from them. There will be few lectures and more hands on learning activities with a focus on the thought process rather than the product of the  learning.

Conclusion

Progressivism is yet another philosophical system that claimed to have the answer for learning only to eventually lead t people’s disappointment. It was hard to assess learning during the progressives era due to the open nature of problem solving. In addition, when the Russians beat the Americans into space. Focusing on the child simply became impractical due to the perceived threat of Russia. In many ways, progressivism was successful because when it was no longer practical it was abandon and this is something that progressivism teaches.

Dendrogram with D3.js

Dendrogram is a type of hierarchical visualization commonly used in data science with hierarchical clustering. In d3.js, the dendrogram looks slightly different in that the root is in the center and the nodes branch out from there. This idea continues for every parent child relationship in the data.

In this post, we will make a simple dendrogram with d3.js using   a simple json file shown below.

{

  "name": "President",

          "children": [

        { "name": "VP of Academics",

        "children":[

          {"name":"Dean of Psych"},

          {"name":"Dean of Ed"}

        ] },

       { "name": "VP of Finance" },

        { "name": "VP of Students" }

      ]

    }

You will need to save the code above as a json file if you want to make this example. In the code, this json example is called “university.json”

Making the Dendrogram

We will begin by setting up the basic svg limit as found in lines 1-19 below.
1.png

In lines 20-26, the radius of the nodes is set and added to the svg element. The clusters are set with the creation of the cluster variable. Below is the code.

1.png

In lines 27-37, we set the position of the nodes and links as well as diagonals for the path.

1

Lines 49-80, have three main blocks of code.

The first block creates a variable called nodesGroups. This code provides a place to hold the nodes and the text that we are going to create.

The second block of code is adding circles to the nodeGroups with  additional settings for the color and radius size. Lastly, the third block of code adds texts to the nodesGroups.

1.png

When all the steps have been taken, you will see the following when you run the code.

1.png

You can see how things worked. The center is the president with the vp of academics of to the right. The president has three people under him (all VPs) while the VP of academics has two people under him (deans). The colors for the path and the circle are all set in the last block of code that was discussed.

Conclusion

Dendrograms allow you to communicate insights about data in a distinctly creative way. This example was simplistic but serves the purpose of exposing you to another way  of using d3.js

Postmodern Teacher

During the last half of the 20th century the philosophical school of post-modernism arose. Just as with existentialism, post-modernism is a school of thought that is anti-definition and anti-organized. As such, it is hard to pinned down exactly what post-modernist believe and stand for in a way that this could be done for older philosophies. In many, ways, as we get closer to the present era the ideas and tenets of the current philosophies become almost invisible  perhaps because we are living directly under their effect rather than looking at their influence in the past.
1
Background

Post-modernism, like almost all philosophies it seems, is a reaction  to modernism.  Modernism primary tenet was to understand the world through the use of reason. Modernist believed that the world had fixed laws that could be observed and understood. Science was the way to understand reality and attain truth. There was also this sense of continuous progress, which is something that is still repeated in the media today.

However, modernism did not solve all problems and lead to a Utopian existence. Instead, throughout the late 19th and 20th century there were consequences of scientific and social progress from pollution, to atomic destruction, wars, famine, disease, etc. It seemed as if every time science solved one problem it eventually led to more problems that were not anticipated.

The foundation for post-modernism was laid by Friedrich Nietzsche who claimed that truth and God are dead. This shifted knowledge from something that was absolute to something that was human generated.

Pragmatism and existentialism further laid the groundwork for post-modernism with pragmatism’s position that knowledge was provisional and constantly changing. Existentialism simply reinforces Nietzsche’s position that knowledge is constructed rather than discovered.

Perhaps one of the strongest influences on post-modernism is Marxism. Karl Marx was focused on class struggles from an economic perspective. Within Postmodernism this was extended to other aspects of society including feminism, racism, sexism, LGBT,  weightism, or generally any minority group who is crying out against the perceived “privilege” of the majority.

Philosophical Implications

Postmodernists essential question everything and it almost seems as if they tear down everything with no real replace for what they are tearing down. It is permissible to have opinions about anything but there is no truth except for the truth that there is no truth because they say so.

An example of questioning reality itself  is in the work of Jacques Derrida and his work on deconstructionism. According to Derrida, language has blocked us from understanding reality because we are using words to describe this reality. This means that whenever we read or examine text we have to unpack or deconstruct the assumptions that the author of the text had in terms of their word choices and context. This is critical because the dominant group writes in a way that excludes the minorities and those without power. Of course, you would need to support Derrida’s words even though they may not be representative of reality either

Other postmodern philosophers suggest that reality is socially constructed by those who have power. Those in power shape reality to benefit themselves. There are examples of this in history, as people in power normally portray the powerless negatively. This has even happened in the world of science where views on bloodletting and even the consumption of cocaine.

After identifying these injustices, the postmodernist is not content to identify problems but to push change. The marginal groups need to rise up from the shackles of their oppressors. Pragmatism push change slightly but postmodernism can almost be revolutionary in its language for transformation. Everything is viewed with an eye towards suspicions that begets change except for the idea of viewing everything with skepticism that leads to change.

When everything is viewed as oppression eventually everything is overturned. Whoever gains power will then be viewed as oppressive until they too are overthrown. Eventually, there is nothing left. The problem with postmodernism is not that it identifies problems but that they have no solution beyond tearing everything down over and over again.

In Education

A postmodern teacher is going to be skeptical of absolute truth. They will stress the idea of doubting the text and trying to identify the inconsistencies in an author’s argument. There will be a focus on minority groups and how they are oppressed by those who are privileged.

With deconstructionism, students are trained to be sensitive to language and its use. This is perhaps one reason why such terms as politically correct are used today. People have been trained to be sensitive to language that does not fit the narrative and to identify hurtful language as almost dangerous.

All opinions are expected to be embraced and appreciated no matter how much they lack in validity and credibility unless they are defined as insensitive. Students will never be called upon to store and share the knowledge of the past. Rather, students are change agents who are called to overthrow the social injustice of the planet. This is not revolution as Marx saw it but rather reconstruction of what was deconstructed.

The curriculum is a process and not based on content. The teacher is also a social justice warrior. What is needed is people who challenge the status quo rather than work within it. Therefore, postmodernist thought is much more people in the softer sciences rather than in STEM fields. STEM requires stability in order to expand technology and make discoveries and money. Unfortunately, social stability is not required as much for a sociology or liberal arts major.  The idealistic nature of postmodernism denies the reality that life has never been fair ever in the entire history of humanity.

Tree Diagram with D3.js

Tree diagrams are used for showing hierarchical relationships in data. This post will explain how to make a tree diagram using d3.js.

The Data

We are going to use a simple json file. Below is the code inside the json file.

{

"name": "President",

"children": [

{ "name": "VP of Academics",

"children":[

{"name":"Dean of Psych"},

{"name":"Dean of Ed"}

] },

{ "name": "VP of Finance" },

{ "name": "VP of Students" }

]

}

The code above is json file that models relationships among different positions you would find at a university. The root node is “president”. Under president, there are three children which are “VP of academics”, “VP of Finance”, and “VP of students”.

VP of academics also has two children which are “Dean of Psych” and “Dean of Ed.” You need to save this code on your computer somewhere as a json file for use in the d3.js code.

Below is a picture of what the final visual looks like.

1

The code is too long to post in its entirety here. Rather, you can download the code at the link here.

The code is explained below.

Code Description

Lines 1-26 setup the general documents, loads the data, adds an svg element to the body, and a g element to the svg element. Below is the code.

1.png

Lines 27-34 creates the actual tree and creates variables for the nodes and links that will be used later.

1.png

Lines 36-50 creates the diagonals and the nodes for the diagram. The diagonal is created using the .projection() method. Attributes are set for the diagonal as well under the .selectAll() method and includes the stroke color, width of the stroke, and the fill. The code is below.

1.png

Lines 52-66 create the circles for each node. This involves appending information in the element as well as setting colors for the circles.

1.png

Finally, lines 68-85 involve the text from the json file. The first method calls the text, the second method deals with position, and the last method also addresses position somewhat.

1

A lot of work but can be valuable in certain situations.

Conclusion

Making tree diagrams is another visualization available using d3.js. If the nature of the data is hierarchical this may be a useful approach to consider when make visualizations.

Pragmatic Teacher

In this post, we will take a look at pragmatism. This philosophy has played a critical role in shaping ideas about education for a long time. In particular, we will look at the characteristics of pragmatism, its philosophical implications, and how it may manifest it’s self in the classroom.

Background

Pragmatism is a uniquely American 19th century contribution to philosophy with some of the primary influences in this school being such people Charles Perce, William James, and John Dewey. The era in which pragmatism was developed was the industrial revolution and an era of great change. Science was gravitating towards the idea of evolution, which at the time was astounding and even the religious world was in turmoil with people speaking of the end of the world. This environment of rapid change was deeply influencing the thoughts of many people.

With all the chaos swirling throughout the world pragmatism came to the point that there were no ideals or principles to look for. Rather, the focus was on what works and benefits the most than on conforming to an external standard.  This position has had a profound impact on education through the work of the progressives as we shall see.

Philosophical Implications

There are no absolutes with a pragmatist. If there is some form of ultimate reality there is no way to know it here. In other words, while Plato bemoaned the cave and Socrates stated that the cave is all there is, a pragmatist may say that the world of forms is possible but since all we know for sure is the cave we should try to make it as nice as comfortable as possible.

One of the sources of argument that pragmatist make about the constant state of change implying a total lack of absolute truth is changes in science. Examples include, moving from a geocentric worldview to a heliocentric one, or moving from a creationist account of life to an evolutionary one. Since these ideas have changed there must not be any absolute truths to hold on to even though the realm of science is notorious for constant changed.

With all the chaos of the world, pragmatist has decided that truth is what works. Knowledge is based on experience. Through trial and error people learn how to deal with various problems. It is this active process of constructing knowledge through experience that knowledge is constructed. Knowledge is not external or outside the person, instead it is created through interaction with the world. This is a major shift in thinking from pass viewpoint and requires that the individual be an active rather than passive learner because they must interact with the world.

There is a separation in the mind of the pragmatist between knowledge and belief. Beliefs are private while knowledge is publicly available., which means it can be observed and verified by others. True knowledge or truth is relative because of the unstable and changing world that we live in.

Since truth is relative morals and values are relative as well. Local societies decide for themselves what is right and wrong and not an external standard. However, this does not mean anything goes. Stealing is disdained in most societies because it does not work as it tends to encourage crime and chaos. The same for murder. This does not mean to the pragmatist that there are universal moral laws, instead it is simply an indication that different groups of people have had similar experiences with stealing and murder and have made the same conclusion that this does not work.

Pragmatism and Education

A unique belief of pragmatism about students is that they need to be active learners. Students need to experience the world around them through learning activities. School is not preparation but is rather part of life it’s self. Therefore, life long learning is to be expected and not just a temporary period of life in which it is needed for studying.

The  teacher is an expert guide who helps the students. They  are a guide because the world changes too quickly to just dictate material to students. This means that the teacher is learning as well with the advantage of more experience living in a world of flux. Since truth is changing, there is no fix curriculum from yesteryear. Instead, the student’s interests are the center of how  the curriculum is built.

With the focus on the environment, the pragmatic teacher is focused heavily on having students impact the world. This means that an emphasis on social action is a part of the pragmatist classroom. In some classroom social change and attaining social goals (ie social justice warrior) is the entire purpose of education. Other philosophies were trying to maintain the status quo but pragmatism is trying to overturn it if it works.

Conclusion

Pragmatism, like most new movements of their time, is simply a reaction to what came before in response to the challenges of the current context. Pragmatist reject absolute truth except for the absolute truth that there is no absolute truth. The world was truly changing quickly when this school of thought was born. However, unlike Plato, who was also experiencing rapid change and decide to search for absolutes in order to find comfort, the pragmatist reject absolute truth for the comfort of constant change. Instead of trying to preserve knowledge it was better to go with the flow as long as it worked.

Existentialist Teacher

This post will examine the mysterious position of existentialism,  which is basic a school of thought that denies that it is a school of thought.  We will look at the origins of existentialism, the characteristics, and its role in education.

Background

Existentialism is all about the individual. In an interesting paradox, existentialism is so individualistic that they do not see themselves as a group with set of beliefs as other philosophies do. There is a rejection of any unified body of beliefs, thoughts, or system.

Early proponents of existentialism include Soren Kierkegaard and Friedrich Nietzsche. These two 19th century philosophers were reacting to the nature of Christianity during their time. Kierkegaard focused on emphasizing the responsibility of the individual believer and their choices within religion. Nietzsche went in a different direction and became convince that there was no God and that man was responsible for his actions alone. This conclusion  eventually drove Nietzsche crazy in a literal manner.

Between the extremes of Kierkegaard and  Nietzsche is where most beliefs of existentialism are. Primarily, existentialism is trying to regain the lost of the individual. This sense of lost may have come from more and more people living in cities to work for others along with the growth of the  government in providing services. The existentialist longed for the day when people were independent and could do what they wanted in returned for the responsibility for their actions.

Philosophical Implications

According to existentialism,  a person must define who they are. Defining who you are is not left to an Absolute Self or Natural Law but to the person who existence. Reality is found within the individual person. This is a major shift from idealism view that reality is beyond this world and realism’s belief that reality is in the physical world.

Truth is based on a person’s choice. People believe what they want because  they want to. This seems confusing but it is laying the foundation for post-modernism min the near future with its view of relative truth. Now, the individual is the source of authority and not any other code.

With a lack of external authority existentialism has to determine right and wrong with no source of authority. This source of freedom has been called a slavery to freedom by some. Slavery is bad but paradoxically too much freedom can be burdensome as well since there is no guidance in terms of how to act. Most people want some freedom but perhaps nobody wants complete freedom as this would be injurious to themselves and others if they could truly do whatever they wanted.

Existentialism and Education

A teacher with an existentialist perspective would be surprised at how students are taught. They would see it as oppressive and even with tendency towards being a form of propaganda. Students would need much more choice and responsibility for their own actions since the current form of teaching destroys individualism.

The existentialist teacher is not the center of the instruction but rather a facilitator. The goal is to help students better understand who they are as individuals. This also means that the student should have a choice in what they learn and that the curriculum needs to be somewhat flexible. The goal is the development of the individual and not the society as the society does not care for the ultimate development of the individual.

Conclusion

Existentialism is a system of thought that claims not to be a system because everyone within the system wants total freedom.  This is contradictory yet considered consistent among existentialist. The reaction they have towards the growing power of large society gives this philosophy a romantic longing for almost a wild pre-industrialization world. However, though many people may not agree with some of the tenets of this group many do wish that they could have at least a little more personal freedom and individuality.

Neo-scholastic Teacher

Scholasticism and Neo-Scholasticism is a philosophy that has had a stronger influence in Christian education rather than in secular circles. This post will explore the characteristics of these philosophies as well as their role in education.

Background

Neo-Scholasticism began as simply scholasticism and was simultaneously a movement and a philosophy that sprang up during the medieval time period in Europe somewhere between 1050 and 1350 originating in the early universities. This was primarily a movement within the Catholic church as they controlled higher education at this time in Europe. The scholars of this movement were not as concern about discovery new truth as it was with proving and establishing the validity of existing truth. In other words, Neo-Scholasticism was primarily reactionary in nature.

The reason for the reactionary nature of Neo-Scholasticism was the rediscovery of the writings of Aristotle. These writings had been lost for centuries but had been preserved in the Islamic nations. Through interactions with the Muslim world through trade and war Aristotle’s writings were translated from Arabic into Latin. Aristotle’s realistic views were a challenge to the Platonic/idealistic views of the Christian church.

Scholars, for whatever reason, were convinced that church teachings had to be harmonized with the writings of Aristotle. Why religious teachings and beliefs had to bow to the influence of one Greek philosopher is subject of debate but perhaps the status of Aristotle compelled the church to merge his ideas with their own in order to maintain intellectual leadership of Europe.

The leader of this merger of faith and reason was Thomas Aquinas. He proposed that people should learn as much as they can through human reason and have faith in matters that cannot be reasoned about. Therefore, at the heart of scholasticism was human reason which in many ways had displaced faith.

Neo-Scholasticism is the modern equivalent of Scholasticism.  The primary difference is that Neo-Scholasticism has religious and secular branch whereas Scholasticism had only one main branch or school of thought.

Philosophical Implications

Scholasticism focus was on accommodating the philosophy of Aristotle with christian thought. Therefore, many of Aristotle’s beliefs are reinterpreted as much as possible to be consistent with Christianity. For example, Aristotle spoke of the Unmoved Mover, which he stated was the first cause of all other causes in the universe. Aquinas equated the Unmoved Mover with God.

Reality had a dualistic nature to it for the scholastic. The natural world was understood through reasoning while the supernatural world was available through revelation and intuition. Truth could be self-evident such as “2+2 = 4” or it can depend on observed experience such as “The average life expectancy is 72 years.” The greatest truth are the unchanging self-evident such as those found in mathematics rather than observed experiential truth.

Morality is governed by reason. There is an assumption that people are rational at their core. The more rational the higher moral quality a person should have.

Neo-Scholasticism and Education

The teacher’s role from a Neo-Scholastic perspective is to help rational students develop their reasoning, will power, and memory. The teacher is the center of the education process and works with students to transfer information. The subject matter takes precedent over the students’ interest.

With  its religious roots, Neo-Scholasticism see the teacher as a spiritual leader. This involves discipleship and even discipline at times. Only through this process can the student acquiring understanding of the unalterable truths of the world.

The curriculum of Neo-Scholasticism would include the humanities, math, and foreign languages (primarily Greek and Latin). The humanities allow students to understand the logic and thinking of great minds, math demonstrates unchanging truths, and foreign languages provides rigors training for the mind. The mind is a muscle that must be strengthened through examining the works of other men.

Conclusion

Neo-Scholasticism has not had the impact on education that idealism or realism has. The emphasis on teacher-centered instruction and memorizing is a major departure from modern forms of teaching. A good memory is not the same as a critical thinker. As with all schools of thought, Neo-Scholasticism suffers from a lack of balance. What is really needed is a flexible position that varies depending on the context.

Path Generators in D3.js

D3.js has the ability to draw rather complex shapes using techniques called path generators. This will allow you to many things that would otherwise be difficult when working with visualizations.

In this post, we will look at three different examples of path generation involving d3.js. The three examples are as follows

  • Making a triangle
  • Duplicating the triangle
  • Make an area chart

Making a Triangle

To make a triangle we start by appending a svg to the body element of our document (lines 7-12). Then when create an array that has three coordinates. We need three coordinates because that is how many coordinates a triangle needs (lines 13-17). After this, we create a variable called generate and use the .svg.line() method to draw the actual lines that we want (lines 18-20).

After this, we append the data and other characteristics to the svg variable. This allows us to set the fill color and the line color (lines 21-28). Below is the code followed by the output.

12

A simple triangle was created with only a few lines of code.

Create a Triangle and Duplicate

This example is an extension of the previous one. Here, we create the same triangle, but then we duplicate it using the translate method. This is a powerful technique if you need to make the same shape more than once.

The new code is found in lines 29-36

12

You can see that the new triangle was moved to a different position based on the arguments we gave it.

Area Chart

Area charts are often used to make line plots but with the area under the line being filled with a certain color. To achieve this we do the following.

  • Add our svg element to the body element (lines 7-10)
  • Create some random data using the .range() method and several functions (lines 12-18)
    • we generate 1000 random numbers (line 12) between 0 and 100 (line 14)
    •   We set the Y values as random values of X in increments of 10 (line16-17)
  • We create a variable called generate to create the path using the .area() method (line 20-23)
    • y0 has to do with the height or depth of the area the other two attributes are the X and Y values
  • We then append all this to the svg variable we created (lines 25-31)

Below is the code followed by the visual.

12

Much more can be done with this but I think this makes the point for now.

Conclusion

This post was just  an introduction to making paths with D3.js.

Metaphysics & Education

Metaphysics is the study of reality and the nature or character of it. This branch  of philosophy deals primarily with what is real. This may seem like an obvious question with an obvious answer. However, different people answer this question in different ways based on what they believe about the nature of reality and how we come to know it.

There are at least four sub-branches of metaphysics  that attempt to address the question of the nature of reality. These four branches are…

  • Cosmology
  • Ontology
  • Anthropology
  • Theology

We will look at each of these and then try to examine how metaphysics manifest itself in education.

Cosmology

Cosmology deals with the origins of the universe. The main views of the origins of the universe can be seen as a continuum from the universe was created or design by God or the other extreme that everything about the universe has happened by accident as is commonly viewed by evolution.  A middle ground along this continuum would be theistic evolution, which states that a divine being used evolution to create the world.

The beliefs an  individual has about cosmology affects other aspects of their life, education, and how they interpret what they experience. For example, an atheist scientist see nature and is awed by the random movement of natural selection to create such beauty. However, a theist would see the same evidence in nature and be led to the conclusion that God has created a beautiful climate. When these two sides meet they cannot agree because they have different assumptions or beliefs about origins and interpret what they see based on these beliefs.

Ontology

Ontology is the study of existence. This is probably one of the harder positions to understand. However, ontology deals with such ideas as whether reality is physical or spiritual, or a combination of the two. In addition, Ontology addresses whether reality is orderly and stable.

People’s beliefs about being can impact how the approach life. If there is nothing there is no reason to care or do anything. However, if there is something beyond this life and life was created with purpose this will alter a person’s behavior as they consider how they may be held accountable for their actions.

Anthropology

Anthropology is the study of man. Some questions that anthropology focuses on in particular is the relationship between the mind and the body. Is it the mind or the body the primary agent of behavior. Other questions include examining whether people or good or evil or morally neutral. Lastly, anthropology addresses the question of the freedom people have. Do people have choice or is their behavior determined by their environment?

The nature vs nurture argument is an old argument about the condition of man. The ultimate question is who is responsible for the actions that people take. The answer to this question evolves around views of the will.

Theology

Theology is the study of the nature of God and plays a profound role at least indirectly in all philosophy. Atheist strongly believe there is no God. As such, the support primarily science as a way of understanding reality. Theists believe there is a God or gods and this natural affects how they view realty.

Even among theists there is disagreement over how many gods there are. Polytheists believe in many gods while monotheists believe in one God. Pantheists believe god(s) is in everything and that they are gods. The position a person has on God can change how they view the world. Monotheists often believe in having a relationship with  one God in order to prepare for the reality of death in this life and the promise of living forever. Polytheists tend to have a contractual quid pro quo relationship with many different gods in order to do better in this world now and smooth the transition to living another life via some form of reincarnation.

Metaphysics and Education

Metaphysics manifest itself in many ways in education. In terms of cosmology and theology, most schools support the idea that the world came about by chance and that life evolved from almost nothing billions of years ago. This is related to theology in that most schools doubt the existence of God being openly atheistic in nature or may at most be agnostic in nature.   In a non-Western context, gods or polytheism is acknowledged and accepted in everyday life but traditional science and atheistic origins of the universe are generally taught in school. This can lead to a dual world view at times.

In terms of ontology and anthropology, the views on ontology vary by culture in education. In the West, the spiritual aspect of man is not acknowledged in education due in part to the focus on science. However, this is beginning to change with the emphasis on mindfulness and meditation in public education. In the East, there is a more open view towards the spiritual nature of man.

In terms of education, students are generally taught that man is inherently good but  may be corrupted by his environment and culture. In the East, education teaches that man is good by nature but may make mistakes. Culture is rarely criticized in eastern education.

Conclusion

Metaphysics is a difficult concept to try to address and understand. The important thing to remember is that metaphysics deals with the question of what is reality and that different people answer this question i different ways. How people answer these questions depends in part on their beliefs about cosmology, ontology, anthropology, and theology.

Drag, Pan, & Zoom Elements with D3.js

Mouse events can be combined in order to create some  rather complex interactions using d3.js. Some examples of these complex actions includes dragging,  panning, and zooming. These events are handle with tools called behaviors. The behaviors deal with dragging, panning, and zooming.

In this post, we will look at these three behaviors in two examples.

  • Dragging
  • Panning and zooming

Dragging

Dragging allows the user to move an element around on the screen. What we are going to do is make three circles that are different colors that we can move around as we desire within the element. We start by setting the width, height of the svg element as well as the radius of the circles we will make (line 7). Next, we create our svg by appending it to the body element. We also set a black line around the element so that the user knows where the borders are (lines 8-14).

The next part involves setting the colors for the circles and then creating the circles and setting all of their attributes (lines 21 – 30). Setting the drag behavior comes later, and we use the .drag() and the .on() methods t create this behavior and the .call() method connects the information in this section to our circles variable.

The last part is the use of the onDrag function. This function retrieves the position of the moving element and transform the element within the svg element (lines 36-46). This involves using an if statement as well as setting attributes. If this sounds confusing, below is the code followed by a visual of what the code does.

1

If you look carefully you will notice I can never move the circles beyond the border. This is because the border represents the edge of the element. This is important because you can limit how far an element can travel by determining the size of the elements space.

Panning and Zooming

Panning allows you to move all visuals around at once inside an element. Zooming allows you to expand or contract what you see. Most of this code is a extension  of the what we did in the previous example. The new additions are explained below.

  1. A variable called zoomAction sets the zoom behavior by determining the scale of the zoom and setting the .on() method (Lines 9-11)
  2. We add the .call() method to the svg variable as well as the .append(‘g’) so that this behavior can be used (Lines 20-21).
  3. The dragAction variable is created to allow us to pan or move the entire element around. This same variable is placed inside a .call() method for the circles variable that was created earlier (Lines 40-46).
  4. Lines 48-60 update the position of the element by making two functions. The onDrag function deals with panning and the onZzoom function deal with zooming.

Below is the code and a visual of what it does.

You can clearly see that we can move the circles individually or as a group. In addition, you also were able to see how we could zoom in and out. Unlike the first example this example allows you to leave the border. This is probably due to the zoom capability.

Conclusion

The behaviors shared here provide additional tools that you can use as you design visuals using D3.js. There are other more practical ways to use these tools as we shall see.

Realistic Teacher

Realism is another philosophy that has had a tremendous impact on education and the world in general. The modern world seems to be almost exclusively realist in terms of its worldview thanks in part to the scientific position that most individuals take on matters.

In this post, we will look briefly at the characteristics of realism. In addition, we will also examine how a teacher who believes in realism may approach teaching and realism’s impact on the broader educational process.

Background

Just as Plato was reacting to the change that was surrounding him when he developed his views on idealism, his pupil Aristotle react to idealism by proposing realism. Realism states that objects we perceive with our senses are independent of our mind. In other words, what see exist independently of us and our mind.

However, realism is not a rejection of idealism but in many ways an extension of it. Aristotle thought that everything was made of a combination of form and matter. Form was similar to the ideals of Plato’s idealism and matter was the new contribution that Aristotle was making which is a focus on the material aspect of an object. Form or ideas can exist without matter, such as the ideal or form democracy. Yet matter cannot exist with a form, such as a physical chair with the idea or form of a chair.

Aristotle further proposed that studying the world or matter would lead to a better understanding of universal ideas. This concept has had a strong impact on research in the development of inductive methodology also known as the scientific method.

Philosophical Implications

Reality as seen through idealism is the physical world. The world is similar to a giant machine in which humans are both passively acted upon and actively influencing as well. There are also natural laws that govern the physical world that can be discovered through observation.

Knowledge is gained only through the senses. Something is true because  it was observed. The natural law is within the reality of the natural world and the realist is looking for this through specific examples. This inductive process helps the realist to understand the world around him. In many ways, the Natural Law of the realist is the Absolute Self of the idealist. The difference is in how each is discovered. The idealist thinks about the Absolute Self and knows through intuition that there is an external standard. The realist observes the Natural Law with is senses which confirms the Natural Law’s reality.

Natural Law also extends into the realm of ethics. It is through observing nature and the world that what is right and wrong, beautiful and ugly can be determined according realism. In the Declaration of Independence, Thomas Jefferson  alludes to realism when he speaks of “inalienable rights.” In other words, Jefferson was proposing that some of the rights of man are obvious if one examines the world in which they live.

Realism and Education

A realistic teacher stresses that students learn through their senses. This involves teaching methodologies that have students doing and experiencing things rather than just listening. This can include such activities as field trips, group work, projects etc.

On a darker side, a realist teacher may believe that students are a product of their environment. This has been interpreted as meaning that students do not truly have choice as they are simple responding to the stimuli in their environment. This has lead to a push in education for a focus on behaviorism and even classical conditioning. Furthermore, most learning objectives are behaviorist in nature because a teacher can “see” a behavior which is evidence that the student can do something.  Off course, this has clash with cognitivism (idealism in the 20th century) which focuses on the mind rather than the behavior.

The teacher’s role is to provide sound information about the reality of the physical world and the Natural Law. This is further supported by a focus on math and science, which today is viewed as a focus on STEM majors. One thing all STEM majors have in common is a focus on what can be seen and a disinterest in the realm of ideas and the highly theoretical. Critical thinking is focus almost exclusively on  problem solving and never for the development of an opinion. What really matters are facts and not so much what people think about them.

With the focus on the senses, one thing the teacher and the students will notice is that the world is in a constant state of change. This has led to a rejection of a permanent Natural Law due to the ephemeral quality of reality.

Conclusion

Realism is the primary worldview of education  today. Seeing is believing as the saying goes. Almost nothing is taken seriously unless there is clear observable evidence to support it. Of course, many people believe that feelings and personal experience counts as evidence. This is because feelings and personal experience have actual occurred in the individual person’s life.

Intro to Interactivity with D3.js

The D3.js provides many ways in which the user can interact with visual data. Interaction with a visual can help the user to better understand the nature and characteristics of the data, which can lead to insights. In this post, we will look at three basic examples of interactivity involving mouse events.

Mouse events are actions taken by the browser in response to some action by the mouse. The handler for mouse events is primarily the .on() method. The three examples of mouse events in this post are listed below.

  • Tracking the mouse’s position
  • Highlighting an element based on mouse position
  • Communicating to the user when they have clicked on an element

Tracking the Mouses’s Position

The code for tracking the mouse’s position is rather simple. What is new is Is that we need to create a variable that appends a text element to the svg element. When we do this we need to indicate the position and size of the text as well.

Next, we need to use the .on() method on the svg variable we created. Inside this method is the type of behavior to monitor which in this case is the movement of the mouse. We then create a simple way for the browser to display the x, y coordinates.  Below is the code followed by the actual visual.

1.png

You can see that as the mouse moves the x,y coordinates move as well. The browser is watching the movement of the mouse and communicating this through the changes in the coordinates in the clip above.

Highlighting an Element Based on Mouse Position

This example allows an element to change color when the mouse comes in contact with it. To do this we need to create some data that will contain the radius of four circles with their x,y position (line 13).

Next we use the .selectAll() method to select all circles, load the data, enter the data, append the circles, set the color of the circles to green, and create a function that sets the position of the circles (lines 15-26).

Lastly, we will use the .on() function twice. Once will be for when the mouse touches the circle and the second time for when the mouse leaves the circle. When the mouse touches a circle the circle will turn black. When the mouse leaves a circle the circle will return to the original color of green (lines 27-32). Below is the code followed by the visual.

1

Indicating when a User Clicks on an Element

This example is an extension of the previous one. All the code is the same except you add the following at the bottom of the code right before the close of the script element.

.on('click', function (d, i) {

alert(d + ' ' + i);

});

This .on() method has an alert inside the function. When this is used it will tell the user when they have clicked on an element and will also tell the user the radius of the circle as well what position in the array the data comes from. Below is the visual of this code.

Conclusion

You can perhaps see the fun that is possible with interaction when using D3.js. There is much more that can be done in ways that are much more practical than what was shown here.

Idealistic Teacher

Idealism is an ancient philosophy that had a strong influence on education through the 20th century. Recently, this position has been overshadowed by realism, however, the influence of idealism can still be felt in education to this day. In this post, we will describe idealism, explain the implications, and examined how an idealistic teacher views education.

Description

Idealism is focus on reality as consisting of ideas, the mind and self. In other words, the mind makes the material world rather than the other way around as found in realism. Plato is the primary author of this philosophy.

The context of Plato’s life was one of change. This was during the time of the Persian Wars in which Greece, Athens in particular, did remarkable well. War naturally brings new ideas to both countries which was leading to changes. In addition, there was a push for individualism from a group of philosophers known as the sophists which was straining the communal culture of Athens.

Some have stated that Plato’s idealism was a reaction against this threat of change. Truth for Plato was permanent and unchanging. Since the world was changing, there could be no truth in this world. Truth must be found somewhere else. The real truth was found in the world of ideas a place that was beyond the senses used in this world.

Plato has rather negative views towards the senses. In his “Allegory of the Cave”, Plato essentially asserts that people who go by their senses are chain and trapped inside a cave of ignorance where they are bound to watch shadows of reality. Those who break free from these chains are those who have gone beyond their senses and use their intellect to reach the world of ideas. Naturally, only an elite handful of chosen ones or philosopher kings are able to do this.

Philosophical Implications

For idealist, the source of knowledge comes from intuition (knowing without conscious thought), revelation (knowing through supernatural encounters), and rationalism (knowing through conscious thought). What is important here is what is missing, which is empiricism (knowledge through the senses). Idealist do not require empirical verification of what is true. In the world today, this is almost laughable but was a core component of education for centuries.

Ethically, idealism emphasis a belief in an external ethical standard to man. Man cannot be the one to decide what is right or wrong. Instead, morals are determined by the world of ideas through the intellect. There is something called the Absolute self that the individual self is trying to imitate. This Absolute Self is considered by many to be God as seen from a christian perspective. Again this is something that would not be considered seriously by many educators.

There is an eternal consistency to truth for idealist.  Something is true when it fits with the harmony of the universe. Even art must make sense and must be used in a way that is consistent the perfect form of the world of ideas. This explains the sonority of early forms of music that have been lost gradually over time.

Idealism and Education

An idealistic teacher is going to focus on the development of the students mind. There is a constant striving for perfection in study of various subjects. Speaking of subjects, the curriculum consist primarily of the humanities and math. History and literature help students to see what is ideal for humans and the study of math is powerful because of its universal nature along with it being a self-evidently true. Generally, any subject that brings students into contact with ideas rather than things should be considered for the curriculum

The teacher’s responsibility is to pass their knowledge of the ultimate reality to the student as the teacher has more experience in this and the Absolute Self. Therefore, the teacher is an example for the student. Knowledge is seen as something that is transferred from the teacher to the student either verbally or writing. This implies that lecturing and direct instruction are key methodologies.

One of the more shocking positions of the idealistic teacher is that the school is not an agent of change. The idealistic teacher and the idealistic school do not train and educate “change agents”. Rather, since absolute truth is unchanging the school should natural reflect an unchanging nature and support the status quo. Anyone familiar with education in universities today would find this difficult to accept.

Conclusion

With focus on an other worldly perfect standard,  idealism is strongly out of place in a world that is governed or perhaps controlled by what they see and experience. Whenever people try to appeal to some sort of unqualified standard it is looked upon almost with ridicule. The exception seems to be when people share an emotional objection to something. Feelings have replaced some form of ethereally standard because emotions are experienced and felt rather than thought about.

The overemphasis on ideals is perhaps the weakness of idealism. Plato thought that people who only rely on their senses were trapped in a cave and unaware of true reality. However, the same can be said of a person who is trapped in the world of ideas. The person who is truly free is the one who can move between the senses and the mind or who can move between the reality of t ideas and physical world. Moving between these positions provides a flexible that neither has by itself.

Tweening with D3.js

Tweening is a tool that allows you to tell D3.js how to calculate attributes during transitions without keyframes tracking. The problem with keyframes tracking is that it can develop performance issues if there is a lot of animation.

We are going to look at three examples of the use of tweening in this post. The examples are as follows.

  • Counting numbers animation
  • Changing font size animation
  • Spinning shape animation

Counting Numbers Animation

This simple animation involves using the .tween() method to count from 0 to 25. The other information in the code determines the position of the element, the font-size, and the length of the animation.

In order to use the .tween()  method you must make a function. You first give the function a name followed by providing the arguments to be used. Inside the function  we indicate what it should do using the .interpolateRound() method which indicates to d3.js to count from 0 to 25. Below is the code followed by the animation.

1

You can see that the speed of the numbers is not constant. This is because we did not control for this.

Changing Font-Size Animation

The next example is more of the same. This time we simply make the size of a text change. TO do this you use the .text() method in your svg element. In addition, you now use the .styleTween() method. Inside this method we use the .interpolate method and set arguments for the font and font-size at the beginning and the end of the animation. Below is the code and the animation1

Spinning Shape Animation

The last example is somewhat more complicated. It involves create a shape that spins in place. To achieve this we do the following.

  1. Set the width and height of the element
  2. Set the svg element to the width and height
  3. Append a group element to  the svg element.
  4. Transform and translate the g element in order to move it
  5. Append a path to the g element
  6. Set the shape to a diamond using the .symbol(), .type(), and .size() methods.
  7. Set the color of the shape using .style()
  8. Set the .each() method to follow the cycle function
  9. Create the cycle function
  10. Set the .transition(), and .duration() methods
  11. Use the .attrTween() and use the .interpolateString() method to set the rotation of the spinning.
  12. Finish with the .each() method

Below is the code followed by the animation.

1

This animation never stops because we are using a cycle.

Conclusion

Animations can be a lot of fun when using d3.js. The examples here may not be the most practical, but they provide you with an opportunity to look at the code and decide how you will want to use d3.js in the future.

Intro to Animation with D3.js

This post will provide an introduction to animation using D3.js. Animation simply changes the properties of the visual object over time. This can be useful for help the viewer of the web page to understand key features of the data.

For now we will do the following in terms of animation.

  • Create a simple animation
  • Animate multiple properties
  • Create chained transitions
  • Handling Transitions

Create a Simple Animation

What is new for us in terms of d3.js code for animation is the use of the .transition() and .duration() methods. The transition method provides instructions on how to changing a visual attribute over time. Duration is simply how long the transition takes.

In the code below, we are going to create a simply black rectangle that will turn white and disappear on the screen. This is done by appending an svg that contains a black rectangle into the body element and then have that rectangle turn white and disappear.

1

1.gif

This interesting but far from amazing. We simply change the color  or animated one property. Next, we learn how to animate more than one property at a time.

Animating Multiple Properties at Once

You are not limited to only animating one property. In the code below we will change the color will have the rectangle move as well. This id one through the x,y coordinates to the second .attr({}) method. The code and the animation are below.

12

You can see how the rectangle moves from the top left to the bottom right while also changing colors from black to white thus disappearing. Next, we will look at chained transitions

Chained Transitions

Chained transitions involves have some sort of animation take place. Followed by a delay and then another animation taking place. In order to do this you need to use the .delay() method. This method tells the  browser to wait a specify number of seconds before doing something else.

In our example, we are going to have our rectangle travel diagonally down while also disappearing only tot suddenly travel up while changing back to the color of black. Below is the code followed by the animation.

13

By now you are starting to see that the only limit to animation in d3.js is your imagination.

Handling Transitions

The beginning and end of a transition can be handle by a .each() method. This is useful when you want to control the style of the element at the beginning and or end of a transition.

In the code below, you will see the rectangle go from red, to green, to orange, to black, and then to gray. At the same time the rectangle will move and change sizes. Notice careful the change from red to green and form black to gray are controlled by .each() methods.

11

Conclusion

Animation is not to only be used for entertainment. When developing visualizations, an animation should provide additional understanding of the content that you are trying to present. This is important to remember so that d3.js does not suffer the same fate as PowerPoint in that people focus more on the visual effects rather than the content.