AntoineGuillot2 / D3partitionR

R package to visualise interactively hierarchical data.
http://enhancedatascience.com/2017/09/20/d3partitionr-0-5-beta/
40 stars 7 forks source link

Renaming / Removing Root from the graph/Controlling colours #15

Open FinScience opened 7 years ago

FinScience commented 7 years ago

Hi,

I am using your package to create a visualization. However, I am not sure how to control colors,remove or rename root. It would be great if you could help me out with this.

Dataset

         Invoked_from               functionality          action  N
1: Invoked_from alpha functionality document menu      action add  1
2: Invoked_from alpha functionality document menu    action click 29
3: Invoked_from alpha functionality document menu    action close  1
4: Invoked_from alpha functionality document menu   action expand  5
5: Invoked_from alpha functionality document menu   action follow  1
6: Invoked_from alpha functionality document menu action maintain  2

d3 = D3partitionR() %>%
  add_data(pt,count = 'N',steps=c('Invoked_from','functionality','action')) %>%
  add_title('SRA') %>%
  plot()

d3

d3test

Any help would be great

AntoineGuillot2 commented 6 years ago

Agregating data to have unique sequence for the 4 variables

var_names=c('Sex','Embarked','Pclass','Survived') data_plot=titanic_data[,.N,by=var_names] data_plot[,(var_names):=lapply(var_names,function(x){data_plot[[x]]=paste0(x,' ',data_plot[[x]]) })]

color_list=c("#ffff00","#0000ff","#ff0000") names(color_list)<-c('Sex male','Sex female','Survived 0')

D3partitionR() %>% D3partitionR::add_data(data_plot,count = 'N',tooltip=c('name'),steps=c('Sex','Embarked','Pclass','Survived')) %>% set_chart_type('treemap') %>% set_legend_parameters(zoom_subset=T)%>% set_discrete_color_scale(color_list)%>% plot()