plotly / plotly/plotly.R

transforms filter breaks with one observation

オープン
#2,173 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
R
スター
2.7k
フォーク
641
PR マージ指標
30日以内にマージされた PR はありません

説明

Hi,

Theres an issue with the transform filter if there is only one observation. It just returns the chart axis. Below is a code to reproduce the issue.

library(data.table)
library(plotly)

# Transforms does not work if there is only one observation
x.data_exp <- data.table(Test = 'a', Exposure = 1)

plt <- plot_ly(height=400, transforms=list(list(type='filter', target=~Exposure, operation='>', value="-1"))) %>%
              add_bars(data = x.data_exp, x=~Test, y = ~Exposure) %>%
              layout(updatemenus = list(list(type='buttons', active=0, x=1.08, y=-0.1, xanchor='left', yanchor='bottom', direction='down', 
                                             buttons=list(
                                               list(label='all', method='restyle', args=list('transforms[0].value','-1')),
                                               list(label='1pc+', method='restyle', args=list('transforms[0].value','0.01')),
                                               list(label='3pc+', method='restyle', args=list('transforms[0].value','0.03'))
                                             ))))

I looked into the HTML and there is a part in the json data where "target":1. If you change this to "target":[1] the chart works as intended. So if there is only one observation maybe its outputting a scaler when it should be an array.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<style>body{background-color:white;}</style>
<script src="lib/htmlwidgets-1.5.4/htmlwidgets.js"></script>
<script src="lib/plotly-binding-4.10.0/plotly.js"></script>
<script src="lib/typedarray-0.1/typedarray.min.js"></script>
<script src="lib/jquery-1.11.3/jquery.min.js"></script>
<link href="lib/crosstalk-1.0.0/css/crosstalk.css" rel="stylesheet" />
<script src="lib/crosstalk-1.0.0/js/crosstalk.min.js"></script>
<link href="lib/plotly-htmlwidgets-css-2.5.1/plotly-htmlwidgets.css" rel="stylesheet" />
<script src="lib/plotly-main-2.5.1/plotly-latest.min.js"></script>

</head>
<body>
<div id="htmlwidget_container">
  <div id="htmlwidget-076f9323fea045959323" style="width:100%;height:400px;" class="plotly html-widget"></div>
</div>
<script type="application/json" data-for="htmlwidget-076f9323fea045959323">{"x":{"visdat":{"1628140951fe":["function () ","plotlyVisDat"],"16285be3752d":["function () ","data"]},"cur_data":"16285be3752d","attrs":{"16285be3752d":{"transforms":[{"type":"filter","target":{},"operation":">","value":"-1"}],"alpha_stroke":1,"sizes":[10,100],"spans":[1,20],"x":{},"y":{},"type":"bar","inherit":true}},"layout":{"height":400,"margin":{"b":40,"l":60,"t":25,"r":10},"updatemenus":[{"type":"buttons","active":0,"x":1.08,"y":-0.1,"xanchor":"left","yanchor":"bottom","direction":"down","buttons":[{"label":"all","method":"restyle","args":["transforms[0].value","-1"]},{"label":"1pc+","method":"restyle","args":["transforms[0].value","0.01"]},{"label":"3pc+","method":"restyle","args":["transforms[0].value","0.03"]}]}],"xaxis":{"domain":[0,1],"automargin":true,"title":"Test","type":"category","categoryorder":"array","categoryarray":["a"]},"yaxis":{"domain":[0,1],"automargin":true,"title":"Exposure"},"hovermode":"closest","showlegend":false},"source":"A","config":{"modeBarButtonsToAdd":["hoverclosest","hovercompare"],"showSendToCloud":false},"data":[{"transforms":[{"type":"filter","target":1,"operation":">","value":"-1"}],"x":["a"],"y":[1],"type":"bar","marker":{"color":"rgba(31,119,180,1)","line":{"color":"rgba(31,119,180,1)"}},"error_y":{"color":"rgba(31,119,180,1)"},"error_x":{"color":"rgba(31,119,180,1)"},"xaxis":"x","yaxis":"y","frame":null}],"highlight":{"on":"plotly_click","persistent":false,"dynamic":false,"selectize":false,"opacityDim":0.2,"selected":{"opacity":1},"debounce":0},"shinyEvents":["plotly_hover","plotly_click","plotly_selected","plotly_relayout","plotly_brushed","plotly_brushing","plotly_clickannotation","plotly_doubleclick","plotly_deselect","plotly_afterplot","plotly_sunburstclick"],"base_url":"https://plot.ly"},"evals":[],"jsHooks":[]}</script>
<script type="application/htmlwidget-sizing" data-for="htmlwidget-076f9323fea045959323">{"viewer":{"width":"100%","height":400,"padding":0,"fill":false},"browser":{"width":"100%","height":400,"padding":0,"fill":false}}</script>
</body>
</html>

Thanks,
Andrew

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

提供された R の再現コードから始め、観測値が 1 つの場合に変換対象について生成される HTML/JSON を調べます。singleton の対象がどのようにシリアライズされるかを追跡し、対象が配列として表現された状態でチャートが正しくレンダリングされることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, r
領域
data-visualization
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。