Skip to content

Latest commit

 

History

History

readme.md

Funnel Chart

Funnel charts are useful for conversion events or cohort analysis, such as sales cycles.

Files

The following scripts are used in this chapter:

  • simple_funnel.py
  • stack_funnel.py
  • simple_funnelarea.py

Pacakges Needed

This chapter requires the following packages for the scripts used:

  • Pandas
  • Plotly

Data Used

This chapter may use the following data from the Data folder:

  • ecom_funnel.csv

Syntax

Data

Data is a list to store either go.Funnel() or go.Funnelarea(). The difference... Please note that x accepts facts or numerics values, while y accepts attribute values or categorical values. Swapping x and y will lead to unexpected behaviour!

go.Funnel()

go.Funnel() has the following parameters:

  • x: The numeric value of the attribute
  • y: A categorical value
  • name: Category, which will be used for identifying the stacked funnel
  • marker: Setting for the funnel bar
    • color: The colour of the area of each attribute
    • line: The setting for the line
      • width
      • line
    • connector: The setting for the connector between each funnel bar
      • line
        • color
        • dash
  • textposition: Text position for y, it can be:
    • inside
    • outside
    • auto
    • none
  • textinfo: Determines which trace information appear on the graph, it can be:
    • text
    • value
    • current path
    • percent root
    • percent entry
    • percent parent
    • Or any combination of them, simply put a + sign between the values above without white space in between
  • hoverinfo: What information to be displayed when user hover over the coloured area, all the options are:
    • percent
    • label+percent
    • label
    • name

go.Funnelarea()

Note: go.Funnelarea() uses value and text! Instead of x and y

go.Funnelarea() has the following parameters:

  • value: The numeric value of the attribute
  • text: A categorical value (Shown on funnel bars)
  • labels: Categorical values (Shown on legend)
  • marker: Setting for the funnel bar
    • color: The colour of the area of each attribute
    • pattern: Setting on how to fill the funnel bars, such as full filled or striped filled
    • line: The setting for the line
      • width
      • line
    • connector: The setting for the connector between each funnel bar
      • line
        • color
        • dash
  • textposition: Text position for y, it can be:
    • inside
    • outside
    • auto
    • none
  • textinfo: Determines which trace information appear on the graph, it can be:
    • text
    • value
    • current path
    • percent root
    • percent entry
    • percent parent
    • Or any combination of them, simply put a + sign between the values above without white space in between
  • hoverinfo: What information to be displayed when user hover over the coloured area, all the options are:
    • percent
    • label+percent
    • label
    • name

Example 1 - Simple Funnel Chart

fig = go.Figure(go.Funnel(
    y = df['stage'],
    x = df['count'])
)

Example 2 - Stacked Funnel Chart

data = []
for shop in df['shop'].unique():
	df_temp = df[df['shop']==shop]
	data.append(go.Funnel(
		name = shop,
	    y = df_temp['stage'],
	    x = df_temp['count'])
	)

Example 3 - Simple Funnel Area



Use text if you want attribute and values on funnel bars.

fig = go.Figure(go.Funnelarea(
    text = df['stage'], # Text displayed on funnel bars
    values = df['count'])
)



Use labels if you do not want attribute on funnel bars, but on legned. The values will still stated on funnel bars unless you turn it off.

fig = go.Figure(go.Funnelarea(
    labels = df['stage'], # Text displayed only in legend
    values = df['count'])
)

Reference

Plotly Documentation Funnel Charts