Public
Edited
Oct 24, 2022
1 fork
1 star
Insert cell
Insert cell
common_fmcg_labelled_quarter_results = FileAttachment("Common_FMCG_Labelled_Quarter_Results.csv").csv({typed:true})
Insert cell
Insert cell
bseFiltered = bse.filter(c => c.Status == "Active")
Insert cell
Insert cell
Insert cell
Insert cell
//Filter the company for the Q4 2019
companyFilteredIncome2019 = common_fmcg_labelled_quarter_results
.filter(d => d.Quarter == "Q4 2019")
.map(d => ({
Company_Name: d['Company Name'],
Total_Income: d['Total Income'],
Industry:d['Industry'],
Net_Profit:d['Net Profit Loss from Ordinary Activities after Tax']
}))
Insert cell
// Which Industry has the highest Revenue or Profit of it companies?
industryRollupParameter2019 = d3.rollups(companyFilteredIncome2019, g => d3.sum(g, x => x[revProfit]), d => d.Industry)
.sort((a,b) => d3.descending(a[1],b[1]))
Insert cell
// Which Industry has the Profit of it companies?
industryRollupNetProfit = d3.rollups(companyFilteredIncome2019, g => d3.sum(g, x => x.Net_Profit), d => d.Industry)
.sort((a,b) => d3.descending(a[1],b[1]))
Insert cell
// Which Industry has the highest Revenue of it companies?
industryRollupTotIncome = d3.rollups(companyFilteredIncome2019, g => d3.sum(g, x => x.Total_Income), d => d.Industry)
.sort((a,b) => d3.descending(a[1],b[1]))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
industryHeirarchy = d3.rollup(companyFilteredIncome2019, g => d3.sum(g, x => x.Total_Income),d => d.Industry, d => d.Company_Name)
Insert cell
scripDoma = d3.scaleOrdinal()
.domain(industryRollupParameter2019.map(d => d[0]))
.range(d3.schemeCategory10)
Insert cell
scripDoma.unknown('lightgreen');
Insert cell
industryPack = d3.pack()
.size([400,400])
.padding(2)
Insert cell
Insert cell
//Create the Root with the Values
industryHeirarchyRoot.sum(d => d[1])
Insert cell
Insert cell
Insert cell
industryHeirarchyPack.descendants()
Insert cell
cirPack = {
const svg = d3.create('svg')
.attr('width',850)
.attr('height',550)

const text = svg.append('text')
.attr('transform','translate(100,25)')
.text('The circle Packing Industries and Companies')
const tip = svg.append('text')
.attr('transform','translate(100,50)')
.attr('visibility','hidden')
.attr('id','cirDetail')

const g = svg.append('g')
.attr('transform',`translate(50,100)`)
const map = g.selectAll('g')
.data(industryHeirarchyPack.descendants())
.join('g')
.attr('transform', d => `translate(${d.x},${d.y})`)
{
return svg.node()
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { aq, op } from '@uwdata/arquero'
Insert cell
temp = aq.from(common_fmcg_labelled_quarter_results)
Insert cell
pivotedCompanyMapAq = temp
.groupby('Company Name')
.pivot('Quarter', 'Total Income')
.objects() // Sometime all it takes is simple 's'
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

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.
Learn more