mirror of
https://github.com/agdamsbo/FreesearchR.git
synced 2025-12-16 09:32:10 +01:00
43 lines
15 KiB
Markdown
43 lines
15 KiB
Markdown
# Add sparkline to datagrid
|
|
|
|
Add sparkline to datagrid
|
|
|
|
## Usage
|
|
|
|
``` r
|
|
add_sparkline(
|
|
grid,
|
|
column = "vals",
|
|
color.main = "#2a8484",
|
|
color.sec = "#84EF84"
|
|
)
|
|
```
|
|
|
|
## Arguments
|
|
|
|
- grid:
|
|
|
|
grid
|
|
|
|
- column:
|
|
|
|
clumn to transform
|
|
|
|
## Value
|
|
|
|
datagrid
|
|
|
|
## Examples
|
|
|
|
``` r
|
|
grid <- mtcars |>
|
|
default_parsing() |>
|
|
overview_vars() |>
|
|
toastui::datagrid() |>
|
|
add_sparkline()
|
|
grid
|
|
|
|
|
|
|
|
{"x":{"nrow":11,"ncol":7,"data":[["numeric","factor","numeric","numeric","numeric","numeric","numeric","logical","logical","factor","factor"],["numeric","factor","numeric","numeric","numeric","numeric","numeric","logical","logical","factor","factor"],["mpg","cyl","disp","hp","drat","wt","qsec","vs","am","gear","carb"],[0,0,0,0,0,0,0,0,0,0,0],[1,1,1,1,1,1,1,1,1,1,1],[25,3,27,22,22,29,30,2,2,3,6],[[21,21,22.8,21.4,18.7,18.1,14.3,24.4,22.8,19.2,17.8,16.4,17.3,15.2,10.4,10.4,14.7,32.4,30.4,33.9,21.5,15.5,15.2,13.3,19.2,27.3,26,30.4,15.8,19.7,15,21.4],["6","6","4","6","8","6","8","4","4","6","6","8","8","8","8","8","8","4","4","4","4","8","8","8","8","4","4","4","8","6","8","4"],[160,160,108,258,360,225,360,146.7,140.8,167.6,167.6,275.8,275.8,275.8,472,460,440,78.7,75.7,71.09999999999999,120.1,318,304,350,400,79,120.3,95.09999999999999,351,145,301,121],[110,110,93,110,175,105,245,62,95,123,123,180,180,180,205,215,230,66,52,65,97,150,150,245,175,66,91,113,264,175,335,109],[3.9,3.9,3.85,3.08,3.15,2.76,3.21,3.69,3.92,3.92,3.92,3.07,3.07,3.07,2.93,3,3.23,4.08,4.93,4.22,3.7,2.76,3.15,3.73,3.08,4.08,4.43,3.77,4.22,3.62,3.54,4.11],[2.62,2.875,2.32,3.215,3.44,3.46,3.57,3.19,3.15,3.44,3.44,4.07,3.73,3.78,5.25,5.424,5.345,2.2,1.615,1.835,2.465,3.52,3.435,3.84,3.845,1.935,2.14,1.513,3.17,2.77,3.57,2.78],[16.46,17.02,18.61,19.44,17.02,20.22,15.84,20,22.9,18.3,18.9,17.4,17.6,18,17.98,17.82,17.42,19.47,18.52,19.9,20.01,16.87,17.3,15.41,17.05,18.9,16.7,16.9,14.5,15.5,14.6,18.6],[false,false,true,true,false,true,false,true,true,true,true,false,false,false,false,false,false,true,true,true,true,false,false,false,false,true,false,true,false,false,false,true],[true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,false,false,false,false,false,true,true,true,true,true,true,true],["4","4","4","3","3","3","3","4","4","4","4","3","3","3","3","3","3","4","4","4","3","3","3","3","3","4","5","5","5","5","5","4"],["4","4","1","1","2","1","4","2","2","4","4","3","3","3","4","4","4","1","2","1","1","2","2","4","2","1","2","2","4","6","8","2"]]],"colnames":["icon","class","name","n_missing","p_complete","n_unique","vals"],"options":{"columns":[{"header":"icon","name":"icon","sortable":true,"align":"left","whiteSpace":"normal","renderer":{"styles":{"wordBreak":"normal"}}},{"header":"class","name":"class","sortable":true,"align":"left","whiteSpace":"normal","renderer":{"styles":{"wordBreak":"normal"}}},{"header":"name","name":"name","sortable":true,"align":"left","whiteSpace":"normal","renderer":{"styles":{"wordBreak":"normal"}}},{"header":"n_missing","name":"n_missing","sortable":true,"align":"right","whiteSpace":"normal","renderer":{"styles":{"wordBreak":"normal"}}},{"header":"p_complete","name":"p_complete","sortable":true,"align":"right","whiteSpace":"normal","renderer":{"styles":{"wordBreak":"normal"}}},{"header":"n_unique","name":"n_unique","sortable":true,"align":"right","whiteSpace":"normal","renderer":{"styles":{"wordBreak":"normal"}}},{"header":"vals","name":"vals","sortable":true,"align":"left","whiteSpace":"normal","renderer":{"styles":{"wordBreak":"normal"},"type":"datagrid.renderer.htmlwidgets","options":{"rendered":["<div id=\"htmlwidget-d11fc4360aa0230696d7\" style=\"width:100%;height:40px;\" class=\"apexcharter html-widget\"><\/div>\n<script type=\"application/json\" data-for=\"htmlwidget-d11fc4360aa0230696d7\">{\"x\":{\"ax_opts\":{\"chart\":{\"type\":\"boxPlot\",\"sparkline\":{\"enabled\":true}},\"series\":[{\"type\":\"boxPlot\",\"data\":[{\"x\":\"1\",\"y\":[10.4,15.35,19.2,22.8,33.9]}]}],\"plotOptions\":{\"bar\":{\"horizontal\":true},\"boxPlot\":{\"colors\":{\"upper\":\"#84EF84\",\"lower\":\"#2a8484\"}}},\"yaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"xaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"colors\":[\"#2a8484\",\"#84EF84\"]},\"auto_update\":{\"series_animate\":true,\"update_options\":false,\"options_animate\":true,\"options_redrawPaths\":true,\"update_synced_charts\":false},\"sparkbox\":false,\"xaxis\":{\"min\":1,\"max\":1},\"type\":\"boxplot\"},\"evals\":[],\"jsHooks\":[]}<\/script>","<div id=\"htmlwidget-21c7483268bafca56cec\" style=\"width:100%;height:40px;\" class=\"apexcharter html-widget\"><\/div>\n<script type=\"application/json\" data-for=\"htmlwidget-21c7483268bafca56cec\">{\"x\":{\"ax_opts\":{\"chart\":{\"type\":\"bar\",\"sparkline\":{\"enabled\":true}},\"series\":[{\"name\":\"y\",\"type\":\"bar\",\"data\":[{\"x\":\"4\",\"y\":11},{\"x\":\"6\",\"y\":7},{\"x\":\"8\",\"y\":14}]}],\"dataLabels\":{\"enabled\":false},\"plotOptions\":{\"bar\":{\"horizontal\":false,\"isDumbbell\":false},\"boxPlot\":{\"colors\":{\"upper\":\"#84EF84\",\"lower\":\"#2a8484\"}}},\"tooltip\":{\"shared\":true,\"intersect\":false,\"followCursor\":true},\"grid\":{\"yaxis\":{\"lines\":{\"show\":true}},\"xaxis\":{\"lines\":{\"show\":false}}},\"yaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"xaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"colors\":[\"#2a8484\",\"#84EF84\"]},\"auto_update\":{\"series_animate\":true,\"update_options\":false,\"options_animate\":true,\"options_redrawPaths\":true,\"update_synced_charts\":false},\"sparkbox\":false,\"xaxis\":{\"min\":\"4\",\"max\":\"8\"},\"type\":\"column\"},\"evals\":[],\"jsHooks\":[]}<\/script>","<div id=\"htmlwidget-1834a22cd196f3aa03a1\" style=\"width:100%;height:40px;\" class=\"apexcharter html-widget\"><\/div>\n<script type=\"application/json\" data-for=\"htmlwidget-1834a22cd196f3aa03a1\">{\"x\":{\"ax_opts\":{\"chart\":{\"type\":\"boxPlot\",\"sparkline\":{\"enabled\":true}},\"series\":[{\"type\":\"boxPlot\",\"data\":[{\"x\":\"1\",\"y\":[71.09999999999999,120.65,196.3,334,472]}]}],\"plotOptions\":{\"bar\":{\"horizontal\":true},\"boxPlot\":{\"colors\":{\"upper\":\"#84EF84\",\"lower\":\"#2a8484\"}}},\"yaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"xaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"colors\":[\"#2a8484\",\"#84EF84\"]},\"auto_update\":{\"series_animate\":true,\"update_options\":false,\"options_animate\":true,\"options_redrawPaths\":true,\"update_synced_charts\":false},\"sparkbox\":false,\"xaxis\":{\"min\":1,\"max\":1},\"type\":\"boxplot\"},\"evals\":[],\"jsHooks\":[]}<\/script>","<div id=\"htmlwidget-28515d92cb327f90c9eb\" style=\"width:100%;height:40px;\" class=\"apexcharter html-widget\"><\/div>\n<script type=\"application/json\" data-for=\"htmlwidget-28515d92cb327f90c9eb\">{\"x\":{\"ax_opts\":{\"chart\":{\"type\":\"boxPlot\",\"sparkline\":{\"enabled\":true}},\"series\":[{\"type\":\"boxPlot\",\"data\":[{\"x\":\"1\",\"y\":[52,96,123,180,264]}]}],\"plotOptions\":{\"bar\":{\"horizontal\":true},\"boxPlot\":{\"colors\":{\"upper\":\"#84EF84\",\"lower\":\"#2a8484\"}}},\"yaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"xaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"colors\":[\"#2a8484\",\"#84EF84\"]},\"auto_update\":{\"series_animate\":true,\"update_options\":false,\"options_animate\":true,\"options_redrawPaths\":true,\"update_synced_charts\":false},\"sparkbox\":false,\"xaxis\":{\"min\":1,\"max\":1},\"type\":\"boxplot\"},\"evals\":[],\"jsHooks\":[]}<\/script>","<div id=\"htmlwidget-0caf26d4e3c00206b0c5\" style=\"width:100%;height:40px;\" class=\"apexcharter html-widget\"><\/div>\n<script type=\"application/json\" data-for=\"htmlwidget-0caf26d4e3c00206b0c5\">{\"x\":{\"ax_opts\":{\"chart\":{\"type\":\"boxPlot\",\"sparkline\":{\"enabled\":true}},\"series\":[{\"type\":\"boxPlot\",\"data\":[{\"x\":\"1\",\"y\":[2.76,3.08,3.695,3.92,4.93]}]}],\"plotOptions\":{\"bar\":{\"horizontal\":true},\"boxPlot\":{\"colors\":{\"upper\":\"#84EF84\",\"lower\":\"#2a8484\"}}},\"yaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"xaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"colors\":[\"#2a8484\",\"#84EF84\"]},\"auto_update\":{\"series_animate\":true,\"update_options\":false,\"options_animate\":true,\"options_redrawPaths\":true,\"update_synced_charts\":false},\"sparkbox\":false,\"xaxis\":{\"min\":1,\"max\":1},\"type\":\"boxplot\"},\"evals\":[],\"jsHooks\":[]}<\/script>","<div id=\"htmlwidget-da0b268a2927f570ebf3\" style=\"width:100%;height:40px;\" class=\"apexcharter html-widget\"><\/div>\n<script type=\"application/json\" data-for=\"htmlwidget-da0b268a2927f570ebf3\">{\"x\":{\"ax_opts\":{\"chart\":{\"type\":\"boxPlot\",\"sparkline\":{\"enabled\":true}},\"series\":[{\"type\":\"boxPlot\",\"data\":[{\"x\":\"1\",\"y\":[1.513,2.5425,3.325,3.65,5.25]}]}],\"plotOptions\":{\"bar\":{\"horizontal\":true},\"boxPlot\":{\"colors\":{\"upper\":\"#84EF84\",\"lower\":\"#2a8484\"}}},\"yaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"xaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"colors\":[\"#2a8484\",\"#84EF84\"]},\"auto_update\":{\"series_animate\":true,\"update_options\":false,\"options_animate\":true,\"options_redrawPaths\":true,\"update_synced_charts\":false},\"sparkbox\":false,\"xaxis\":{\"min\":1,\"max\":1},\"type\":\"boxplot\"},\"evals\":[],\"jsHooks\":[]}<\/script>","<div id=\"htmlwidget-0ed12bb554391c49c2e3\" style=\"width:100%;height:40px;\" class=\"apexcharter html-widget\"><\/div>\n<script type=\"application/json\" data-for=\"htmlwidget-0ed12bb554391c49c2e3\">{\"x\":{\"ax_opts\":{\"chart\":{\"type\":\"boxPlot\",\"sparkline\":{\"enabled\":true}},\"series\":[{\"type\":\"boxPlot\",\"data\":[{\"x\":\"1\",\"y\":[14.5,16.885,17.71,18.9,20.22]}]}],\"plotOptions\":{\"bar\":{\"horizontal\":true},\"boxPlot\":{\"colors\":{\"upper\":\"#84EF84\",\"lower\":\"#2a8484\"}}},\"yaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"xaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"colors\":[\"#2a8484\",\"#84EF84\"]},\"auto_update\":{\"series_animate\":true,\"update_options\":false,\"options_animate\":true,\"options_redrawPaths\":true,\"update_synced_charts\":false},\"sparkbox\":false,\"xaxis\":{\"min\":1,\"max\":1},\"type\":\"boxplot\"},\"evals\":[],\"jsHooks\":[]}<\/script>","<div id=\"htmlwidget-ec658d41f8c4f2d124e9\" style=\"width:100%;height:40px;\" class=\"apexcharter html-widget\"><\/div>\n<script type=\"application/json\" data-for=\"htmlwidget-ec658d41f8c4f2d124e9\">{\"x\":{\"ax_opts\":{\"chart\":{\"type\":\"bar\",\"sparkline\":{\"enabled\":true}},\"series\":[{\"name\":\"y\",\"type\":\"bar\",\"data\":[{\"x\":\"FALSE\",\"y\":18},{\"x\":\"TRUE\",\"y\":14}]}],\"dataLabels\":{\"enabled\":false},\"plotOptions\":{\"bar\":{\"horizontal\":false,\"isDumbbell\":false},\"boxPlot\":{\"colors\":{\"upper\":\"#84EF84\",\"lower\":\"#2a8484\"}}},\"tooltip\":{\"shared\":true,\"intersect\":false,\"followCursor\":true},\"grid\":{\"yaxis\":{\"lines\":{\"show\":true}},\"xaxis\":{\"lines\":{\"show\":false}}},\"yaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"xaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"colors\":[\"#2a8484\",\"#84EF84\"]},\"auto_update\":{\"series_animate\":true,\"update_options\":false,\"options_animate\":true,\"options_redrawPaths\":true,\"update_synced_charts\":false},\"sparkbox\":false,\"xaxis\":{\"min\":\"FALSE\",\"max\":\"TRUE\"},\"type\":\"column\"},\"evals\":[],\"jsHooks\":[]}<\/script>","<div id=\"htmlwidget-6b83523733b890d61edc\" style=\"width:100%;height:40px;\" class=\"apexcharter html-widget\"><\/div>\n<script type=\"application/json\" data-for=\"htmlwidget-6b83523733b890d61edc\">{\"x\":{\"ax_opts\":{\"chart\":{\"type\":\"bar\",\"sparkline\":{\"enabled\":true}},\"series\":[{\"name\":\"y\",\"type\":\"bar\",\"data\":[{\"x\":\"FALSE\",\"y\":19},{\"x\":\"TRUE\",\"y\":13}]}],\"dataLabels\":{\"enabled\":false},\"plotOptions\":{\"bar\":{\"horizontal\":false,\"isDumbbell\":false},\"boxPlot\":{\"colors\":{\"upper\":\"#84EF84\",\"lower\":\"#2a8484\"}}},\"tooltip\":{\"shared\":true,\"intersect\":false,\"followCursor\":true},\"grid\":{\"yaxis\":{\"lines\":{\"show\":true}},\"xaxis\":{\"lines\":{\"show\":false}}},\"yaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"xaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"colors\":[\"#2a8484\",\"#84EF84\"]},\"auto_update\":{\"series_animate\":true,\"update_options\":false,\"options_animate\":true,\"options_redrawPaths\":true,\"update_synced_charts\":false},\"sparkbox\":false,\"xaxis\":{\"min\":\"FALSE\",\"max\":\"TRUE\"},\"type\":\"column\"},\"evals\":[],\"jsHooks\":[]}<\/script>","<div id=\"htmlwidget-b3f7c917b6c8ff580948\" style=\"width:100%;height:40px;\" class=\"apexcharter html-widget\"><\/div>\n<script type=\"application/json\" data-for=\"htmlwidget-b3f7c917b6c8ff580948\">{\"x\":{\"ax_opts\":{\"chart\":{\"type\":\"bar\",\"sparkline\":{\"enabled\":true}},\"series\":[{\"name\":\"y\",\"type\":\"bar\",\"data\":[{\"x\":\"3\",\"y\":15},{\"x\":\"4\",\"y\":12},{\"x\":\"5\",\"y\":5}]}],\"dataLabels\":{\"enabled\":false},\"plotOptions\":{\"bar\":{\"horizontal\":false,\"isDumbbell\":false},\"boxPlot\":{\"colors\":{\"upper\":\"#84EF84\",\"lower\":\"#2a8484\"}}},\"tooltip\":{\"shared\":true,\"intersect\":false,\"followCursor\":true},\"grid\":{\"yaxis\":{\"lines\":{\"show\":true}},\"xaxis\":{\"lines\":{\"show\":false}}},\"yaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"xaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"colors\":[\"#2a8484\",\"#84EF84\"]},\"auto_update\":{\"series_animate\":true,\"update_options\":false,\"options_animate\":true,\"options_redrawPaths\":true,\"update_synced_charts\":false},\"sparkbox\":false,\"xaxis\":{\"min\":\"3\",\"max\":\"5\"},\"type\":\"column\"},\"evals\":[],\"jsHooks\":[]}<\/script>","<div id=\"htmlwidget-d258b2ee1c304ebe1664\" style=\"width:100%;height:40px;\" class=\"apexcharter html-widget\"><\/div>\n<script type=\"application/json\" data-for=\"htmlwidget-d258b2ee1c304ebe1664\">{\"x\":{\"ax_opts\":{\"chart\":{\"type\":\"bar\",\"sparkline\":{\"enabled\":true}},\"series\":[{\"name\":\"y\",\"type\":\"bar\",\"data\":[{\"x\":\"1\",\"y\":7},{\"x\":\"2\",\"y\":10},{\"x\":\"3\",\"y\":3},{\"x\":\"4\",\"y\":10},{\"x\":\"6\",\"y\":1},{\"x\":\"8\",\"y\":1}]}],\"dataLabels\":{\"enabled\":false},\"plotOptions\":{\"bar\":{\"horizontal\":false,\"isDumbbell\":false},\"boxPlot\":{\"colors\":{\"upper\":\"#84EF84\",\"lower\":\"#2a8484\"}}},\"tooltip\":{\"shared\":true,\"intersect\":false,\"followCursor\":true},\"grid\":{\"yaxis\":{\"lines\":{\"show\":true}},\"xaxis\":{\"lines\":{\"show\":false}}},\"yaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"xaxis\":{\"labels\":{\"style\":{\"colors\":\"#848484\"}}},\"colors\":[\"#2a8484\",\"#84EF84\"]},\"auto_update\":{\"series_animate\":true,\"update_options\":false,\"options_animate\":true,\"options_redrawPaths\":true,\"update_synced_charts\":false},\"sparkbox\":false,\"xaxis\":{\"min\":\"1\",\"max\":\"8\"},\"type\":\"column\"},\"evals\":[],\"jsHooks\":[]}<\/script>"],"styles":null}},"className":"datagrid-sparkline-cell","minWidth":200}],"bodyHeight":"fitToParent","draggable":false,"usageStatistics":false,"contextMenu":null,"rowHeight":"40px"},"theme":"clean","themeOptions":{"cell":{"normal":{"showHorizontalBorder":true}}},"language":"en","languageOptions":[],"filters":false,"rowAttributes":[],"validationInput":false,"dataAsInput":false,"dragInput":false},"evals":["options.columns.6.renderer.type"],"jsHooks":[]}
|
|
```
|