mydata=Object.assign(newMap(csv_data),{title:["Female population density in each district"]})
md`# Linear Scale (Unclassed)`
d3.min(femalepct)
d3.max(femalepct)
chart(femalepct)
//Uses raw data. Takes the minimum value and maximum value. Define a colour to each min and max value the rest value,in between, will be interpolated and a color will be assogned to them in a sequestration manner. The classification is named "unclassed" and "d3.scaleLinear()" will create the unclassed map. The domain is entered which is the input value here "d3.extent(femalepct)" takes the min and max value in the data set. The range defines the no. of classes which is depicted by the no. of visual variables which is color in this case. The visual variable is given to the min and max value and the rest of the values are interpolated by itself.//
unclassed=d3.scaleLinear()
.domain(d3.extent(femalepct))
.range(["#e0ecf4","#8856a7"])
chart(numericSort(femalepct),unclassed)
//Colours are chosen through colorbrewer.org. The selection depends on the type of data you want to map. Is it ordinal, binary, sequential or divergent. Here the range is the no. of classes which is determined by the no. of colours input. If same colors are to be input for each classification. You can create a name for the list of colors. So instead of repeating each colour you can enter the name and that will have the list of colors embedded in it//
bupu=["#e0ecf4","#9ebcda","#8856a7"]
md`# Quantile Classification`
//Quantile data is rank-ordered and puts equal number of observation in each bin. Name the classification and use "d3.scaleQuantile() to create a quantile map the domain the add the femalepct array. Define the range. It will chart the femalepct in quantile function//
quantile=d3.scaleQuantile()
.domain(femalepct)
.range(bupu)
chart(numericSort(femalepct),quantile)
md`# Jenks Natural Breaks Classification`
//Natural breaks is to minimise the difference within classes and maximize the the difference between classes. In this the commande gives you the natural breaks depending on the length/class you define. First naturalbreaks are identified. Here "ckmeans" clustering of the input data and the class - here defined as the colour length, which is another way of deterining no. of classes in observable. Then the classification is name "jenks" and in the domain the input value is naturalbreaks and the range is defined in this case "bupu" because the list was already created//
////Equal internal is the width that each class occupies along the number line or the each class occupies the same steps along the no. line. Steps are decided by dividing the range of the data by the number of class. The upper limit is detemined by adding the class interval to the lowest value in the data. Here the range of my data is .47 and divide that by the no. of class = 3, which gives me = .15. I add .15 to the lowest value which is .05 = .2, which is now the upper limit for class/bin 1. add .15 to .2 = .35, which is the upper limit for my class 2. Add .15 to .32 = .50 which should be the upper limit for class 3 but since I have values till .52 my upper limit for my last class ends at .53.//
// On observale you name the classification method in this case 'threshold' which is manual equal interval."d3.scale.Threshold()" will create the threshold map - this is the code, which will take the input of value and the colour and map them over each other. Domain is the values of your class, in this case the upper limit of your bins/classes. The square brackets makes it a list of values. No. of classes are defined by the no. of visual variables meantioned in the range. If you need three classes then mention three colors/visual variables and so on.//
threshold=d3.scaleThreshold()
.domain([0.20,0.35,0.53])
.range(bupu)
chart(numericSort(femalepct),threshold)
//No. of classes are determined by understandin the goodness of absolute deviatoion (GADF). How different is the value of that observation from the median of that class and from the difference of the other class and the entire data set as well. GADF = 1 - (The sum of absolute deviation of the class median)'(sum of absolute deviation from the entire data set). Comparing how different the observation is from the median of the entire data set. Divide the class median to the deviation of the entire data set. FOr each class you get a percentage which is the goodness of absolute deviation fit. The sum of absolute deviation from the class median should be minimum. Which ever class break has the mimimum that is how the No. of classes are determined.//
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.