Skip to content

Treemaps#545

Merged
mofojed merged 4 commits intodeephaven:mainfrom
mofojed:treemap
Jul 11, 2022
Merged

Treemaps#545
mofojed merged 4 commits intodeephaven:mainfrom
mofojed:treemap

Conversation

@mofojed
Copy link
Member

@mofojed mofojed commented May 1, 2022

Snippet used for testing:

from deephaven.csv import read
from deephaven import new_table, merge, time_table
from deephaven.column import string_col, long_col, double_col
from deephaven.plot import Figure
from deephaven.constants import NULL_DOUBLE, NULL_LONG
from deephaven.plot.color import Color
​
s_and_p = read('/data/Stocks in the SP 500 Index.csv')\
    .view([
        "Symbol",
        "Description",
        "Sector=GICS_Sector.toLowerCase()",
        "MarketCap=Long.parseLong(Market_cap.replaceAll(`[$,]`, ``))"])
​
sectors = sector_items = s_and_p\
    .select_distinct(["Sector"])\
    .sort(["Sector"])
​
sector_items = sectors\
    .view([
        "Parent=`root`",
        "Label=Sector",
        "Value=(long)0",
        "Color=`#373438`",
        "Text=Sector",
        "HoverText=Sector"])
​
def heatmap_daily_perc(perc):
    if perc < -0.02:
        return '#f95d84'
    if perc < -0.01:
        return '#f37e3f'
    if perc > 0.01:
        return '#9edc6f'
    return '#fcd65b'
​
ticks = time_table('00:00:01').view("N=i").last_by()
​
stock_items = s_and_p\
    .update([
        "Perc=randomGaussian(0, 2)/100.0",
        "PercLabel=String.format(`%.1f%%`, Perc*100)"])\
    .natural_join(ticks, [])\
    .view([
        "Parent=Sector",
        "Label=Symbol",
        "Value=(long)(MarketCap*pow(1+Perc,N))",
        "Color=(String)heatmap_daily_perc(Perc)",
        "Text=PercLabel",
        "HoverText=Description + `: ` + PercLabel"])
​
items = merge([sector_items, stock_items])
​
s_and_p_tree_map = Figure().plot_tree_map(
    t = items,
    series_name = "S&P 500 Daily Change",
    hover_text_column = "HoverText",
    ids_column = "Label",
    labels_column = "Label",
    parents_column = "Parent",
    text_column = "Text",
    values_column = "Value",
    color = "Color",
).show()
​
del items, stock_items, ticks, sector_items, sectors, s_and_p

@mofojed mofojed self-assigned this May 1, 2022
mofojed added 4 commits July 6, 2022 14:19
Just hacked in on top of pie charts right now
- Set up hover text, labels, etc
- Add lodash.set to set a property from a nested path
- Added a couple unit tests
@mofojed mofojed marked this pull request as ready for review July 6, 2022 18:19
@mofojed mofojed added the enhancement New feature or request label Jul 6, 2022
@mofojed mofojed changed the title treemap Treemaps Jul 6, 2022
@mofojed mofojed requested a review from vbabich July 6, 2022 18:28
@mofojed mofojed added this to the July 2022 milestone Jul 6, 2022
@codecov
Copy link

codecov bot commented Jul 6, 2022

Codecov Report

Merging #545 (5780154) into main (a3f37ab) will decrease coverage by 0.02%.
The diff coverage is 23.25%.

@@            Coverage Diff             @@
##             main     #545      +/-   ##
==========================================
- Coverage   35.76%   35.73%   -0.03%     
==========================================
  Files         396      396              
  Lines       29183    29215      +32     
  Branches     6957     6973      +16     
==========================================
+ Hits        10436    10441       +5     
- Misses      18561    18587      +26     
- Partials      186      187       +1     
Flag Coverage Δ
unit 35.73% <23.25%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
packages/chart/src/plotly/Plotly.js 0.00% <0.00%> (ø)
packages/chart/src/ChartUtils.js 60.35% <20.00%> (-2.72%) ⬇️
packages/chart/src/FigureChartModel.js 54.81% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a3f37ab...5780154. Read the comment docs.

@mofojed mofojed merged commit 1a8bb7c into deephaven:main Jul 11, 2022
@mofojed mofojed deleted the treemap branch July 11, 2022 12:26
@github-actions github-actions bot locked and limited conversation to collaborators Jul 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request notable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants