Compare commits
324 Commits
Author | SHA1 | Date |
---|---|---|
pvictor | 5f8389ff34 | |
pvictor | 85708897b0 | |
pvictor | 9200d918ad | |
pvictor | 58723475cb | |
pvictor | b313b45989 | |
pvictor | 7e4189366e | |
pvictor | 3a3a10369f | |
pvictor | d0fac7c1ee | |
pvictor | 1ac176f30c | |
pvictor | 624ab8b901 | |
pvictor | 57733add33 | |
pvictor | c1560fc9c5 | |
dependabot[bot] | e68f20930c | |
pvictor | 6cff8a9f67 | |
pvictor | 1d94f9d4a6 | |
pvictor | eb228597d8 | |
pvictor | bbda86de93 | |
pvictor | 467be227fc | |
pvictor | 11d244e992 | |
pvictor | 5587cdbef4 | |
pvictor | be187e37f1 | |
Victor Perrier | 34aee9bc96 | |
Victor Perrier | 44ead44178 | |
Victor Perrier | 9baa753c3f | |
pvictor | 24c552ea68 | |
pvictor | b7ed86e556 | |
pvictor | 7705b91e88 | |
pvictor | 70204162f4 | |
dependabot[bot] | 11c6938935 | |
pvictor | f83cb879a8 | |
pvictor | de477fec66 | |
pvictor | 896998074e | |
pvictor | b69b7b7b4d | |
pvictor | 1b6a57df3a | |
pvictor | 34d73e81ee | |
pvictor | 7d32381a65 | |
pvictor | 2174c8b238 | |
Victor Perrier | 1fe6e97eee | |
pvictor | cacfcde3ce | |
pvictor | 4ef564e605 | |
Victor Perrier | 23dbb5e869 | |
pvictor | 4cbf760e29 | |
pvictor | 1e3ad8fcc8 | |
pvictor | 162b7874d6 | |
pvictor | ef470d1889 | |
pvictor | 69a343fca0 | |
pvictor | e848debf0a | |
pvictor | f50e0064c2 | |
pvictor | d0d234baee | |
pvictor | a9914aa702 | |
dependabot[bot] | f45efa78fd | |
pvictor | bc22af7e0c | |
pvictor | 7a959cb461 | |
pvictor | ea4abf2779 | |
Victor Perrier | aa6d74a38d | |
dependabot[bot] | eb2a82746e | |
pvictor | 50fac13d51 | |
pvictor | 3f1bb5048e | |
pvictor | 036244b981 | |
pvictor | f7de6805db | |
pvictor | 64ca1925c1 | |
pvictor | 50926f0570 | |
pvictor | 67a97cdf5f | |
pvictor | 314baa5cd9 | |
pvictor | dddd472c1f | |
pvictor | 4f4142211b | |
pvictor | f4215fdf37 | |
pvictor | 301051c297 | |
pvictor | 45f29fca2e | |
pvictor | c717358068 | |
pvictor | 0f7ec49342 | |
pvictor | fe45564f6a | |
pvictor | 647f4ab9c8 | |
pvictor | ace2508e89 | |
pvictor | a0d0616009 | |
pvictor | 47381fcfda | |
pvictor | d14e36d22b | |
pvictor | 14484602f7 | |
pvictor | 017b84f35c | |
pvictor | 05494785ae | |
Victor Perrier | c0672ba655 | |
pvictor | 8bda434fa0 | |
pvictor | 01c1c8ed2d | |
pvictor | 090f3d2d37 | |
pvictor | 7b9df92ee7 | |
pvictor | f670771a22 | |
pvictor | 027c5bc16f | |
pvictor | 4178c633de | |
pvictor | 705f9f971a | |
pvictor | 3c861bec58 | |
pvictor | 251df70b2b | |
pvictor | cefba791f7 | |
pvictor | dfd9bb07af | |
pvictor | ea494e899d | |
pvictor | a05d2db20d | |
pvictor | 56ce243b0f | |
pvictor | 2c18c1b329 | |
pvictor | 8fa55a9f53 | |
pvictor | 28931d2887 | |
pvictor | 36a537a79b | |
pvictor | 1e42e587af | |
pvictor | e3efecf7f8 | |
pvictor | e2af5eee09 | |
pvictor | 4352d95f97 | |
pvictor | 14b2a2cc74 | |
pvictor | bfc50ca080 | |
pvictor | 1d54804e04 | |
pvictor | 9efca10228 | |
pvictor | 3e85bd477a | |
pvictor | 63db3566fb | |
pvictor | 552675f0a2 | |
pvictor | 318690ff06 | |
pvictor | e76a129702 | |
pvictor | 83d6926fe6 | |
pvictor | 67680c48f3 | |
pvictor | f91a6c69c6 | |
pvictor | 2d9b9ff631 | |
pvictor | 1e74d6857e | |
pvictor | 5ac0087461 | |
pvictor | cf81488f56 | |
pvictor | 1aac748555 | |
pvictor | 3d55188a00 | |
pvictor | 5dc9271701 | |
Victor Perrier | 4b82ddb922 | |
pvictor | 55e19f60c4 | |
pvictor | 5679b7cdba | |
pvictor | 175271d01a | |
pvictor | 730d6651a0 | |
pvictor | bdf6e19597 | |
pvictor | 3c252c9f20 | |
pvictor | 90aac1901b | |
pvictor | 901e67494d | |
pvictor | 88f926b788 | |
pvictor | b17ad7b046 | |
pvictor | 69104bb6a9 | |
pvictor | 12c02b5336 | |
pvictor | 9a1c257977 | |
pvictor | dea01b7e8d | |
Victor Perrier | 5e3be7068a | |
pvictor | 9a56de4d4e | |
pvictor | 898ff0f729 | |
pvictor | c7fcaab4bd | |
Victor Perrier | 35472372cd | |
pvictor | 7131c8fd00 | |
pvictor | 0bd9dda5a7 | |
pvictor | 47ef3d1b3e | |
pvictor | 88956c582b | |
pvictor | 19d25ee1fd | |
pvictor | c27a0feba5 | |
pvictor | 7091f5da01 | |
pvictor | eb01583f51 | |
pvictor | 639450cb7d | |
pvictor | 585cbd0bfd | |
pvictor | 971388c4f1 | |
pvictor | 1bca00e544 | |
pvictor | ff7b5ba7d9 | |
pvictor | 70eb611091 | |
pvictor | de3d9c1a9f | |
pvictor | 0cadab8b51 | |
pvictor | 716e96b16c | |
pvictor | 4470756c38 | |
pvictor | 67f09cd048 | |
pvictor | ffefe8d394 | |
pvictor | 2a261e1a91 | |
pvictor | 727c9ed3fe | |
pvictor | 5560ae0b31 | |
pvictor | 805e441499 | |
pvictor | 9fb6a7b341 | |
pvictor | 02560a95a0 | |
pvictor | 315001e883 | |
pvictor | 11a5037276 | |
pvictor | be7b3d4061 | |
pvictor | c7d037eea8 | |
pvictor | c06574ba3b | |
pvictor | 6b23a4a9ab | |
pvictor | dbeb316074 | |
pvictor | 7e64d25710 | |
pvictor | cd38b5c5e5 | |
pvictor | abad2b837c | |
pvictor | 74512ce454 | |
pvictor | af5670a0b0 | |
pvictor | 53e7addd8b | |
pvictor | eecfb61154 | |
pvictor | 3bd31007f5 | |
pvictor | 7a20be6e20 | |
pvictor | faa07879ef | |
pvictor | 9481c21d43 | |
pvictor | 5aff3524a2 | |
pvictor | b487e92b70 | |
pvictor | 5be96dcd77 | |
pvictor | d44581dc2a | |
pvictor | 53cc0cdb32 | |
pvictor | 145c48f3b7 | |
pvictor | bd179f978b | |
pvictor | 8ce6afc5f5 | |
pvictor | 296797c353 | |
pvictor | 273936b151 | |
pvictor | 31f824b5d5 | |
pvictor | 9d5158c024 | |
pvictor | 7712ab2e64 | |
pvictor | e6ae2ac8c8 | |
pvictor | d25bf7f7d7 | |
pvictor | 47d8a9c15a | |
pvictor | ebbaf381d1 | |
pvictor | ce1ea38e73 | |
pvictor | 9e1e61561b | |
pvictor | 7da1efd19c | |
pvictor | 9aea6b8e9e | |
pvictor | 738e281777 | |
pvictor | b9bc804e28 | |
pvictor | 8c471242f0 | |
pvictor | 6ebd778537 | |
pvictor | 6e91a515de | |
pvictor | 48d4aa0362 | |
pvictor | 5693403b68 | |
pvictor | c8ff4986b5 | |
pvictor | 311dc0f18d | |
pvictor | ddf9bb3294 | |
pvictor | 9c9a277aee | |
pvictor | 7dc81c6db6 | |
pvictor | 5704d62220 | |
pvictor | 0fdba4cd9b | |
pvictor | 2b1fc484b7 | |
pvictor | 78d09c3316 | |
pvictor | 27673fb980 | |
pvictor | 02cf03fd6a | |
pvictor | ea901187ac | |
pvictor | 5728a361da | |
pvictor | 1a6063e9fb | |
pvictor | 79f04f26da | |
pvictor | 8d751a485e | |
pvictor | 92b2217f56 | |
pvictor | 721cce9cff | |
pvictor | dc10f5e2b1 | |
pvictor | a96755e1c0 | |
pvictor | f7a8df7277 | |
pvictor | d3126ab26b | |
pvictor | 5a793fe45c | |
pvictor | 528489fc15 | |
pvictor | 43167f690a | |
pvictor | edfa24b75a | |
pvictor | 5a32d96690 | |
pvictor | e74270431d | |
pvictor | 18dea3f325 | |
pvictor | b03f42df8c | |
pvictor | cc0a11de24 | |
pvictor | 01231de378 | |
pvictor | c012ad8832 | |
pvictor | 373d80ceff | |
Victor Perrier | c3530c74c6 | |
pvictor | 11335839fd | |
pvictor | 8238c0709e | |
pvictor | 7312588c47 | |
pvictor | 31ada1a177 | |
pvictor | b4622aecdb | |
pvictor | 73daff130f | |
pvictor | 6fb06170d5 | |
pvictor | b35423b21c | |
pvictor | 88b63408c9 | |
pvictor | 8f56dca2b9 | |
pvictor | ea12c0b1f6 | |
pvictor | fee9c2c9ae | |
pvictor | 8a3bf8d6e8 | |
pvictor | a0ec017373 | |
pvictor | 38dde279f9 | |
pvictor | 02c267db56 | |
pvictor | 4823f7a630 | |
pvictor | 98b09d2f93 | |
pvictor | 641d763286 | |
pvictor | 58d7bcc55c | |
pvictor | 1d5478b1a2 | |
pvictor | c8c23aa43b | |
pvictor | e3d9c9ffc9 | |
Victor Perrier | ec890de767 | |
pvictor | dd1090989d | |
pvictor | edea361d26 | |
pvictor | 368af5fa48 | |
pvictor | 1a18a095b2 | |
pvictor | 29ae8cd6a5 | |
pvictor | 7d3d6eec23 | |
pvictor | 5fd663162d | |
pvictor | a00b3abf98 | |
pvictor | 4be8cac5df | |
pvictor | 10fe4eee19 | |
pvictor | 279ca36946 | |
pvictor | 8d5cfa631e | |
pvictor | b97073f540 | |
pvictor | c85ffb6daa | |
pvictor | b0f4b1d588 | |
pvictor | 7450f3eb52 | |
pvictor | 90e1d3e2f9 | |
pvictor | c8461f7a85 | |
pvictor | d44e251f31 | |
pvictor | 2be3c5b4b3 | |
Victor Perrier | e6e60e4032 | |
Victor Perrier | d2d8a540cc | |
pvictor | ef63ec04e0 | |
pvictor | 7097b8bf2a | |
pvictor | fa4a8c4462 | |
pvictor | 015b901602 | |
pvictor | 34eeddfa06 | |
pvictor | 5875f14cbe | |
pvictor | 8f293c74e2 | |
pvictor | 38b648ed6d | |
pvictor | e0b6e28913 | |
pvictor | 2513bc5fdf | |
pvictor | 4f2e8af93e | |
pvictor | 267793ff5a | |
pvictor | 00fe467dcc | |
pvictor | cfd5a9e712 | |
pvictor | 53a8cfa957 | |
pvictor | 326f455def | |
pvictor | f7e551db05 | |
pvictor | 500619df5a | |
pvictor | 0259eb2bb4 | |
Victor Perrier | 4376fc0173 | |
Federico Marini | 8f95e87288 | |
pvictor | 9c352df6cb | |
pvictor | ecdd725c7a | |
pvictor | 360181aa0b | |
pvictor | 3ed4f46957 | |
pvictor | b03db0e367 | |
pvictor | dd39d9dd99 | |
pvictor | 65b565ad67 |
|
@ -3,8 +3,22 @@
|
|||
^apexcharter\.Rproj$
|
||||
^\.Rproj\.user$
|
||||
^dev$
|
||||
^img$
|
||||
^revdep
|
||||
^_pkgdown\.yml$
|
||||
^docs$
|
||||
^cran-comments\.md$
|
||||
^CRAN-RELEASE$
|
||||
^examples$
|
||||
^man-roxygen$
|
||||
^\.github$
|
||||
^LICENSE\.md$
|
||||
^codecov\.yml$
|
||||
^pkgdown$
|
||||
^srcjs$
|
||||
^node_modules$
|
||||
^package\.json$
|
||||
^package-lock\.json$
|
||||
^webpack\.dev\.js$
|
||||
^webpack\.prod\.js$
|
||||
^webpack\.common\.js$
|
||||
^CRAN-SUBMISSION$
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
*.html
|
|
@ -0,0 +1,49 @@
|
|||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
|
||||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
|
||||
on:
|
||||
push:
|
||||
branches: [main, master]
|
||||
pull_request:
|
||||
branches: [main, master]
|
||||
|
||||
name: R-CMD-check
|
||||
|
||||
jobs:
|
||||
R-CMD-check:
|
||||
runs-on: ${{ matrix.config.os }}
|
||||
|
||||
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config:
|
||||
- {os: macos-latest, r: 'release'}
|
||||
- {os: windows-latest, r: 'release'}
|
||||
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
|
||||
- {os: ubuntu-latest, r: 'release'}
|
||||
- {os: ubuntu-latest, r: 'oldrel-1'}
|
||||
|
||||
env:
|
||||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
|
||||
R_KEEP_PKG_SOURCE: yes
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: r-lib/actions/setup-pandoc@v2
|
||||
|
||||
- uses: r-lib/actions/setup-r@v2
|
||||
with:
|
||||
r-version: ${{ matrix.config.r }}
|
||||
http-user-agent: ${{ matrix.config.http-user-agent }}
|
||||
use-public-rspm: true
|
||||
|
||||
- uses: r-lib/actions/setup-r-dependencies@v2
|
||||
with:
|
||||
extra-packages: any::rcmdcheck
|
||||
needs: check
|
||||
|
||||
- uses: r-lib/actions/check-r-package@v2
|
||||
with:
|
||||
upload-snapshots: true
|
|
@ -0,0 +1,47 @@
|
|||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
|
||||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
|
||||
on:
|
||||
push:
|
||||
branches: [main, master]
|
||||
pull_request:
|
||||
branches: [main, master]
|
||||
release:
|
||||
types: [published]
|
||||
workflow_dispatch:
|
||||
|
||||
name: pkgdown
|
||||
|
||||
jobs:
|
||||
pkgdown:
|
||||
runs-on: ubuntu-latest
|
||||
# Only restrict concurrency for non-PR jobs
|
||||
concurrency:
|
||||
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
|
||||
env:
|
||||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: r-lib/actions/setup-pandoc@v2
|
||||
|
||||
- uses: r-lib/actions/setup-r@v2
|
||||
with:
|
||||
use-public-rspm: true
|
||||
|
||||
- uses: r-lib/actions/setup-r-dependencies@v2
|
||||
with:
|
||||
extra-packages: any::pkgdown, local::., any::dplyr, any::highcharter, any::gapminder
|
||||
needs: website
|
||||
pak-version: devel
|
||||
|
||||
- name: Build site
|
||||
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
|
||||
shell: Rscript {0}
|
||||
|
||||
- name: Deploy to GitHub pages 🚀
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: JamesIves/github-pages-deploy-action@v4.4.1
|
||||
with:
|
||||
clean: false
|
||||
branch: gh-pages
|
||||
folder: docs
|
|
@ -0,0 +1,50 @@
|
|||
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
|
||||
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
|
||||
on:
|
||||
push:
|
||||
branches: [main, master]
|
||||
pull_request:
|
||||
branches: [main, master]
|
||||
|
||||
name: test-coverage
|
||||
|
||||
jobs:
|
||||
test-coverage:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: r-lib/actions/setup-r@v2
|
||||
with:
|
||||
use-public-rspm: true
|
||||
|
||||
- uses: r-lib/actions/setup-r-dependencies@v2
|
||||
with:
|
||||
extra-packages: any::covr
|
||||
needs: coverage
|
||||
|
||||
- name: Test coverage
|
||||
run: |
|
||||
covr::codecov(
|
||||
quiet = FALSE,
|
||||
clean = FALSE,
|
||||
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
|
||||
)
|
||||
shell: Rscript {0}
|
||||
|
||||
- name: Show testthat output
|
||||
if: always()
|
||||
run: |
|
||||
## --------------------------------------------------------------------
|
||||
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
|
||||
shell: bash
|
||||
|
||||
- name: Upload test results
|
||||
if: failure()
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: coverage-test-failures
|
||||
path: ${{ runner.temp }}/package
|
|
@ -4,3 +4,6 @@ inst/doc
|
|||
.RData
|
||||
*.Rproj
|
||||
data-raw/*.csv
|
||||
node_modules
|
||||
docs
|
||||
data-raw/inputs/
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
# R for travis: see documentation at https://docs.travis-ci.com/user/languages/r
|
||||
|
||||
language: R
|
||||
sudo: false
|
||||
cache: packages
|
22
DESCRIPTION
22
DESCRIPTION
|
@ -1,31 +1,35 @@
|
|||
Package: apexcharter
|
||||
Version: 0.1.2
|
||||
Version: 0.4.3.9000
|
||||
Title: Create Interactive Chart with the JavaScript 'ApexCharts' Library
|
||||
Description: Provides an 'htmlwidgets' interface to 'apexcharts.js'.
|
||||
'Apexcharts' is a modern JavaScript charting library to build interactive charts and visualizations with simple API.
|
||||
'Apexcharts' examples and documentation are available here: <https://apexcharts.com/>.
|
||||
Authors@R: c(
|
||||
person("Victor", "Perrier", email = "victor.perrier@dreamrs.fr", role = c("aut", "cre")),
|
||||
person("Fanny", "Meyer", email = "fanny.meyer@dreamrs.fr", role = "aut"),
|
||||
person("Juned", "Chhipa", role = "cph", comment = "apexcharts.js library"))
|
||||
person("Fanny", "Meyer", role = "aut"),
|
||||
person("Juned", "Chhipa", role = "cph", comment = "apexcharts.js library"),
|
||||
person("Mike", "Bostock", role = "cph", comment = "d3.format library"))
|
||||
License: MIT + file LICENSE
|
||||
Encoding: UTF-8
|
||||
LazyData: true
|
||||
ByteCompile: true
|
||||
Depends: R (>= 2.10)
|
||||
Imports:
|
||||
htmlwidgets,
|
||||
htmltools,
|
||||
htmlwidgets (>= 1.5.3),
|
||||
magrittr,
|
||||
rlang,
|
||||
ggplot2,
|
||||
scales
|
||||
jsonlite,
|
||||
shiny (>= 1.1.0)
|
||||
Suggests:
|
||||
testthat,
|
||||
dplyr,
|
||||
knitr,
|
||||
scales,
|
||||
rmarkdown,
|
||||
shiny
|
||||
RoxygenNote: 6.1.1
|
||||
URL: https://github.com/dreamRs/apexcharter
|
||||
covr
|
||||
RoxygenNote: 7.3.1
|
||||
Roxygen: list(markdown = TRUE)
|
||||
URL: https://github.com/dreamRs/apexcharter, https://dreamrs.github.io/apexcharter/
|
||||
BugReports: https://github.com/dreamRs/apexcharter/issues
|
||||
VignetteBuilder: knitr
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
ApexCharts.js
|
||||
=============
|
||||
# MIT License
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 ApexCharts
|
||||
Copyright (c) 2020 Victor Perrier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -12,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
73
NAMESPACE
73
NAMESPACE
|
@ -1,23 +1,42 @@
|
|||
# Generated by roxygen2: do not edit by hand
|
||||
|
||||
S3method(print,apex_facet)
|
||||
S3method(print,apex_grid)
|
||||
export("%>%")
|
||||
export(JS)
|
||||
export(add_event)
|
||||
export(add_event_marker)
|
||||
export(add_hline)
|
||||
export(add_line)
|
||||
export(add_point)
|
||||
export(add_shade)
|
||||
export(add_shade_weekend)
|
||||
export(add_smooth_line)
|
||||
export(add_vline)
|
||||
export(aes)
|
||||
export(apex)
|
||||
export(apex_grid)
|
||||
export(apexchart)
|
||||
export(apexchartOutput)
|
||||
export(apexchartProxy)
|
||||
export(apexfacetOutput)
|
||||
export(apexgridOutput)
|
||||
export(ax_annotations)
|
||||
export(ax_chart)
|
||||
export(ax_colors)
|
||||
export(ax_colors_manual)
|
||||
export(ax_dataLabels)
|
||||
export(ax_facet_grid)
|
||||
export(ax_facet_wrap)
|
||||
export(ax_fill)
|
||||
export(ax_forecast_data_points)
|
||||
export(ax_grid)
|
||||
export(ax_labels)
|
||||
export(ax_labels2)
|
||||
export(ax_labs)
|
||||
export(ax_legend)
|
||||
export(ax_markers)
|
||||
export(ax_nodata)
|
||||
export(ax_plotOptions)
|
||||
export(ax_proxy_options)
|
||||
export(ax_proxy_series)
|
||||
|
@ -34,20 +53,74 @@ export(ax_xaxis)
|
|||
export(ax_yaxis)
|
||||
export(ax_yaxis2)
|
||||
export(bar_opts)
|
||||
export(boxplot_opts)
|
||||
export(bubble_opts)
|
||||
export(config_update)
|
||||
export(events_opts)
|
||||
export(format_date)
|
||||
export(format_num)
|
||||
export(heatmap_opts)
|
||||
export(label)
|
||||
export(label_value)
|
||||
export(parse_df)
|
||||
export(pie_opts)
|
||||
export(radialBar_opts)
|
||||
export(renderApexchart)
|
||||
export(renderApexfacet)
|
||||
export(renderApexgrid)
|
||||
export(renderSparkBox)
|
||||
export(run_demo_input)
|
||||
export(run_demo_sparkbox)
|
||||
export(run_demo_sync)
|
||||
export(set_input_click)
|
||||
export(set_input_export)
|
||||
export(set_input_selection)
|
||||
export(set_input_zoom)
|
||||
export(set_tooltip_fixed)
|
||||
export(sparkBoxOutput)
|
||||
export(spark_box)
|
||||
export(vars)
|
||||
importFrom(ggplot2,aes)
|
||||
importFrom(ggplot2,label_value)
|
||||
importFrom(ggplot2,vars)
|
||||
importFrom(graphics,boxplot)
|
||||
importFrom(htmltools,css)
|
||||
importFrom(htmltools,renderTags)
|
||||
importFrom(htmltools,resolveDependencies)
|
||||
importFrom(htmltools,tagList)
|
||||
importFrom(htmltools,tags)
|
||||
importFrom(htmltools,validateCssUnit)
|
||||
importFrom(htmlwidgets,JS)
|
||||
importFrom(htmlwidgets,JSEvals)
|
||||
importFrom(htmlwidgets,createWidget)
|
||||
importFrom(htmlwidgets,getDependency)
|
||||
importFrom(htmlwidgets,shinyRenderWidget)
|
||||
importFrom(htmlwidgets,shinyWidgetOutput)
|
||||
importFrom(htmlwidgets,sizingPolicy)
|
||||
importFrom(jsonlite,fromJSON)
|
||||
importFrom(magrittr,"%>%")
|
||||
importFrom(rlang,"!!")
|
||||
importFrom(rlang,"%||%")
|
||||
importFrom(rlang,as_label)
|
||||
importFrom(rlang,eval_tidy)
|
||||
importFrom(rlang,is_function)
|
||||
importFrom(rlang,is_list)
|
||||
importFrom(rlang,is_named)
|
||||
importFrom(rlang,is_null)
|
||||
importFrom(rlang,quo)
|
||||
importFrom(rlang,quos)
|
||||
importFrom(rlang,sym)
|
||||
importFrom(rlang,syms)
|
||||
importFrom(shiny,createRenderFunction)
|
||||
importFrom(shiny,createWebDependency)
|
||||
importFrom(shiny,exprToFunction)
|
||||
importFrom(shiny,getDefaultReactiveDomain)
|
||||
importFrom(shiny,registerInputHandler)
|
||||
importFrom(shiny,shinyAppFile)
|
||||
importFrom(shiny,uiOutput)
|
||||
importFrom(stats,complete.cases)
|
||||
importFrom(stats,lm)
|
||||
importFrom(stats,loess)
|
||||
importFrom(stats,predict)
|
||||
importFrom(stats,setNames)
|
||||
importFrom(utils,modifyList)
|
||||
|
|
136
NEWS.md
136
NEWS.md
|
@ -1,7 +1,141 @@
|
|||
apexcharter 0.4.3
|
||||
==================
|
||||
|
||||
* Updated ApexCharts.js to 3.49.1 (see https://github.com/apexcharts/apexcharts.js/releases).
|
||||
* New chart type : slope charts.
|
||||
|
||||
|
||||
|
||||
apexcharter 0.4.2
|
||||
==================
|
||||
|
||||
* Updated ApexCharts.js to 3.46.0 (see https://github.com/apexcharts/apexcharts.js/releases).
|
||||
|
||||
|
||||
|
||||
apexcharter 0.4.1
|
||||
==================
|
||||
|
||||
* Updated ApexCharts.js to 3.41.0 (new charts type: dumbbell chart and funnel chart).
|
||||
* `apex()` : added support for boxplot.
|
||||
* New function `ax_forecast_data_points()` to mark points as forecasted values.
|
||||
|
||||
|
||||
|
||||
apexcharter 0.4.0
|
||||
==================
|
||||
|
||||
* Updated ApexCharts.js to 3.36.3.
|
||||
* New chart type : range area charts.
|
||||
* Facets: correctly manage secondary y axis.
|
||||
|
||||
|
||||
|
||||
apexcharter 0.3.1
|
||||
==================
|
||||
|
||||
* Updated ApexCharts.js to 3.33.1
|
||||
* Minimal {htmlwidgets} version required >= 1.5.3
|
||||
|
||||
|
||||
|
||||
apexcharter 0.3.0
|
||||
==================
|
||||
|
||||
* Updated ApexCharts.js to 3.29.0
|
||||
* Internal: use [{packer}](https://github.com/JohnCoene/packer) to manage JavaScript assets.
|
||||
* `d3.format` JavaScript functions are now available in browser under `format()` and `formatLocale()`.
|
||||
|
||||
|
||||
|
||||
apexcharter 0.2.0
|
||||
==================
|
||||
|
||||
* Updated ApexCharts.js to 3.26.2
|
||||
* New functions `ax_facet_wrap()` and `ax_facet_grid()` to create faceting charts.
|
||||
* New function `apex_grid()` to combine several charts in a grid.
|
||||
|
||||
|
||||
|
||||
apexcharter 0.1.8
|
||||
==================
|
||||
|
||||
* Updated ApexCharts.js to 3.22.2
|
||||
|
||||
## Bugfixes
|
||||
|
||||
* Fixed bad JavaScript namespace
|
||||
* Fixed bug in groups with scatter chart
|
||||
|
||||
|
||||
|
||||
apexcharter 0.1.7
|
||||
==================
|
||||
|
||||
* Updated ApexCharts.js to 3.22.0
|
||||
* New chart type: treemap, see vignette for example.
|
||||
* New function `ax_colors_manual()` to set color mapping manually.
|
||||
* `apex()` now accept `polarArea` as type of chart.
|
||||
|
||||
|
||||
|
||||
apexcharter 0.1.6
|
||||
==================
|
||||
|
||||
* Updated ApexCharts.js to 3.20.1
|
||||
* New functions `add_line()` and `add_smooth_line()` to add simple or trend line on charts (scatter & bars).
|
||||
* New Shiny input: export, to retrieve chart's base64 dataURI.
|
||||
|
||||
|
||||
|
||||
apexcharter 0.1.5
|
||||
==================
|
||||
|
||||
* Updated ApexCharts.js to 3.18.1
|
||||
* Support for candlestick charts in `apex()`.
|
||||
* `apex()` has a new argument `synchronize` to easily synchronize charts together.
|
||||
* `apex()` has new charts type: area-spline, area-step and step.
|
||||
|
||||
|
||||
## New functions
|
||||
|
||||
* `spark_box` to create boxes with sparkline, see corresponding vignette for more details.
|
||||
* `add_shade()`, `add_shade_weekend()`, `add_event()` to add annotations on time-series charts.
|
||||
* `add_hline()`, `add_vline()`, `add_point()` to add annotations on charts.
|
||||
* `set_tooltip_fixed()` to fix tooltip in specific position.
|
||||
|
||||
## Bugfixes
|
||||
|
||||
* Xaxis datetime now display properly with columns and bars.
|
||||
* Dark mode wasn't activated properly in `ax_theme()`.
|
||||
|
||||
|
||||
|
||||
|
||||
apexcharter 0.1.4
|
||||
==================
|
||||
|
||||
* Upgraded ApexCharts.js to 3.17.1
|
||||
* Fixed a bug in grouped bar charts with different levels in groups.
|
||||
* New vignette to explain how to sync charts.
|
||||
* New vignette to show shiny usage.
|
||||
* Added functions `set_input_click()`, `set_input_zoom()` and `set_input_selection()` to add interaction in Shiny applications.
|
||||
|
||||
|
||||
|
||||
apexcharter 0.1.3
|
||||
==================
|
||||
|
||||
* Upgraded ApexCharts.js to 3.10.1
|
||||
* New function `format_num()` to format labels on y-axis or tooltip for example.
|
||||
* Added localization configs file, see `?ax_chart` for examples.
|
||||
|
||||
|
||||
|
||||
apexcharter 0.1.2
|
||||
==================
|
||||
|
||||
* Update ApexCharts to 3.8.2
|
||||
* Upgraded ApexCharts.js to 3.8.2
|
||||
* Set parent container height to 0 by default (fix [#2](https://github.com/dreamRs/apexcharter/issues/2)).
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,436 @@
|
|||
|
||||
add_annotation <- function(ax, type_annotation = c("xaxis", "yaxis", "points"),
|
||||
as_date = FALSE, position = "back", ...) {
|
||||
type_annotation <- match.arg(type_annotation)
|
||||
config <- dropNullsOrEmpty(list(...))
|
||||
if (!is.null(config$label) && is.character(config$label)) {
|
||||
config$label <- list(text = config$label)
|
||||
}
|
||||
if (!is.null(config$marker) && is.numeric(config$marker)) {
|
||||
config$marker <- list(size = config$marker)
|
||||
}
|
||||
if (identical(type_annotation, "yaxis")) {
|
||||
len <- length(config$y)
|
||||
} else {
|
||||
len <- length(config$x)
|
||||
}
|
||||
config <- rapply(
|
||||
object = config,
|
||||
f = rep_len,
|
||||
length.out = len,
|
||||
how = "replace"
|
||||
)
|
||||
extract <- function(el, index) {
|
||||
`[`(el, index)
|
||||
}
|
||||
annotations <- lapply(
|
||||
X = seq_len(len),
|
||||
FUN = function(i) {
|
||||
this <- rapply(
|
||||
object = config,
|
||||
f = extract,
|
||||
index = i,
|
||||
how = "list"
|
||||
)
|
||||
if (isTRUE(as_date)) {
|
||||
if (!is.null(this$x))
|
||||
this$x <- format_date(this$x)
|
||||
if (!is.null(this$x2))
|
||||
this$x2 <- format_date(this$x2)
|
||||
}
|
||||
this
|
||||
}
|
||||
)
|
||||
if (identical(type_annotation, "xaxis")) {
|
||||
if (!is.null(ax$x$ax_opts$annotations$xaxis)) {
|
||||
annotations <- c(annotations, ax$x$ax_opts$annotations$xaxis)
|
||||
ax$x$ax_opts$annotations$xaxis <- NULL
|
||||
}
|
||||
ax <- ax_annotations(
|
||||
ax = ax,
|
||||
position = position,
|
||||
xaxis = annotations
|
||||
)
|
||||
} else if (identical(type_annotation, "yaxis")) {
|
||||
if (!is.null(ax$x$ax_opts$annotations$yaxis)) {
|
||||
annotations <- c(annotations, ax$x$ax_opts$annotations$yaxis)
|
||||
ax$x$ax_opts$annotations$yaxis <- NULL
|
||||
}
|
||||
ax <- ax_annotations(
|
||||
ax = ax,
|
||||
position = position,
|
||||
yaxis = annotations
|
||||
)
|
||||
} else if (identical(type_annotation, "points")) {
|
||||
if (!is.null(ax$x$ax_opts$annotations$points)) {
|
||||
annotations <- c(annotations, ax$x$ax_opts$annotations$points)
|
||||
ax$x$ax_opts$annotations$points <- NULL
|
||||
}
|
||||
ax <- ax_annotations(
|
||||
ax = ax,
|
||||
position = position,
|
||||
points = annotations
|
||||
)
|
||||
}
|
||||
return(ax)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#' Label for annotations
|
||||
#'
|
||||
#' @param text Text for the annotation label.
|
||||
#' @param borderColor Border color for the label.
|
||||
#' @param borderWidth Border width for the label.
|
||||
#' @param textAnchor The alignment of text relative to label's drawing position.
|
||||
#' @param position Available options: left or right.
|
||||
#' @param offsetX Sets the left offset for annotation label.
|
||||
#' @param offsetY Sets the top offset for annotation label.
|
||||
#' @param background Background Color for the annotation label.
|
||||
#' @param color ForeColor for the annotation label.
|
||||
#' @param fontSize FontSize for the annotation label.
|
||||
#' @param fontWeight Font-weight for the annotation label.
|
||||
#' @param fontFamily Font-family for the annotation label.
|
||||
#' @param cssClass A custom Css Class to give to the annotation label elements.
|
||||
#' @param padding Padding for the label: top, right, bottom, left.
|
||||
#'
|
||||
#' @return A \code{list} that can be used in \code{\link{add_shade}}, \code{\link{add_point}},
|
||||
#' \code{\link{add_event}}, \code{\link{add_event_marker}}.
|
||||
#' @export
|
||||
#'
|
||||
label <- function(text = NULL,
|
||||
borderColor = NULL,
|
||||
borderWidth = NULL,
|
||||
textAnchor = NULL,
|
||||
position = NULL,
|
||||
offsetX = NULL,
|
||||
offsetY = NULL,
|
||||
background = NULL,
|
||||
color = NULL,
|
||||
fontSize = NULL,
|
||||
fontWeight = NULL,
|
||||
fontFamily = NULL,
|
||||
cssClass = NULL,
|
||||
padding = c(2, 5, 2, 5)) {
|
||||
dropNulls(list(
|
||||
borderColor = borderColor,
|
||||
borderWidth = borderWidth,
|
||||
text = text,
|
||||
textAnchor = textAnchor,
|
||||
position = position,
|
||||
offsetX = offsetX,
|
||||
offsetY = offsetY,
|
||||
style = dropNulls(list(
|
||||
background = background,
|
||||
color = color,
|
||||
fontSize = fontSize,
|
||||
fontWeight = fontWeight,
|
||||
fontFamily = fontFamily,
|
||||
padding = list(
|
||||
top = padding[1],
|
||||
right = padding[2],
|
||||
bottom = padding[3],
|
||||
left = padding[4]
|
||||
)
|
||||
))
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
#' Marker for annotations
|
||||
#'
|
||||
#' @param size Size of the marker.
|
||||
#' @param fillColor Fill Color of the marker point.
|
||||
#' @param strokeColor Stroke Color of the marker point.
|
||||
#' @param strokeWidth Stroke Size of the marker point.
|
||||
#' @param shape Shape of the marker: \code{"circle"} or \code{"square"}.
|
||||
#' @param radius Radius of the marker (applies to square shape).
|
||||
#' @param OffsetX Sets the left offset of the marker.
|
||||
#' @param OffsetY Sets the top offset of the marker.
|
||||
#' @param cssClass Additional CSS classes to append to the marker.
|
||||
#'
|
||||
#' @return A \code{list} that can be used in \code{\link{add_point}}.
|
||||
#' @noRd
|
||||
#'
|
||||
marker <- function(size = NULL,
|
||||
fillColor = NULL,
|
||||
strokeColor = NULL,
|
||||
strokeWidth = NULL,
|
||||
shape = NULL,
|
||||
radius = NULL,
|
||||
OffsetX = NULL,
|
||||
OffsetY = NULL,
|
||||
cssClass = NULL) {
|
||||
dropNulls(list(
|
||||
size = size,
|
||||
fillColor = fillColor,
|
||||
strokeColor = strokeColor,
|
||||
strokeWidth = strokeWidth,
|
||||
shape = shape,
|
||||
radius = radius,
|
||||
OffsetX = OffsetX,
|
||||
OffsetY = OffsetY,
|
||||
cssClass = cssClass
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
#' @title Add a shaded area to a chart
|
||||
#'
|
||||
#' @description \code{add_shade()} allow to add a shaded area on specified range,
|
||||
#' \code{add_shade_weekend()} add a shadow on every week-end.
|
||||
#'
|
||||
#' @template ax-default
|
||||
#' @param from Vector of position to start shadow.
|
||||
#' @param to Vector of position to end shadow.
|
||||
#' @param color Color of the shadow.
|
||||
#' @param opacity Opacity of the shadow.
|
||||
#' @param label Add a label to the shade, use a \code{character}
|
||||
#' or see \code{\link{label}} for more controls.
|
||||
#' @param ... Additional arguments, see
|
||||
#' \url{https://apexcharts.com/docs/options/annotations/} for possible options.
|
||||
#'
|
||||
#' @note \code{add_shade_weekend} only works if variable
|
||||
#' used for x-axis is of class \code{Date} or \code{POSIXt}.
|
||||
#'
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @name add-shade
|
||||
#'
|
||||
#' @example examples/add_shade.R
|
||||
add_shade <- function(ax, from, to, color = "#848484", opacity = 0.2, label = NULL, ...) {
|
||||
if (length(from) != length(to)) {
|
||||
stop("In add_shade: from and to must be of same length!", call. = FALSE)
|
||||
}
|
||||
add_annotation(
|
||||
ax = ax,
|
||||
type_annotation = "xaxis",
|
||||
as_date = TRUE,
|
||||
x = from,
|
||||
x2 = to,
|
||||
fillColor = color,
|
||||
opacity = opacity,
|
||||
label = label,
|
||||
...
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
#' @export
|
||||
#' @rdname add-shade
|
||||
add_shade_weekend <- function(ax, color = "#848484", opacity = 0.2, label = NULL, ...) {
|
||||
if (is.null(ax$x$xaxis)) {
|
||||
stop("add_shade_weekend can only be used with apex().", call. = FALSE)
|
||||
}
|
||||
if (inherits(ax$x$xaxis$min, c("Date", "POSIXt"))) {
|
||||
from <- as.Date(format(ax$x$xaxis$min, format = "%Y-%m-%d"))
|
||||
to <- as.Date(format(ax$x$xaxis$max, format = "%Y-%m-%d"))
|
||||
dates <- seq(from = from - 2, to = to + 2, by = "day")
|
||||
if (inherits(ax$x$xaxis$min, "Date")) {
|
||||
sat <- dates[format(dates, format = "%u") == 5]
|
||||
time <- "12:00:00"
|
||||
} else {
|
||||
sat <- dates[format(dates, format = "%u") == 6]
|
||||
time <- "00:00:00"
|
||||
}
|
||||
sun <- sat + 2
|
||||
ax <- add_shade(
|
||||
ax = ax,
|
||||
from = paste(format(sat, format = "%Y-%m-%d"), time),
|
||||
to = paste(format(sun, format = "%Y-%m-%d"), time),
|
||||
color = color,
|
||||
opacity = opacity,
|
||||
label = label,
|
||||
...
|
||||
)
|
||||
}
|
||||
return(ax)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#' @title Add an event to a chart
|
||||
#'
|
||||
#' @description Add a vertical line to mark a special event on a chart.
|
||||
#'
|
||||
#' @template ax-default
|
||||
#' @param when Vector of position to place the event.
|
||||
#' @param color Color of the line.
|
||||
#' @param dash Creates dashes in borders of SVG path.
|
||||
#' A higher number creates more space between dashes in the border.
|
||||
#' Use \code{0} for plain line.
|
||||
#' @param label Add a label to the shade, use a \code{character}
|
||||
#' or see \code{\link{label}} for more controls.
|
||||
#' @param ... Additional arguments, see
|
||||
#' \url{https://apexcharts.com/docs/options/annotations/} for possible options.
|
||||
#'
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @seealso \code{\link{add_event_marker}} to add a point.
|
||||
#'
|
||||
#' @example examples/add_event.R
|
||||
add_event <- function(ax, when, color = "#E41A1C", dash = 4, label = NULL, ...) {
|
||||
add_annotation(
|
||||
ax = ax,
|
||||
type_annotation = "xaxis",
|
||||
as_date = TRUE,
|
||||
x = when,
|
||||
borderColor = color,
|
||||
strokeDashArray = dash,
|
||||
label = label,
|
||||
...
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
#' @title Add an event marker to a chart
|
||||
#'
|
||||
#' @description Add a point with a label based on a datetime.
|
||||
#'
|
||||
#' @param when Vector of position to place the event.
|
||||
#' @inheritParams add_point
|
||||
#'
|
||||
#' @return An [apexchart()] `htmlwidget` object.
|
||||
#' @export
|
||||
#'
|
||||
#' @seealso \code{\link{add_event}} to add a vertical line.
|
||||
#'
|
||||
#' @example examples/add_event_marker.R
|
||||
add_event_marker <- function(ax, when, y,
|
||||
size = 5,
|
||||
color = "#000",
|
||||
fill = "#FFF",
|
||||
width = 2,
|
||||
shape = "circle",
|
||||
radius = 2,
|
||||
label = NULL, ...) {
|
||||
add_annotation(
|
||||
ax = ax,
|
||||
type_annotation = "points",
|
||||
position = "front",
|
||||
as_date = TRUE,
|
||||
x = when, y = y,
|
||||
marker = marker(
|
||||
size = size,
|
||||
fillColor = fill,
|
||||
strokeColor = color,
|
||||
strokeWidth = width,
|
||||
shape = shape,
|
||||
radius = radius
|
||||
),
|
||||
label = label,
|
||||
...
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#' Add horizontal or vertical line
|
||||
#'
|
||||
#' @template ax-default
|
||||
#' @param value Vector of position for the line(s).
|
||||
#' @param color Color(s) of the line(s).
|
||||
#' @param dash Creates dashes in borders of SVG path.
|
||||
#' A higher number creates more space between dashes in the border.
|
||||
#' Use \code{0} for plain line.
|
||||
#' @param label Add a label to the shade, use a \code{character}
|
||||
#' or see \code{\link{label}} for more controls.
|
||||
#' @param ... Additional arguments, see
|
||||
#' \url{https://apexcharts.com/docs/options/annotations/} for possible options.
|
||||
#'
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @name add-vh-lines
|
||||
#'
|
||||
#' @example examples/add-lines.R
|
||||
add_hline <- function(ax, value, color = "#000", dash = 0, label = NULL, ...) {
|
||||
add_annotation(
|
||||
ax = ax,
|
||||
type_annotation = "yaxis",
|
||||
position = "front",
|
||||
as_date = FALSE,
|
||||
y = value,
|
||||
borderColor = color,
|
||||
strokeDashArray = dash,
|
||||
label = label,
|
||||
...
|
||||
)
|
||||
}
|
||||
#' @export
|
||||
#' @rdname add-vh-lines
|
||||
add_vline <- function(ax, value, color = "#000", dash = 0, label = NULL, ...) {
|
||||
add_annotation(
|
||||
ax = ax,
|
||||
type_annotation = "xaxis",
|
||||
position = "front",
|
||||
as_date = FALSE,
|
||||
x = value,
|
||||
borderColor = color,
|
||||
strokeDashArray = dash,
|
||||
label = label,
|
||||
...
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
#' Add an annotation point
|
||||
#'
|
||||
#' @template ax-default
|
||||
#' @param x Coordinate(s) on the x-axis.
|
||||
#' @param y Coordinate(s) on the y-axis.
|
||||
#' @param size Size of the marker.
|
||||
#' @param color Stroke Color of the marker point.
|
||||
#' @param fill Fill Color of the marker point.
|
||||
#' @param width Stroke Size of the marker point.
|
||||
#' @param shape Shape of the marker: \code{"circle"} or \code{"square"}.
|
||||
#' @param radius Radius of the marker (applies to square shape).
|
||||
#' @param label Add a label to the shade, use a \code{character}
|
||||
#' or see \code{\link{label}} for more controls.
|
||||
#' @param ... Additional arguments, see
|
||||
#' \url{https://apexcharts.com/docs/options/annotations/} for possible options.
|
||||
#'
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @seealso \code{\link{add_event_marker}} to add a point when x-axis is a datetime.
|
||||
#'
|
||||
#' @example examples/add_point.R
|
||||
add_point <- function(ax, x, y,
|
||||
size = 5,
|
||||
color = "#000",
|
||||
fill = "#FFF",
|
||||
width = 2,
|
||||
shape = "circle",
|
||||
radius = 2,
|
||||
label = NULL, ...) {
|
||||
add_annotation(
|
||||
ax = ax,
|
||||
type_annotation = "points",
|
||||
position = "front",
|
||||
as_date = inherits(x, c("Date", "POSIXct")),
|
||||
x = x, y = y,
|
||||
marker = marker(
|
||||
size = size,
|
||||
fillColor = fill,
|
||||
strokeColor = color,
|
||||
strokeWidth = width,
|
||||
shape = shape,
|
||||
radius = radius
|
||||
),
|
||||
label = label,
|
||||
...
|
||||
)
|
||||
}
|
|
@ -15,7 +15,7 @@
|
|||
#' @param legendClick Fires when user clicks on legend.
|
||||
#' @param selection Fires when user selects rect using the selection tool.
|
||||
#' @param dataPointSelection Fires when user clicks on a datapoint (bar/column/marker/bubble/donut-slice).
|
||||
#' @param dataPointMouseEnter Fires when user’s mouse enter on a datapoint (bar/column/marker/bubble/donut-slice).
|
||||
#' @param dataPointMouseEnter Fires when user's mouse enter on a datapoint (bar/column/marker/bubble/donut-slice).
|
||||
#' @param dataPointMouseLeave MouseLeave event for a datapoint (bar/column/marker/bubble/donut-slice).
|
||||
#' @param beforeZoom This function, if defined, runs just before zooming in/out of the chart allowing you to set a custom range for zooming in/out.
|
||||
#' @param zoomed Fires when user zooms in/out the chart using either the selection zooming tool or zoom in/out buttons.
|
||||
|
@ -115,7 +115,7 @@ events_opts <- function(click = NULL,
|
|||
|
||||
#' @title Bar options
|
||||
#'
|
||||
#' @description Use these options in \code{\link{ax_plotOptions}}.
|
||||
#' @description Use these options in [ax_plotOptions()].
|
||||
#'
|
||||
#' @param horizontal Logical. This option will turn a column chart into a horizontal bar chart.
|
||||
#' @param endingShape Available Options: \code{"flat"} or \code{"rounded"}.
|
||||
|
@ -128,16 +128,15 @@ events_opts <- function(click = NULL,
|
|||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/plotoptions/bar/}.
|
||||
#'
|
||||
#' @return A \code{list} of options that can be used in \code{\link{ax_plotOptions}}.
|
||||
#' @return A \code{list} of options that can be used in [ax_plotOptions()].
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#'
|
||||
#' library(dplyr)
|
||||
#' data("mpg", package = "ggplot2")
|
||||
#'
|
||||
#' apex(count(mpg, manufacturer), aes(manufacturer, n)) %>%
|
||||
#' apex(mpg, aes(manufacturer)) %>%
|
||||
#' ax_plotOptions(
|
||||
#' bar = bar_opts(
|
||||
#' endingShape = "rounded",
|
||||
|
@ -171,7 +170,7 @@ bar_opts <- function(horizontal = NULL,
|
|||
|
||||
#' @title Heatmap options
|
||||
#'
|
||||
#' @description Use these options in \code{\link{ax_plotOptions}}.
|
||||
#' @description Use these options in [ax_plotOptions()].
|
||||
#'
|
||||
#' @param radius Numeric. Radius of the rectangle inside heatmap.
|
||||
#' @param enableShades Logical. Enable different shades of color depending on the value
|
||||
|
@ -181,7 +180,7 @@ bar_opts <- function(horizontal = NULL,
|
|||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/plotoptions/heatmap/}.
|
||||
#'
|
||||
#' @return A \code{list} of options that can be used in \code{\link{ax_plotOptions}}.
|
||||
#' @return A \code{list} of options that can be used in [ax_plotOptions()].
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
|
@ -229,7 +228,7 @@ heatmap_opts <- function(radius = NULL,
|
|||
|
||||
#' @title Radial bar options
|
||||
#'
|
||||
#' @description Use these options in \code{\link{ax_plotOptions}}.
|
||||
#' @description Use these options in [ax_plotOptions()].
|
||||
#'
|
||||
#' @param size Numeric. Manual size of the radialBars instead of calculating automatically from default height / width.
|
||||
#' @param inverseOrder Logical. Whether to make the first value of series innermost or outermost.
|
||||
|
@ -244,7 +243,7 @@ heatmap_opts <- function(radius = NULL,
|
|||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/plotoptions/radialbar/}.
|
||||
#'
|
||||
#' @return A \code{list} of options that can be used in \code{\link{ax_plotOptions}}.
|
||||
#' @return A \code{list} of options that can be used in [ax_plotOptions()].
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
|
@ -302,7 +301,7 @@ radialBar_opts <- function(size = NULL,
|
|||
|
||||
#' @title Pie options
|
||||
#'
|
||||
#' @description Use these options in \code{\link{ax_plotOptions}}.
|
||||
#' @description Use these options in [ax_plotOptions()].
|
||||
#'
|
||||
#' @param size Numeric. Custom size of the pie which will override the default size calculations.
|
||||
#' @param donut List with two fields \code{size} (Donut / ring size in percentage relative to the total pie area.)
|
||||
|
@ -315,16 +314,14 @@ radialBar_opts <- function(size = NULL,
|
|||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/plotoptions/pie/}.
|
||||
#'
|
||||
#' @return A \code{list} of options that can be used in \code{\link{ax_plotOptions}}.
|
||||
#' @return A \code{list} of options that can be used in [ax_plotOptions()].
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#'
|
||||
#' library(dplyr)
|
||||
#' data("mpg", package = "ggplot2")
|
||||
#'
|
||||
#' apex(count(mpg, cyl), aes(cyl, n), type = "donut") %>%
|
||||
#' apex(mpg, aes(cyl), type = "donut") %>%
|
||||
#' ax_plotOptions(
|
||||
#' pie = pie_opts(
|
||||
#' donut = list(size = "90%", background = "#BABABA")
|
||||
|
@ -350,3 +347,75 @@ pie_opts <- function(size = NULL,
|
|||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
#' @title Bubble options
|
||||
#'
|
||||
#' @description Use these options in [ax_plotOptions()].
|
||||
#'
|
||||
#' @param minBubbleRadius Minimum radius size of a bubble.
|
||||
#' If a bubble value is too small to be displayed, this size will be used.
|
||||
#' @param maxBubbleRadius Maximum radius size of a bubble.
|
||||
#' If a bubble value is too large to cover the chart, this size will be used.
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/plotoptions/bubble/}.
|
||||
#'
|
||||
#' @return A \code{list} of options that can be used in [ax_plotOptions()].
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#' apex(
|
||||
#' data = mtcars,
|
||||
#' type = "scatter",
|
||||
#' mapping = aes(x = wt, y = mpg, z = qsec)
|
||||
#' ) %>%
|
||||
#' ax_plotOptions(
|
||||
#' bubble = bubble_opts(
|
||||
#' minBubbleRadius = 1,
|
||||
#' maxBubbleRadius = 20
|
||||
#' )
|
||||
#' )
|
||||
bubble_opts <- function(minBubbleRadius, maxBubbleRadius, ...) {
|
||||
dropNulls(
|
||||
list(
|
||||
minBubbleRadius = minBubbleRadius,
|
||||
maxBubbleRadius = maxBubbleRadius,
|
||||
...
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#' @title Boxplot options
|
||||
#'
|
||||
#' @description Use these options in [ax_plotOptions()].
|
||||
#'
|
||||
#' @param color.upper Color for the upper quartile (Q3 to median) of the box plot.
|
||||
#' @param color.lower Color for the lower quartile (median to Q1) of the box plot.
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/plotoptions/boxplot/}.
|
||||
#'
|
||||
#' @return A \code{list} of options that can be used in [ax_plotOptions()].
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#' data("mpg", package = "ggplot2")
|
||||
#' apex(mpg, aes(class, hwy), "boxplot") %>%
|
||||
#' ax_plotOptions(
|
||||
#' boxPlot = boxplot_opts(color.upper = "#848484", color.lower = "#848484" )
|
||||
#' )
|
||||
boxplot_opts <- function(color.upper, color.lower, ...) {
|
||||
dropNulls(
|
||||
list(
|
||||
colors = dropNulls(list(
|
||||
upper = color.upper,
|
||||
lower = color.lower
|
||||
)),
|
||||
...
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
363
R/apex-utils.R
363
R/apex-utils.R
|
@ -1,14 +1,10 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
# ApexCharts API ----------------------------------------------------------
|
||||
|
||||
|
||||
#' Annotations properties
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param position Whether to put the annotations behind the charts or in front of it. Available Options: \code{"front"} or \code{"back"}.
|
||||
#' @param yaxis List of lists.
|
||||
#' @param xaxis List of lists.
|
||||
|
@ -17,7 +13,6 @@
|
|||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/annotations/}.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
|
@ -130,11 +125,19 @@ ax_annotations <- function(ax,
|
|||
|
||||
#' Chart parameters
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param type Specify the chart type. Available Options: \code{"bar"}, \code{"column"}, \code{"line"},
|
||||
#' \code{"pie"}, \code{"donut"}, \code{"radialBar"}, \code{"scatter"}, \code{"bubble"}, \code{"heatmap"}.
|
||||
#' @param stacked Logical. Enables stacked option for axis charts.
|
||||
#' @param stackType When stacked, should the stacking be percentage based or normal stacking. Available options: \code{"normal"} or \code{"100\%"}
|
||||
#' @param stackType When stacked, should the stacking be percentage based or normal stacking.
|
||||
#' Available options: \code{"normal"} or \code{"100\%"}.
|
||||
#' @param defaultLocale Locale to use : \code{"ca"}, \code{"cs"}, \code{"de"},
|
||||
#' \code{"el"}, \code{"en"}, \code{"es"}, \code{"fi"}, \code{"fr"}, \code{"he"},
|
||||
#' \code{"hi"}, \code{"hr"}, \code{"hy"}, \code{"id"}, \code{"it"}, \code{"ko"},
|
||||
#' \code{"lt"}, \code{"nb"}, \code{"nl"}, \code{"pl"}, \code{"pt-br"}, \code{"pt"},
|
||||
#' \code{"ru"}, \code{"se"}, \code{"sk"}, \code{"sl"}, \code{"th"}, \code{"tr"},
|
||||
#' \code{"ua"}.
|
||||
#' @param locales Array of custom locales parameters.
|
||||
#' @param animations A list of parameters.
|
||||
#' @param background Background color for the chart area. If you want to set background with css, use \code{.apexcharts-canvas} to set it.
|
||||
#' @param foreColor Sets the text color for the chart. Defaults to \code{#373d3f}.
|
||||
|
@ -150,37 +153,16 @@ ax_annotations <- function(ax,
|
|||
#' @param height Height of the chart.
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#' library(dplyr)
|
||||
#' data("diamonds", package = "ggplot2")
|
||||
#'
|
||||
#' # Stack bar type
|
||||
#' apex(
|
||||
#' data = count(diamonds, cut, color),
|
||||
#' mapping = aes(x = cut, y = n, fill = color)
|
||||
#' ) %>%
|
||||
#' ax_chart(stacked = TRUE)
|
||||
#'
|
||||
#' apex(
|
||||
#' data = count(diamonds, cut, color),
|
||||
#' mapping = aes(x = cut, y = n, fill = color)
|
||||
#' ) %>%
|
||||
#' ax_chart(stacked = TRUE, stackType = "100%")
|
||||
#'
|
||||
#'
|
||||
#' # Toolbar
|
||||
#' apex(
|
||||
#' data = count(diamonds, cut, color),
|
||||
#' mapping = aes(x = cut, y = n, fill = color)
|
||||
#' ) %>%
|
||||
#' ax_chart(toolbar = list(show = FALSE))
|
||||
#' @example examples/ax_chart.R
|
||||
#' @example examples/localization.R
|
||||
ax_chart <- function(ax,
|
||||
type = NULL,
|
||||
stacked = NULL,
|
||||
stackType = NULL,
|
||||
defaultLocale = NULL,
|
||||
locales = NULL,
|
||||
animations = NULL,
|
||||
background = NULL,
|
||||
foreColor = NULL,
|
||||
|
@ -202,24 +184,25 @@ ax_chart <- function(ax,
|
|||
|
||||
#' Specific options for chart
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @param bar See \code{\link{bar_opts}}.
|
||||
#' @param heatmap See \code{\link{heatmap_opts}}.
|
||||
#' @param radialBar See \code{\link{radialBar_opts}}.
|
||||
#' @param pie See \code{\link{pie_opts}}.
|
||||
#' @template ax-default
|
||||
#' @param bar See [bar_opts()].
|
||||
#' @param heatmap See [heatmap_opts()].
|
||||
#' @param radialBar See [radialBar_opts()].
|
||||
#' @param pie See [pie_opts()].
|
||||
#' @param bubble See [bubble_opts()].
|
||||
#' @param boxPlot See [boxplot_opts()].
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#' library(dplyr)
|
||||
#' data("diamonds", package = "ggplot2")
|
||||
#'
|
||||
#' # Stack bar type
|
||||
#' apex(
|
||||
#' data = count(diamonds, cut),
|
||||
#' mapping = aes(x = cut, y = n)
|
||||
#' data = diamonds,
|
||||
#' mapping = aes(x = cut)
|
||||
#' ) %>%
|
||||
#' ax_plotOptions(
|
||||
#' bar = bar_opts(endingShape = "rounded", columnWidth = "10%")
|
||||
|
@ -227,8 +210,8 @@ ax_chart <- function(ax,
|
|||
#'
|
||||
#' # Pie
|
||||
#' apex(
|
||||
#' data = count(diamonds, cut),
|
||||
#' mapping = aes(x = cut, y = n),
|
||||
#' data = diamonds,
|
||||
#' mapping = aes(x = cut),
|
||||
#' type = "pie"
|
||||
#' ) %>%
|
||||
#' ax_plotOptions(
|
||||
|
@ -251,6 +234,8 @@ ax_plotOptions <- function(ax,
|
|||
heatmap = NULL,
|
||||
radialBar = NULL,
|
||||
pie = NULL,
|
||||
bubble = NULL,
|
||||
boxPlot = NULL,
|
||||
...) {
|
||||
params <- c(as.list(environment()), list(...))[-1]
|
||||
.ax_opt2(ax, "plotOptions", l = dropNulls(params))
|
||||
|
@ -259,32 +244,31 @@ ax_plotOptions <- function(ax,
|
|||
|
||||
#' Colors
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @param ... Colors for the chart’s series. When all colors are used, it starts from the beginning.
|
||||
#' @template ax-default
|
||||
#' @param ... Colors for the chart's series. When all colors are used, it starts from the beginning.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/colors/}
|
||||
#'
|
||||
#' @examples
|
||||
#'
|
||||
#' library(dplyr)
|
||||
#' data("diamonds", package = "ggplot2")
|
||||
#'
|
||||
#' # Change default color(s)
|
||||
#' apex(
|
||||
#' data = count(diamonds, cut),
|
||||
#' mapping = aes(x = cut, y = n)
|
||||
#' data = diamonds,
|
||||
#' mapping = aes(x = cut)
|
||||
#' ) %>%
|
||||
#' ax_colors("#F7D358")
|
||||
#'
|
||||
#'
|
||||
#' library(scales)
|
||||
#' apex(
|
||||
#' data = count(diamonds, cut, color),
|
||||
#' mapping = aes(x = cut, y = n, fill = color)
|
||||
#' data = diamonds,
|
||||
#' mapping = aes(x = cut, fill = color)
|
||||
#' ) %>%
|
||||
#' ax_colors(scales::brewer_pal(palette = "Set2")(7))
|
||||
#' ax_colors(brewer_pal(palette = "Set2")(7))
|
||||
ax_colors <- function(ax, ...) {
|
||||
args <- list(...)
|
||||
if (length(args) == 1) {
|
||||
|
@ -296,9 +280,9 @@ ax_colors <- function(ax, ...) {
|
|||
|
||||
#' Labels on data
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param enabled To determine whether to show dataLabels or not.
|
||||
#' @param textAnchor The alignment of text relative to dataLabel’s drawing position.
|
||||
#' @param textAnchor The alignment of text relative to dataLabel's drawing position.
|
||||
#' Accepted values \code{"start"}, \code{"middle"} or \code{"end"}.
|
||||
#' @param offsetX Sets the left offset for dataLabels.
|
||||
#' @param offsetY Sets the top offset for dataLabels.
|
||||
|
@ -307,19 +291,18 @@ ax_colors <- function(ax, ...) {
|
|||
#' @param formatter The formatter function takes in a single value and allows you to format the value before displaying
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/datalabels/}
|
||||
#'
|
||||
#' @examples
|
||||
#' library(dplyr)
|
||||
#' data("diamonds", package = "ggplot2")
|
||||
#'
|
||||
#' # Add data labels
|
||||
#' apex(
|
||||
#' data = count(diamonds, cut),
|
||||
#' mapping = aes(x = cut, y = n)
|
||||
#' data = diamonds,
|
||||
#' mapping = aes(x = cut)
|
||||
#' ) %>%
|
||||
#' ax_dataLabels(enabled = TRUE)
|
||||
ax_dataLabels <- function(ax,
|
||||
|
@ -338,7 +321,7 @@ ax_dataLabels <- function(ax,
|
|||
|
||||
#' Fill property
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param type Whether to fill the paths with solid colors or gradient.
|
||||
#' Available options: \code{"solid"}, \code{"gradient"}, \code{"pattern"} or \code{"image"}.
|
||||
#' @param colors Colors to fill the svg paths..
|
||||
|
@ -348,19 +331,18 @@ ax_dataLabels <- function(ax,
|
|||
#' @param pattern A list of parameters.
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/fill/}
|
||||
#'
|
||||
#' @examples
|
||||
#' library(dplyr)
|
||||
#' data("diamonds", package = "ggplot2")
|
||||
#'
|
||||
#' # Use a pattern to fill bars
|
||||
#' apex(
|
||||
#' data = count(diamonds, cut, color),
|
||||
#' mapping = aes(x = color, y = n, fill = cut)
|
||||
#' data = diamonds,
|
||||
#' mapping = aes(x = color, fill = cut)
|
||||
#' ) %>%
|
||||
#' ax_fill(
|
||||
#' type = "pattern",
|
||||
|
@ -402,7 +384,7 @@ ax_fill <- function(ax,
|
|||
|
||||
#' Add grids on chart
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param show Logical. To show or hide grid area (including xaxis / yaxis)
|
||||
#' @param borderColor Colors of grid borders / lines.
|
||||
#' @param strokeDashArray Creates dashes in borders of svg path. Higher number creates more space between dashes in the border.
|
||||
|
@ -414,26 +396,25 @@ ax_fill <- function(ax,
|
|||
#' @param padding A list of parameters.
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/grid/}
|
||||
#'
|
||||
#' @examples
|
||||
#' library(dplyr)
|
||||
#' data("mpg", package = "ggplot2")
|
||||
#'
|
||||
#' # Hide Y-axis and gridelines
|
||||
#' apex(
|
||||
#' data = count(mpg, manufacturer),
|
||||
#' mapping = aes(x = manufacturer, y = n)
|
||||
#' data = mpg,
|
||||
#' mapping = aes(x = manufacturer)
|
||||
#' ) %>%
|
||||
#' ax_grid(show = FALSE)
|
||||
#'
|
||||
#' # just grid lines
|
||||
#' apex(
|
||||
#' data = count(mpg, manufacturer),
|
||||
#' mapping = aes(x = manufacturer, y = n)
|
||||
#' data = mpg,
|
||||
#' mapping = aes(x = manufacturer)
|
||||
#' ) %>%
|
||||
#' ax_grid(yaxis = list(lines = list(show = FALSE)))
|
||||
#'
|
||||
|
@ -467,12 +448,12 @@ ax_grid <- function(ax,
|
|||
|
||||
#' Alternative axis labels
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param labels A vector to use as labels.
|
||||
#' @param ... Vector. In Axis Charts (line / column), labels can be set instead of setting xaxis categories
|
||||
#' option. While, in pie/donut charts, each label corresponds to value in series array.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @name ax_labels
|
||||
|
@ -503,15 +484,15 @@ ax_labels2 <- function(ax, labels) {
|
|||
|
||||
#' Legend properties
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param show Logical. Whether to show or hide the legend container.
|
||||
#' @param position Available position options for legend: \code{"top"}, \code{"right"}, \code{"bottom"}, \code{"left"}.
|
||||
#' @param showForSingleSeries Show legend even if there is just 1 series.
|
||||
#' @param showForNullSeries Allows you to hide a particular legend if it’s series contains all null values.
|
||||
#' @param showForZeroSeries Allows you to hide a particular legend if it’s series contains all 0 values.
|
||||
#' @param showForNullSeries Allows you to hide a particular legend if it's series contains all null values.
|
||||
#' @param showForZeroSeries Allows you to hide a particular legend if it's series contains all 0 values.
|
||||
#' @param horizontalAlign Available options for horizontal alignment: \code{"right"}, \code{"center"}, \code{"left"}.
|
||||
#' @param fontSize Sets the fontSize of legend text elements
|
||||
#' @param textAnchor The alignment of text relative to legend’s drawing position
|
||||
#' @param textAnchor The alignment of text relative to legend's drawing position
|
||||
#' @param offsetY Sets the top offset for legend container.
|
||||
#' @param offsetX Sets the left offset for legend container.
|
||||
#' @param formatter JS function. A custom formatter function to append additional text to the legend series names.
|
||||
|
@ -529,26 +510,25 @@ ax_labels2 <- function(ax, labels) {
|
|||
#' @param floating Logical. The floating option will take out the legend from the chart area and make it float above the chart.
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/legend/}
|
||||
#'
|
||||
#' @examples
|
||||
#' library(dplyr)
|
||||
#' data("mpg", package = "ggplot2")
|
||||
#'
|
||||
#' # Legend position
|
||||
#' apex(
|
||||
#' data = count(mpg, manufacturer, year),
|
||||
#' mapping = aes(x = manufacturer, y = n, fill = year)
|
||||
#' data = mpg,
|
||||
#' mapping = aes(x = manufacturer, fill = year)
|
||||
#' ) %>%
|
||||
#' ax_legend(position = "right")
|
||||
#'
|
||||
#' # hide legend
|
||||
#' apex(
|
||||
#' data = count(mpg, manufacturer, year),
|
||||
#' mapping = aes(x = manufacturer, y = n, fill = year)
|
||||
#' data = mpg,
|
||||
#' mapping = aes(x = manufacturer, fill = year)
|
||||
#' ) %>%
|
||||
#' ax_legend(show = FALSE)
|
||||
ax_legend <- function(ax,
|
||||
|
@ -578,7 +558,7 @@ ax_legend <- function(ax,
|
|||
|
||||
#' Markers properties
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param size Numeric. Size of the marker point.
|
||||
#' @param colors Sets the fill color(s) of the marker point.
|
||||
#' @param strokeColor Stroke Color of the marker.
|
||||
|
@ -592,7 +572,7 @@ ax_legend <- function(ax,
|
|||
#' @param hover List with item \code{size} (Size of the marker when it is active).
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/markers/}
|
||||
|
@ -627,7 +607,7 @@ ax_markers <- function(ax,
|
|||
|
||||
#' No data specification
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param text
|
||||
#' @param align
|
||||
#' @param verticalAlign
|
||||
|
@ -636,7 +616,7 @@ ax_markers <- function(ax,
|
|||
#' @param style
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @noRd
|
||||
#'
|
||||
ax_noData <- function(ax,
|
||||
|
@ -654,22 +634,21 @@ ax_noData <- function(ax,
|
|||
|
||||
#' Responsive options
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/responsive/}
|
||||
#'
|
||||
#' @examples
|
||||
#' library(dplyr)
|
||||
#' data("mpg", package = "ggplot2")
|
||||
#'
|
||||
#' # Open in browser and resize window
|
||||
#' apex(
|
||||
#' data = count(mpg, manufacturer, year),
|
||||
#' mapping = aes(x = manufacturer, y = n, fill = year),
|
||||
#' data = mpg,
|
||||
#' mapping = aes(x = manufacturer, fill = year),
|
||||
#' type = "bar"
|
||||
#' ) %>%
|
||||
#' ax_legend(position = "right") %>%
|
||||
|
@ -695,10 +674,10 @@ ax_responsive <- function(ax, ...) {
|
|||
|
||||
#' Add data to a chart
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param ... Lists containing data to plot, typically list with two items: \code{name} and \code{data}.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @name ax-series
|
||||
|
@ -738,25 +717,24 @@ ax_series2 <- function(ax, l) {
|
|||
|
||||
#' Charts' states
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param normal A list of parameters.
|
||||
#' @param hover A list of parameters.
|
||||
#' @param active A list of parameters.
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/states/}
|
||||
#'
|
||||
#' @examples
|
||||
#' library(dplyr)
|
||||
#' data("mpg", package = "ggplot2")
|
||||
#'
|
||||
#' # Inverse effect on hover
|
||||
#' apex(
|
||||
#' data = count(mpg, manufacturer),
|
||||
#' mapping = aes(x = manufacturer, y = n),
|
||||
#' data = mpg,
|
||||
#' mapping = aes(x = manufacturer),
|
||||
#' type = "bar"
|
||||
#' ) %>%
|
||||
#' ax_states(
|
||||
|
@ -778,7 +756,7 @@ ax_states <- function(ax,
|
|||
|
||||
#' Chart's title
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param text Text to display as a title of chart.
|
||||
#' @param align Alignment of subtitle relative to chart area. Possible Options: \code{"left"}, \code{"center"} and \code{"right"}.
|
||||
#' @param margin Numeric. Vertical spacing around the title text.
|
||||
|
@ -788,7 +766,7 @@ ax_states <- function(ax,
|
|||
#' @param style List with two items: \code{fontSize} (Font Size of the title text) and \code{color} (Fore color of the title text).
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/title/}
|
||||
|
@ -819,7 +797,7 @@ ax_title <- function(ax,
|
|||
|
||||
#' Chart's subtitle
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param text Text to display as a subtitle of chart.
|
||||
#' @param align Alignment of subtitle relative to chart area. Possible Options: \code{"left"}, \code{"center"} and \code{"right"}.
|
||||
#' @param margin Numeric. Vertical spacing around the subtitle text.
|
||||
|
@ -829,7 +807,7 @@ ax_title <- function(ax,
|
|||
#' @param style List with two items: \code{fontSize} (Font Size of the subtitle text) and \code{color} (Fore color of the subtitle text).
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/subtitle/}
|
||||
|
@ -863,7 +841,7 @@ ax_subtitle <- function(ax,
|
|||
|
||||
#' Stroke properties
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param show Logical. To show or hide path-stroke / line
|
||||
#' @param curve In line / area charts, whether to draw smooth lines or straight lines.
|
||||
#' Available Options: \code{"smooth"} (connects the points in a curve fashion. Also known as spline)
|
||||
|
@ -877,7 +855,7 @@ ax_subtitle <- function(ax,
|
|||
#' @param dashArray Creates dashes in borders of svg path. Higher number creates more space between dashes in the border.
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/stroke/}
|
||||
|
@ -919,10 +897,10 @@ ax_stroke <- function(ax,
|
|||
|
||||
#' Tooltip options
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param enabled Logical. Show tooltip when user hovers over chart area.
|
||||
#' @param shared Logical. When having multiple series, show a shared tooltip.
|
||||
#' @param followCursor Logical. Follow user’s cursor position instead of putting tooltip on actual data points.
|
||||
#' @param followCursor Logical. Follow user's cursor position instead of putting tooltip on actual data points.
|
||||
#' @param intersect Logical. Show tooltip only when user hovers exactly over datapoint.
|
||||
#' @param inverseOrder Logical. In multiple series, when having shared tooltip, inverse the order of series (for better comparison in stacked charts).
|
||||
#' @param custom JS function. Draw a custom html tooltip instead of the default one based on the values provided in the function arguments.
|
||||
|
@ -937,26 +915,25 @@ ax_stroke <- function(ax,
|
|||
#' @param fixed A list of parameters.
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/tooltip/}
|
||||
#'
|
||||
#' @examples
|
||||
#' library(dplyr)
|
||||
#' data("mpg", package = "ggplot2")
|
||||
#'
|
||||
#' # Hide tooltip
|
||||
#' apex(
|
||||
#' data = count(mpg, manufacturer, year),
|
||||
#' mapping = aes(x = manufacturer, y = n, fill = year)
|
||||
#' data = mpg,
|
||||
#' mapping = aes(x = manufacturer, fill = year)
|
||||
#' ) %>%
|
||||
#' ax_tooltip(enabled = FALSE)
|
||||
#'
|
||||
#' # Share between series
|
||||
#' apex(
|
||||
#' data = count(mpg, manufacturer, year),
|
||||
#' mapping = aes(x = manufacturer, y = n, fill = year)
|
||||
#' data = mpg,
|
||||
#' mapping = aes(x = manufacturer, fill = year)
|
||||
#' ) %>%
|
||||
#' ax_tooltip(shared = TRUE)
|
||||
#'
|
||||
|
@ -994,7 +971,7 @@ ax_tooltip <- function(ax,
|
|||
|
||||
#' X-axis options
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param type Character. Available Options : \code{"categories"} and \code{"datetime"}.
|
||||
#' @param categories Categories are labels which are displayed on the x-axis.
|
||||
#' @param labels A list of parameters.
|
||||
|
@ -1013,33 +990,32 @@ ax_tooltip <- function(ax,
|
|||
#' @param tooltip A list of parameters.
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/xaxis/}
|
||||
#'
|
||||
#' @examples
|
||||
#' library(dplyr)
|
||||
#' data("mpg", package = "ggplot2")
|
||||
#'
|
||||
#' # X axis title
|
||||
#' apex(
|
||||
#' data = count(mpg, manufacturer),
|
||||
#' mapping = aes(x = manufacturer, y = n)
|
||||
#' data = mpg,
|
||||
#' mapping = aes(x = manufacturer)
|
||||
#' ) %>%
|
||||
#' ax_xaxis(title = list(text = "Car's manufacturer"))
|
||||
#'
|
||||
#' # force labels to rotate and increase height
|
||||
#' apex(
|
||||
#' data = count(mpg, manufacturer),
|
||||
#' mapping = aes(x = manufacturer, y = n)
|
||||
#' data = mpg,
|
||||
#' mapping = aes(x = manufacturer)
|
||||
#' ) %>%
|
||||
#' ax_xaxis(labels = list(rotateAlways = TRUE, maxHeight = 180))
|
||||
#'
|
||||
#' # force to not rotate
|
||||
#' apex(
|
||||
#' data = count(mpg, manufacturer),
|
||||
#' mapping = aes(x = manufacturer, y = n)
|
||||
#' data = mpg,
|
||||
#' mapping = aes(x = manufacturer)
|
||||
#' ) %>%
|
||||
#' ax_xaxis(labels = list(rotate = 0, trim = FALSE))
|
||||
#'
|
||||
|
@ -1100,7 +1076,7 @@ ax_xaxis <- function(ax,
|
|||
|
||||
#' Y-axis options
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param opposite Logical. When enabled, will draw the yaxis on the right side of the chart.
|
||||
#' @param tickAmount Number of Tick Intervals to show.
|
||||
#' @param max Lowest number to be set for the y-axis. The graph drawing beyond this number will be clipped off.
|
||||
|
@ -1115,7 +1091,7 @@ ax_xaxis <- function(ax,
|
|||
#' @param crosshairs A list of parameters.
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/yaxis/}
|
||||
|
@ -1139,7 +1115,7 @@ ax_xaxis <- function(ax,
|
|||
#' apex(temperature, aes(month, tp), "line") %>%
|
||||
#' ax_yaxis(
|
||||
#' labels = list(
|
||||
#' formatter = htmlwidgets::JS("function(value) {return value + '°C';}")
|
||||
#' formatter = htmlwidgets::JS("function(value) {return value + '\u00b0C';}")
|
||||
#' )
|
||||
#' )
|
||||
ax_yaxis <- function(ax,
|
||||
|
@ -1169,25 +1145,13 @@ ax_yaxis <- function(ax,
|
|||
|
||||
#' Secondary Y-axis options
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param ... See arguments from \code{\link{ax_yaxis}}.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#'
|
||||
#' library(dplyr)
|
||||
#' data("economics_long", package = "ggplot2")
|
||||
#'
|
||||
#' eco <- economics_long %>%
|
||||
#' filter(variable %in% c("pce", "pop")) %>%
|
||||
#' filter(date >= "2000-01-01")
|
||||
#'
|
||||
#' apex(eco, aes(x = date, y = value, color = variable), type = "line") %>%
|
||||
#' ax_yaxis(title = list(text = "Pce")) %>%
|
||||
#' ax_yaxis2(opposite = TRUE, title = list(text = "Pop"))
|
||||
#'
|
||||
#' @example examples/ax_yaxis2.R
|
||||
ax_yaxis2 <- function(ax, ...) {
|
||||
params <- dropNulls(list(...))
|
||||
yaxis <- .get_ax_opt(ax, "yaxis")
|
||||
|
@ -1206,40 +1170,38 @@ ax_yaxis2 <- function(ax, ...) {
|
|||
|
||||
#' Theme for charts
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param mode use light or dark theme.
|
||||
#' @param palette Character. Available palettes: \code{"palette1"} to \code{"palette10"}.
|
||||
#' @param monochrome A list of parameters.
|
||||
#' @param ... Additional parameters.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @export
|
||||
#'
|
||||
#' @note See \url{https://apexcharts.com/docs/options/theme/}
|
||||
#'
|
||||
#' @examples
|
||||
#' library(dplyr)
|
||||
#' data("mpg", package = "ggplot2")
|
||||
#' data("diamonds", package = "ggplot2")
|
||||
#'
|
||||
#' # Dark mode
|
||||
#' apex(
|
||||
#' data = count(mpg, manufacturer),
|
||||
#' mapping = aes(x = manufacturer, y = n)
|
||||
#' data = mpg,
|
||||
#' mapping = aes(x = manufacturer)
|
||||
#' ) %>%
|
||||
#' ax_theme(mode = "dark")
|
||||
#'
|
||||
#' # Use predefined palette (1 to 10)
|
||||
#' apex(
|
||||
#' data = count(diamonds, cut, color),
|
||||
#' mapping = aes(x = color, y = n, fill = cut)
|
||||
#' data = diamonds,
|
||||
#' mapping = aes(x = color, fill = cut)
|
||||
#' ) %>%
|
||||
#' ax_theme(palette = "palette2")
|
||||
#'
|
||||
#' # monochrome palette
|
||||
#' apex(
|
||||
#' data = count(diamonds, cut, color),
|
||||
#' mapping = aes(x = color, y = n, fill = cut)
|
||||
#' data = diamonds,
|
||||
#' mapping = aes(x = color, fill = cut)
|
||||
#' ) %>%
|
||||
#' ax_theme(monochrome = list(enabled = TRUE, color = "#0B6121"))
|
||||
ax_theme <- function(ax,
|
||||
|
@ -1252,6 +1214,105 @@ ax_theme <- function(ax,
|
|||
mode = mode,
|
||||
palette = palette,
|
||||
monochrome = monochrome
|
||||
), list(...))[-1]
|
||||
), list(...))
|
||||
.ax_opt2(ax, "theme", l = dropNulls(params))
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#' Configuration for charts with no data
|
||||
#'
|
||||
#' @template ax-default
|
||||
#' @param text The text to display when no-data is available.
|
||||
#' @param align Horizontal alignment: \code{"left"}, \code{"center"} or \code{"right"}.
|
||||
#' @param verticalAlign Vertical alignment: \code{"top"}, \code{"middle"} or \code{"bottom"}.
|
||||
#' @param color ForeColor of the text.
|
||||
#' @param fontSize FontSize of the text.
|
||||
#' @param fontFamily FontFamily of the text.
|
||||
#' @param offsetX,offsetY Text offset.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#' empty <- data.frame(
|
||||
#' var1 = character(0),
|
||||
#' var2 = numeric(0)
|
||||
#' )
|
||||
#' apex(empty, aes(var1, var2), "column") %>%
|
||||
#' ax_nodata(
|
||||
#' text = "Sorry no data to visualize",
|
||||
#' fontSize = "30px"
|
||||
#' )
|
||||
ax_nodata <- function(ax,
|
||||
text = "No data",
|
||||
align = "center",
|
||||
verticalAlign = "middle",
|
||||
color = NULL,
|
||||
fontSize = NULL,
|
||||
fontFamily = NULL,
|
||||
offsetX = NULL,
|
||||
offsetY = NULL) {
|
||||
params <- list(
|
||||
text = text,
|
||||
align = align,
|
||||
verticalAlign = verticalAlign,
|
||||
offsetX = offsetX,
|
||||
offsetY = offsetY,
|
||||
style = dropNulls(list(
|
||||
color = color,
|
||||
fontSize = fontSize,
|
||||
fontFamily = fontFamily
|
||||
))
|
||||
)
|
||||
.ax_opt2(ax, "noData", l = dropNulls(params))
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#' Forecast data points
|
||||
#'
|
||||
#' @template ax-default
|
||||
#' @param count Number of ending data-points you want to indicate as a forecast or prediction values.
|
||||
#' The ending line/bar will result into a dashed border with a distinct look to differentiate from the rest of the data-points.
|
||||
#' @param fillOpacity Opacity of the fill attribute.
|
||||
#' @param strokeWidth Sets the width of the points.
|
||||
#' @param dashArray Creates dashes in borders of svg path. Higher number creates more space between dashes in the border.
|
||||
#' @param ... Additional arguments (not used).
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#' # add 5 predictions to data then plot it
|
||||
#' data.frame(
|
||||
#' time = seq_len(53),
|
||||
#' lh = c(
|
||||
#' as.vector(lh),
|
||||
#' as.vector(predict(arima(lh, order = c(1,0,1)), 5)$pred)
|
||||
#' )
|
||||
#' ) %>%
|
||||
#' apex(aes(time, lh), type = "line") %>%
|
||||
#' ax_xaxis(type = "numeric") %>%
|
||||
#' ax_forecast_data_points(count = 5)
|
||||
ax_forecast_data_points <- function(ax,
|
||||
count = NULL,
|
||||
fillOpacity = NULL,
|
||||
strokeWidth = NULL,
|
||||
dashArray = NULL,
|
||||
...) {
|
||||
params <- list(
|
||||
count = count,
|
||||
fillOpacity = fillOpacity,
|
||||
strokeWidth = strokeWidth,
|
||||
dashArray = dashArray
|
||||
)
|
||||
.ax_opt2(ax, "forecastDataPoints", l = dropNulls(params))
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
442
R/apex.R
442
R/apex.R
|
@ -1,71 +1,79 @@
|
|||
|
||||
#' @title Quick ApexChart
|
||||
#'
|
||||
#' @description Initialize a chart with three main parameters : data, mapping and type of chart.
|
||||
#' @title Quick ApexCharts
|
||||
#'
|
||||
#' @param data Default dataset to use for chart. If not already a \code{data.frame}, it will be coerced to with \code{as.data.frame}.
|
||||
#' @description Initialize a chart with three main parameters :
|
||||
#' data, mapping and type of chart.
|
||||
#'
|
||||
#' @param data Default dataset to use for chart. If not already
|
||||
#' a `data.frame`, it will be coerced to with `as.data.frame`.
|
||||
#' @param mapping Default list of aesthetic mappings to use for chart
|
||||
#' @param type Specify the chart type. Available Options: \code{"column"}, \code{"bar"}, \code{"line"},
|
||||
#' \code{"area"}, \code{"spline"}, \code{"pie"}, \code{"donut"}, \code{"radialBar"}, \code{"radar"}, \code{"scatter"}, \code{"heatmap"}.
|
||||
#' @param type Specify the chart type. Available options:
|
||||
#' `"column"`, `"bar"`,
|
||||
#' `"line"`, `"step"`, `"spline"`,
|
||||
#' `"area"`, `"area-step"`, `"area-spline"`,
|
||||
#' `"pie"`, `"donut"`,
|
||||
#' `"radialBar"`, `"radar"`, `"scatter"`,
|
||||
#' `"heatmap"`, `"treemap"`,
|
||||
#' `"timeline"`, `"dumbbell"` and `"slope"`.
|
||||
#' @param ... Other arguments passed on to methods. Not currently used.
|
||||
#' @param auto_update In Shiny application, update existing chart rather than generating new one.
|
||||
#' @param width A numeric input in pixels.
|
||||
#' @param height A numeric input in pixels.
|
||||
#' @param elementId Use an explicit element ID for the widget.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @param synchronize Give a common id to charts to synchronize them (tooltip and zoom).
|
||||
#' @param serie_name Name for the serie displayed in tooltip,
|
||||
#' only used for single serie.
|
||||
#' @inheritParams apexchart
|
||||
#'
|
||||
#' @return An [apexchart()] `htmlwidget` object.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#'
|
||||
#' @importFrom rlang eval_tidy as_label
|
||||
#' @importFrom utils modifyList
|
||||
#' @importFrom stats complete.cases
|
||||
#'
|
||||
#' @examples
|
||||
#' library(dplyr)
|
||||
#'
|
||||
#'
|
||||
#' # make a barchart with a frequency table
|
||||
#' data("mpg", package = "ggplot2")
|
||||
#' apex(
|
||||
#' data = count(mpg, manufacturer),
|
||||
#' mapping = aes(x = manufacturer, y = n),
|
||||
#' type = "bar"
|
||||
#' )
|
||||
#'
|
||||
#' # timeseries
|
||||
#' data("economics", package = "ggplot2")
|
||||
#' apex(
|
||||
#' data = economics,
|
||||
#' mapping = aes(x = date, y = uempmed),
|
||||
#' type = "line"
|
||||
#' )
|
||||
#'
|
||||
#' # you can add option to apex result :
|
||||
#' apex(
|
||||
#' data = economics,
|
||||
#' mapping = aes(x = date, y = uempmed),
|
||||
#' type = "line"
|
||||
#' ) %>%
|
||||
#' ax_stroke(width = 1)
|
||||
#'
|
||||
#'
|
||||
#'
|
||||
#' # with group variable
|
||||
#' data("economics_long", package = "ggplot2")
|
||||
#' apex(
|
||||
#' data = economics_long,
|
||||
#' mapping = aes(x = date, y = value01, group = variable),
|
||||
#' type = "line"
|
||||
#' )
|
||||
apex <- function(data, mapping, type = "column", ..., auto_update = TRUE, width = NULL, height = NULL, elementId = NULL) {
|
||||
type <- match.arg(type, c("column", "bar", "line", "area", "spline", "area-spline",
|
||||
"pie", "donut", "radialBar", "radar", "scatter", "heatmap"))
|
||||
#' @example examples/apex.R
|
||||
apex <- function(data, mapping,
|
||||
type = "column",
|
||||
...,
|
||||
auto_update = TRUE,
|
||||
synchronize = NULL,
|
||||
serie_name = NULL,
|
||||
width = NULL,
|
||||
height = NULL,
|
||||
elementId = NULL) {
|
||||
type <- match.arg(
|
||||
arg = type,
|
||||
choices = c(
|
||||
"column", "bar",
|
||||
"rangeBar", "dumbbell",
|
||||
"line", "spline", "step", "slope",
|
||||
"area", "area-spline", "area-step",
|
||||
"rangeArea",
|
||||
"pie", "donut",
|
||||
"radialBar",
|
||||
"radar",
|
||||
"polarArea",
|
||||
"scatter", "bubble",
|
||||
"heatmap",
|
||||
"treemap",
|
||||
"timeline",
|
||||
"candlestick",
|
||||
"boxplot"
|
||||
)
|
||||
)
|
||||
data <- as.data.frame(data)
|
||||
if (identical(type, "heatmap")) {
|
||||
mapping <- rename_aes_heatmap(mapping)
|
||||
} else {
|
||||
mapping <- rename_aes(mapping)
|
||||
}
|
||||
if (identical(type, "scatter") & is_sized(mapping)) {
|
||||
type <- "bubble"
|
||||
}
|
||||
mapdata <- lapply(mapping, rlang::eval_tidy, data = data)
|
||||
if (type %in% c("pie", "donut", "radialBar")) {
|
||||
type_no_compute <- c("candlestick", "boxplot", "timeline", "heatmap", "rangeArea", "rangeBar", "dumbbell", "slope")
|
||||
if (is.null(mapdata$y) & !type %in% type_no_compute) {
|
||||
mapdata <- compute_count(mapdata)
|
||||
}
|
||||
if (type %in% c("pie", "donut", "radialBar", "polarArea")) {
|
||||
opts <- list(
|
||||
chart = list(type = correct_type(type)),
|
||||
series = list1(mapdata$y),
|
||||
|
@ -73,58 +81,142 @@ apex <- function(data, mapping, type = "column", ..., auto_update = TRUE, width
|
|||
)
|
||||
} else {
|
||||
opts <- list(
|
||||
chart = list(type = correct_type(type)),
|
||||
series = make_series(mapdata, mapping, type)
|
||||
chart = dropNulls(list(
|
||||
type = correct_type(type),
|
||||
group = synchronize
|
||||
)),
|
||||
series = make_series(mapdata, mapping, type, serie_name)
|
||||
)
|
||||
}
|
||||
if (!is.null(synchronize)) {
|
||||
opts$yaxis$labels$minWidth <- 15
|
||||
}
|
||||
opts <- modifyList(opts, choose_config(type, mapdata))
|
||||
apexchart(
|
||||
ax_opts = opts, width = width, height = height,
|
||||
elementId = elementId, auto_update = auto_update
|
||||
if (isTRUE(getOption("apex.axis.light", default = TRUE))) {
|
||||
opts$yaxis$labels$style$colors <- "#848484"
|
||||
opts$xaxis$labels$style$colors <- "#848484"
|
||||
}
|
||||
ax <- apexchart(
|
||||
ax_opts = opts,
|
||||
width = width,
|
||||
height = height,
|
||||
elementId = elementId,
|
||||
auto_update = auto_update
|
||||
)
|
||||
if (inherits(mapdata$x, c("character", "Date", "POSIXt", "numeric", "integer")) & length(mapdata$x) > 0) {
|
||||
ax$x$xaxis <- list(
|
||||
min = min(mapdata$x, na.rm = TRUE),
|
||||
max = max(mapdata$x, na.rm = TRUE)
|
||||
)
|
||||
}
|
||||
ax$x$data <- data
|
||||
ax$x$mapping <- mapping
|
||||
ax$x$type <- type
|
||||
ax$x$serie_name <- serie_name
|
||||
class(ax) <- c(class(ax), "apex")
|
||||
return(ax)
|
||||
}
|
||||
|
||||
|
||||
# Construct series
|
||||
make_series <- function(mapdata, mapping, type) {
|
||||
mapdata <- as.data.frame(mapdata)
|
||||
series_names <- "Series"
|
||||
if (is_x_datetime(mapdata)) {
|
||||
add_names <- FALSE
|
||||
#' @importFrom rlang %||%
|
||||
make_series <- function(mapdata, mapping, type = NULL, serie_name = NULL, force_datetime_names = FALSE) {
|
||||
if (identical(type, "boxplot")) {
|
||||
series <- parse_boxplot_data(mapdata, serie_name = serie_name)
|
||||
} else if (identical(type, "candlestick")) {
|
||||
if (!all(c("x", "open", "high", "low", "close") %in% names(mapping)))
|
||||
stop("For candlestick charts 'x', 'open', 'high', 'low', and 'close' aesthetics must be provided.", call. = FALSE)
|
||||
if (!is.null(mapdata$group))
|
||||
warning("'group' aesthetic in candlestick chart is not supported", call. = FALSE)
|
||||
mapdata$group <- NULL
|
||||
series <- parse_candlestick_data(mapdata)
|
||||
} else if (isTRUE(type %in% c("rangeBar", "timeline"))) {
|
||||
if (!all(c("x", "start", "end") %in% names(mapping)))
|
||||
stop("For timeline charts 'x', 'start', and 'end' aesthetics must be provided.", call. = FALSE)
|
||||
if (is.null(mapdata$group))
|
||||
mapdata$group <- serie_name %||% rlang::as_label(mapping$x)
|
||||
series <- parse_timeline_data(mapdata)
|
||||
} else if (isTRUE(type %in% c("dumbbell"))) {
|
||||
if (!all(c("y", "x", "xend") %in% names(mapping)))
|
||||
stop("For dumbbell charts 'x', 'xend', and 'y' aesthetics must be provided.", call. = FALSE)
|
||||
if (is.null(mapdata$group))
|
||||
mapdata$group <- serie_name %||% rlang::as_label(mapping$x)
|
||||
series <- parse_dumbbell_data(mapdata)
|
||||
} else {
|
||||
add_names <- names(mapping)
|
||||
}
|
||||
if (!is.null(mapping$y))
|
||||
series_names <- rlang::as_label(mapping$y)
|
||||
series <- list(list(
|
||||
name = series_names,
|
||||
data = parse_df(mapdata, add_names = add_names)
|
||||
))
|
||||
if (is_grouped(names(mapping))) {
|
||||
mapdata <- rename_aes(mapdata)
|
||||
series <- lapply(
|
||||
X = unique(mapdata$group),
|
||||
FUN = function(x) {
|
||||
data <- mapdata[mapdata$group %in% x, ]
|
||||
data <- data[, setdiff(names(data), "group"), drop = FALSE]
|
||||
list(
|
||||
name = x,
|
||||
data = parse_df(
|
||||
data = data,
|
||||
add_names = add_names
|
||||
)
|
||||
)
|
||||
mapdata <- as.data.frame(mapdata, stringsAsFactors = FALSE)
|
||||
if (all(rlang::has_name(mapdata, c("ymin", "ymax")))) {
|
||||
mapdata$y <- lapply(
|
||||
X = seq_len(nrow(mapdata)),
|
||||
FUN = function(i) {
|
||||
list(mapdata$ymin[i], mapdata$ymax[i])
|
||||
}
|
||||
)
|
||||
mapdata$ymin <- mapdata$ymax <- NULL
|
||||
}
|
||||
if (isTRUE(type %in% c("scatter", "bubble"))) {
|
||||
complete <- complete.cases(mapdata[c("x", "y")])
|
||||
n_missing <- sum(!complete)
|
||||
if (n_missing > 0) {
|
||||
mapdata <- mapdata[complete, ]
|
||||
warning(sprintf("apex: Removed %s rows containing missing values", n_missing), call. = FALSE)
|
||||
}
|
||||
)
|
||||
}
|
||||
if (is.character(mapdata$x))
|
||||
mapdata$x[is.na(mapdata$x)] <- "NA"
|
||||
x_order <- unique(mapdata$x)
|
||||
if (is_x_datetime(mapdata) & !identical(type, "rangeArea")) {
|
||||
add_names <- force_datetime_names
|
||||
x_order <- sort(x_order)
|
||||
} else {
|
||||
add_names <- names(mapdata)
|
||||
}
|
||||
if (is.null(serie_name) & !is.null(mapping$y))
|
||||
serie_name <- rlang::as_label(mapping$y)
|
||||
series <- list(dropNulls(list(
|
||||
name = as.character(serie_name),
|
||||
type = multi_type(type),
|
||||
data = parse_df(mapdata, add_names = add_names)
|
||||
)))
|
||||
if (is_grouped(mapping)) {
|
||||
mapdata <- rename_aes(mapdata)
|
||||
len_grp <- tapply(as.character(mapdata$group), as.character(mapdata$group), length)
|
||||
if (length(unique(len_grp)) > 1 & !isTRUE(type %in% c("scatter", "bubble"))) {
|
||||
warning("apex: all groups must have same length! You can use `tidyr::complete` for this.")
|
||||
}
|
||||
series <- lapply(
|
||||
X = unique(mapdata$group),
|
||||
FUN = function(x) {
|
||||
data <- mapdata[mapdata$group %in% x, ]
|
||||
data <- data[, setdiff(names(data), "group"), drop = FALSE]
|
||||
data <- data[order(match(x = data[["x"]], table = x_order, nomatch = 0L)), , drop = FALSE]
|
||||
dropNulls(list(
|
||||
name = as.character(x),
|
||||
type = multi_type(type),
|
||||
data = parse_df(
|
||||
data = data,
|
||||
add_names = add_names
|
||||
)
|
||||
))
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
series
|
||||
}
|
||||
|
||||
is_grouped <- function(x) {
|
||||
any(c("colour", "fill", "group") %in% x)
|
||||
any(c("colour", "fill", "group") %in% names(x))
|
||||
}
|
||||
|
||||
is_sized <- function(x) {
|
||||
any(c("size", "z") %in% names(x))
|
||||
}
|
||||
|
||||
#' @importFrom rlang quo
|
||||
rename_aes_heatmap <- function(mapping) {
|
||||
if (is.null(mapping["x"]))
|
||||
stop("apex(..., type = 'heatmap') must have an 'x' aesthetic", call. = FALSE)
|
||||
mapping[["x"]] <- quo(as.character(!!mapping[["x"]]))
|
||||
n_mapping <- names(mapping)
|
||||
n_mapping[n_mapping == "y"] <- "group"
|
||||
if ("fill" %in% n_mapping) {
|
||||
|
@ -144,6 +236,9 @@ rename_aes <- function(mapping) {
|
|||
if ("fill" %in% names(mapping)) {
|
||||
names(mapping)[names(mapping) == "fill"] <- "group"
|
||||
}
|
||||
if ("size" %in% names(mapping)) {
|
||||
names(mapping)[names(mapping) == "size"] <- "z"
|
||||
}
|
||||
mapping
|
||||
}
|
||||
|
||||
|
@ -161,24 +256,67 @@ list1 <- function(x) {
|
|||
|
||||
# Change type of charts for helpers type
|
||||
correct_type <- function(type) {
|
||||
if (identical(type, "column")) {
|
||||
if (isTRUE(type %in% c("column"))) {
|
||||
"bar"
|
||||
} else if (identical(type, "spline")) {
|
||||
} else if (isTRUE(type %in% c("spline", "step", "slope"))) {
|
||||
"line"
|
||||
} else if (isTRUE(type %in% c("area-spline", "area-step"))) {
|
||||
"area"
|
||||
} else if (isTRUE(type %in% c("timeline", "dumbbell"))) {
|
||||
"rangeBar"
|
||||
} else if (identical(type, "boxplot")) {
|
||||
"boxPlot"
|
||||
} else {
|
||||
type
|
||||
}
|
||||
}
|
||||
|
||||
range_num <- function(x) {
|
||||
if (is.numeric(x)) {
|
||||
range(pretty(x))
|
||||
multi_type <- function(x) {
|
||||
multis <- c("column", "area", "line",
|
||||
"spline", "step", "scatter",
|
||||
"bubble", "rangeArea")
|
||||
if (isTRUE(x %in% multis)) {
|
||||
correct_type(x)
|
||||
} else {
|
||||
NULL
|
||||
}
|
||||
}
|
||||
|
||||
range_num <- function(x) {
|
||||
if (is.numeric(x) & length(x) > 0) {
|
||||
p <- pretty(x)
|
||||
list(
|
||||
values = p,
|
||||
n = length(p) - 1,
|
||||
range = range(p)
|
||||
)
|
||||
} else {
|
||||
NULL
|
||||
}
|
||||
}
|
||||
|
||||
#' @importFrom rlang %||%
|
||||
compute_count <- function(mapdata) {
|
||||
if (!is_grouped(mapdata)) {
|
||||
x <- mapdata$x
|
||||
weight <- mapdata$weight %||% rep(1, length(x))
|
||||
count <- tapply(weight, x, sum, na.rm = TRUE, simplify = FALSE)
|
||||
mapdata$x <- names(count)
|
||||
mapdata$y <- as.numeric(count)
|
||||
} else {
|
||||
weight <- mapdata$weight %||% rep(1, length(mapdata$x))
|
||||
count <- tapply(weight, mapdata[c("x", "group")], sum, na.rm = TRUE, simplify = FALSE)
|
||||
mapdata$x <- rep(rownames(count), ncol(count))
|
||||
mapdata$y <- unlist(count, use.names = FALSE)
|
||||
mapdata$group <- rep(colnames(count), each = nrow(count))
|
||||
}
|
||||
mapdata$y[is.na(mapdata$y)] <- 0
|
||||
return(mapdata)
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Configs ----
|
||||
|
||||
|
||||
# Switch between auto configs according to type & mapping
|
||||
|
@ -186,36 +324,54 @@ choose_config <- function(type, mapdata) {
|
|||
datetime <- is_x_datetime(mapdata)
|
||||
range_x <- range_num(mapdata$x)
|
||||
range_y <- range_num(mapdata$y)
|
||||
if (identical(type, "boxplot")) {
|
||||
box_horiz <- !is.numeric(mapdata$y) & is.numeric(mapdata$x)
|
||||
}
|
||||
switch(
|
||||
type,
|
||||
type,
|
||||
"bar" = config_bar(horizontal = TRUE),
|
||||
"column" = config_bar(horizontal = FALSE),
|
||||
"dumbbell" = config_bar(horizontal = TRUE, isDumbbell = TRUE),
|
||||
"column" = config_bar(horizontal = FALSE, datetime = datetime),
|
||||
"line" = config_line(datetime = datetime),
|
||||
"area" = config_line(datetime = datetime),
|
||||
"rangeArea" = config_line(datetime = datetime),
|
||||
"spline" = config_line(curve = "smooth", datetime = datetime),
|
||||
"scatter" = config_scatter(range_x = range_x, range_y = range_y),
|
||||
"step" = config_line(curve = "stepline", datetime = datetime),
|
||||
"area-spline" = config_line(curve = "smooth", datetime = datetime),
|
||||
"area-step" = config_line(curve = "stepline", datetime = datetime),
|
||||
"scatter" = config_scatter(range_x = range_x, range_y = range_y, datetime = datetime),
|
||||
"bubble" = config_scatter(range_x = range_x, range_y = range_y, datetime = datetime),
|
||||
"timeline" = config_timeline(),
|
||||
"candlestick" = config_candlestick(),
|
||||
"boxplot" = config_boxplot(horizontal = box_horiz),
|
||||
"slope" = config_slope(),
|
||||
list()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
# Config for column & bar charts
|
||||
config_bar <- function(horizontal = FALSE) {
|
||||
config_bar <- function(horizontal = FALSE, datetime = FALSE, isDumbbell = FALSE) {
|
||||
config <- list(
|
||||
dataLabels = list(enabled = FALSE),
|
||||
plotOptions = list(
|
||||
bar = list(
|
||||
horizontal = horizontal
|
||||
horizontal = horizontal,
|
||||
isDumbbell = isDumbbell
|
||||
)
|
||||
),
|
||||
tooltip = list(
|
||||
shared = TRUE,
|
||||
intersect = FALSE,
|
||||
followCursor = TRUE
|
||||
),
|
||||
grid = list(
|
||||
yaxis = list(lines = list(show = !isTRUE(horizontal))),
|
||||
xaxis = list(lines = list(show = isTRUE(horizontal)))
|
||||
)
|
||||
)
|
||||
if (isTRUE(horizontal)) {
|
||||
config <- c(config, list(
|
||||
grid = list(
|
||||
yaxis = list(lines = list(show = FALSE)),
|
||||
xaxis = list(lines = list(show = TRUE))
|
||||
)
|
||||
))
|
||||
if (isTRUE(datetime)) {
|
||||
config$xaxis$type <- "datetime"
|
||||
}
|
||||
config
|
||||
}
|
||||
|
@ -225,7 +381,11 @@ config_line <- function(curve = "straight", datetime = FALSE) {
|
|||
config <- list(
|
||||
dataLabels = list(enabled = FALSE),
|
||||
stroke = list(
|
||||
curve = curve
|
||||
curve = curve,
|
||||
width = 2
|
||||
),
|
||||
yaxis = list(
|
||||
decimalsInFloat = 2
|
||||
)
|
||||
)
|
||||
if (isTRUE(datetime)) {
|
||||
|
@ -237,16 +397,80 @@ config_line <- function(curve = "straight", datetime = FALSE) {
|
|||
}
|
||||
|
||||
|
||||
config_scatter <- function(range_x, range_y) {
|
||||
config_scatter <- function(range_x, range_y, datetime = FALSE) {
|
||||
config <- list(
|
||||
dataLabels = list(enabled = FALSE),
|
||||
xaxis = list(
|
||||
min = range_x[1], max = range_x[2]
|
||||
type = "numeric",
|
||||
min = range_x$range[1],
|
||||
max = range_x$range[2],
|
||||
tickAmount = range_x$n,
|
||||
# labels = list(formatter = format_num("~r")),
|
||||
crosshairs = list(
|
||||
show = TRUE,
|
||||
stroke = list(dashArray = 0)
|
||||
)
|
||||
),
|
||||
yaxis = list(
|
||||
min = range_y[1], max = range_y[2]
|
||||
min = range_y$range[1],
|
||||
max = range_y$range[2],
|
||||
tickAmount = range_y$n,
|
||||
labels = list(formatter = format_num("~r")),
|
||||
tooltip = list(
|
||||
enabled = TRUE
|
||||
)
|
||||
),
|
||||
grid = list(
|
||||
xaxis = list(
|
||||
lines = list(
|
||||
show = TRUE
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
if (isTRUE(datetime)) {
|
||||
config$xaxis$type <- "datetime"
|
||||
}
|
||||
config
|
||||
}
|
||||
|
||||
config_timeline <- function() {
|
||||
list(
|
||||
plotOptions = list(
|
||||
bar = list(
|
||||
horizontal = TRUE
|
||||
)
|
||||
),
|
||||
xaxis = list(
|
||||
type = "datetime"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
config_candlestick <- function() {
|
||||
list(
|
||||
xaxis = list(
|
||||
type = "datetime"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
config_boxplot <- function(horizontal = FALSE) {
|
||||
list(
|
||||
plotOptions = list(
|
||||
bar = list(
|
||||
horizontal = horizontal
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
config_slope <- function() {
|
||||
list(
|
||||
plotOptions = list(
|
||||
line = list(
|
||||
isSlopeChart = TRUE
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
#' to create interactive and modern SVG charts.
|
||||
#'
|
||||
#' @name apexcharter-package
|
||||
#' @docType package
|
||||
#' @author Victor Perrier (@@dreamRs_fr)
|
||||
NULL
|
||||
"_PACKAGE"
|
||||
|
||||
#' apexcharter exported operators and S3 methods
|
||||
#'
|
||||
|
@ -30,6 +29,18 @@ NULL
|
|||
#' @rdname apexcharter-exports
|
||||
NULL
|
||||
|
||||
#' @importFrom ggplot2 vars
|
||||
#' @name vars
|
||||
#' @export
|
||||
#' @rdname apexcharter-exports
|
||||
NULL
|
||||
|
||||
#' @importFrom ggplot2 label_value
|
||||
#' @name label_value
|
||||
#' @export
|
||||
#' @rdname apexcharter-exports
|
||||
NULL
|
||||
|
||||
#' @importFrom htmlwidgets JS
|
||||
#' @name JS
|
||||
#' @export
|
||||
|
|
207
R/apexcharter.R
207
R/apexcharter.R
|
@ -1,69 +1,50 @@
|
|||
|
||||
#' Create a apexcharts.js widget
|
||||
#' Create an ApexCharts widget
|
||||
#'
|
||||
#' @param ax_opts A \code{list} in JSON format with chart parameters.
|
||||
#' @param auto_update In Shiny application, update existing chart rather than generating new one.
|
||||
#' @param width A numeric input in pixels.
|
||||
#' @param height A numeric input in pixels.
|
||||
#' @param ax_opts A `list` in JSON format with chart parameters.
|
||||
#' @param auto_update In Shiny application, update existing chart
|
||||
#' rather than generating new one. Can be `TRUE`/`FALSE` or
|
||||
#' use [config_update()] for more control.
|
||||
#' @param width,height A numeric input in pixels.
|
||||
#' @param elementId Use an explicit element ID for the widget.
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @return An [apexchart()] `htmlwidget` object.
|
||||
#' @seealso For quickly create a chart, see [apex()].
|
||||
#' @export
|
||||
#'
|
||||
#' @importFrom htmlwidgets createWidget sizingPolicy
|
||||
#'
|
||||
#' @examples
|
||||
#'
|
||||
#' library(apexcharter)
|
||||
#'
|
||||
#' # Use raw API by passing a list of
|
||||
#' # parameters to the function
|
||||
#'
|
||||
#' apexchart(ax_opts = list(
|
||||
#' chart = list(
|
||||
#' type = "bar"
|
||||
#' ),
|
||||
#' series = list(list(
|
||||
#' name = "Example",
|
||||
#' data = sample(1:100, 5)
|
||||
#' )),
|
||||
#' xaxis = list(
|
||||
#' categories = LETTERS[1:5]
|
||||
#' )
|
||||
#' ))
|
||||
#'
|
||||
#'
|
||||
#' # Or use apexchart() to initialize the chart
|
||||
#' # before passing parameters
|
||||
#'
|
||||
#' apexchart() %>%
|
||||
#' ax_chart(type = "bar") %>%
|
||||
#' ax_series(
|
||||
#' list(
|
||||
#' name = "Example",
|
||||
#' data = sample(1:100, 5)
|
||||
#' )
|
||||
#' ) %>%
|
||||
#' ax_xaxis(
|
||||
#' categories = LETTERS[1:5]
|
||||
#' )
|
||||
#'
|
||||
apexchart <- function(ax_opts = list(), auto_update = TRUE, width = NULL, height = NULL, elementId = NULL) {
|
||||
#' @example examples/apexchart.R
|
||||
apexchart <- function(ax_opts = list(),
|
||||
auto_update = TRUE,
|
||||
width = NULL,
|
||||
height = NULL,
|
||||
elementId = NULL) {
|
||||
|
||||
if (isTRUE(auto_update)) {
|
||||
auto_update <- config_update()
|
||||
}
|
||||
|
||||
# forward options using x
|
||||
x <- list(
|
||||
ax_opts = ax_opts,
|
||||
auto_update = auto_update
|
||||
auto_update = auto_update,
|
||||
sparkbox = FALSE
|
||||
)
|
||||
|
||||
# create widget
|
||||
htmlwidgets::createWidget(
|
||||
name = 'apexcharter',
|
||||
name = "apexcharter",
|
||||
x = x,
|
||||
width = width,
|
||||
height = height,
|
||||
package = 'apexcharter',
|
||||
package = "apexcharter",
|
||||
elementId = elementId,
|
||||
preRenderHook = function(widget) {
|
||||
widget$x$data <- NULL
|
||||
widget$x$mapping <- NULL
|
||||
widget$x$add_line <- NULL
|
||||
add_locale_apex(widget)
|
||||
},
|
||||
sizingPolicy = htmlwidgets::sizingPolicy(
|
||||
defaultWidth = "100%",
|
||||
defaultHeight = "100%",
|
||||
|
@ -75,77 +56,103 @@ apexchart <- function(ax_opts = list(), auto_update = TRUE, width = NULL, height
|
|||
browser.fill = TRUE,
|
||||
viewer.suppress = FALSE,
|
||||
browser.external = TRUE,
|
||||
padding = 20
|
||||
padding = 0
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
# dput(tools::file_path_sans_ext(list.files("inst/apexcharts-locale/")))
|
||||
#' @importFrom jsonlite fromJSON
|
||||
add_locale_apex <- function(widget) {
|
||||
if (!is.null(widget$x$ax_opts$chart$defaultLocale)) {
|
||||
defaultLocale <- widget$x$ax_opts$chart$defaultLocale
|
||||
defaultLocale <- match.arg(
|
||||
arg = defaultLocale,
|
||||
choices = c("ca", "cs", "de", "el", "en", "es", "fi", "fr", "he", "hi",
|
||||
"hr", "hu", "hy", "id", "it", "ja", "ka", "ko", "lt", "nb", "nl",
|
||||
"pl", "pt-br", "pt", "rs", "ru", "se", "sk", "sl", "sq", "th",
|
||||
"tr", "ua", "zh-cn")
|
||||
)
|
||||
if (!is.null(widget$x$ax_opts$chart$locales)) {
|
||||
warning(
|
||||
"defaultLocale is used but will be ignored since",
|
||||
" a custom array for locales is provided."
|
||||
)
|
||||
} else {
|
||||
path <- system.file(
|
||||
file.path("apexcharts-locale", paste0(defaultLocale, ".json")),
|
||||
package = "apexcharter"
|
||||
)
|
||||
locale <- jsonlite::fromJSON(txt = path)
|
||||
widget$x$ax_opts$chart$locales <- list(locale)
|
||||
}
|
||||
}
|
||||
widget
|
||||
}
|
||||
|
||||
|
||||
|
||||
#' Configuration for auto update
|
||||
#'
|
||||
#' @param series_animate Should the chart animate on re-rendering.
|
||||
#' @param update_options Update or not global options for chart.
|
||||
#' @param options_animate Should the chart animate on re-rendering.
|
||||
#' @param options_redrawPaths When the chart is re-rendered,
|
||||
#' should it draw from the existing paths or completely redraw
|
||||
#' the chart paths from the beginning. By default, the chart
|
||||
#' is re-rendered from the existing paths.
|
||||
#' @param update_synced_charts All the charts in a group should
|
||||
#' also update when one chart in a group is updated.
|
||||
#'
|
||||
#' @export
|
||||
config_update <- function(series_animate = TRUE,
|
||||
update_options = FALSE,
|
||||
options_animate = TRUE,
|
||||
options_redrawPaths = TRUE,
|
||||
update_synced_charts = FALSE) {
|
||||
list(
|
||||
series_animate = series_animate,
|
||||
update_options = update_options,
|
||||
options_animate = options_animate,
|
||||
options_redrawPaths = options_redrawPaths,
|
||||
update_synced_charts = update_synced_charts
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
#' @title Shiny bindings for apexcharter
|
||||
#'
|
||||
#' @description Output and render functions for using apexcharter within Shiny
|
||||
#' applications and interactive Rmd documents.
|
||||
#'
|
||||
#' @param outputId output variable to read from
|
||||
#' @param width,height Must be a valid CSS unit (like \code{'100\%'},
|
||||
#' \code{'400px'}, \code{'auto'}) or a number, which will be coerced to a
|
||||
#' string and have \code{'px'} appended.
|
||||
#' @param expr An expression that generates a apexcharter
|
||||
#' @param env The environment in which to evaluate \code{expr}.
|
||||
#' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This
|
||||
#' @param outputId Output variable to read from.
|
||||
#' @param width,height Must be a valid CSS unit (like `100%`,
|
||||
#' `400px`, `auto`) or a number, which will be coerced to a
|
||||
#' string and have `px` appended.
|
||||
#' @param expr An expression that generates a calendar
|
||||
#' @param env The environment in which to evaluate `expr`.
|
||||
#' @param quoted Is `expr` a quoted expression (with `quote()`)? This
|
||||
#' is useful if you want to save an expression in a variable.
|
||||
#'
|
||||
#' @return An Apexchart output that can be included in the application UI.
|
||||
#'
|
||||
#' @return Output element that can be included in UI. Render function to create output in server.
|
||||
#'
|
||||
#' @note To render a chart with facets (using [ax_facet_wrap()] or [ax_facet_grid()]) in Shiny,
|
||||
#' see [apexfacetOutput()] (in UI) and [renderApexfacet()] (in Server).
|
||||
#'
|
||||
#' @name apexcharter-shiny
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @importFrom htmlwidgets shinyWidgetOutput shinyRenderWidget
|
||||
#'
|
||||
#' @examples
|
||||
#'
|
||||
#' if (interactive()) {
|
||||
#' library(shiny)
|
||||
#'
|
||||
#' ui <- fluidPage(
|
||||
#' fluidRow(
|
||||
#' column(
|
||||
#' width = 8, offset = 2,
|
||||
#' tags$h2("Apexchart in Shiny"),
|
||||
#' actionButton("redraw", "Redraw chart"),
|
||||
#' apexchartOutput("chart")
|
||||
#' )
|
||||
#' )
|
||||
#' )
|
||||
#'
|
||||
#' server <- function(input, output, session) {
|
||||
#'
|
||||
#' output$chart <- renderApexchart({
|
||||
#' input$redraw
|
||||
#' apexchart() %>%
|
||||
#' ax_chart(type = "bar") %>%
|
||||
#' ax_series(
|
||||
#' list(
|
||||
#' name = "Example",
|
||||
#' data = sample(1:100, 5)
|
||||
#' )
|
||||
#' ) %>%
|
||||
#' ax_xaxis(
|
||||
#' categories = LETTERS[1:5]
|
||||
#' )
|
||||
#' })
|
||||
#'
|
||||
#' }
|
||||
#'
|
||||
#' shinyApp(ui, server)
|
||||
#' }
|
||||
apexchartOutput <- function(outputId, width = '100%', height = '400px'){
|
||||
htmlwidgets::shinyWidgetOutput(outputId, 'apexcharter', width, height, package = 'apexcharter')
|
||||
}
|
||||
#'
|
||||
#' @example examples/apexcharter-shiny.R
|
||||
apexchartOutput <- function(outputId, width = "100%", height = "400px") { # nocov start
|
||||
htmlwidgets::shinyWidgetOutput(outputId, "apexcharter", width, height, package = "apexcharter")
|
||||
} # nocov end
|
||||
|
||||
#' @rdname apexcharter-shiny
|
||||
#' @export
|
||||
renderApexchart <- function(expr, env = parent.frame(), quoted = FALSE) {
|
||||
renderApexchart <- function(expr, env = parent.frame(), quoted = FALSE) { # nocov start
|
||||
if (!quoted) { expr <- substitute(expr) } # force quoted
|
||||
htmlwidgets::shinyRenderWidget(expr, apexchartOutput, env, quoted = TRUE)
|
||||
}
|
||||
} # nocov end
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
|
||||
#' Set specific color's series
|
||||
#'
|
||||
#' @template ax-default
|
||||
#' @param values Named list, names represent data series, values colors to use.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @example examples/colors.R
|
||||
ax_colors_manual <- function(ax, values) {
|
||||
if (!inherits(ax, "apexcharter"))
|
||||
stop("ax_colors_manual: ax must be an apexcharter object", call. = FALSE)
|
||||
ax$x$colors_manual <- values
|
||||
ax$x$ax_opts$colors <- NULL
|
||||
groups <- get_groups(ax)
|
||||
values <- validate_values(values, groups)
|
||||
ax_colors(ax = ax, values$val)
|
||||
}
|
||||
|
||||
#' @importFrom rlang is_named
|
||||
validate_values <- function(values, groups) {
|
||||
if (!rlang::is_named(values))
|
||||
stop("values must be a named list or vector")
|
||||
nm <- names(values)
|
||||
val <- unname(unlist(values))
|
||||
nm_check <- setdiff(groups, nm)
|
||||
if (length(nm_check) > 0) {
|
||||
warning("Some groups doesn't have a corresponding color value")
|
||||
}
|
||||
list(
|
||||
nm = intersect(groups, nm),
|
||||
val = val[match(x = groups, table = nm, nomatch = 0L)]
|
||||
)
|
||||
}
|
||||
|
||||
get_groups <- function(ax) {
|
||||
if (!inherits(ax, "apexcharter"))
|
||||
stop("ax must be an apexcharter htmlwidget")
|
||||
if (is.null(ax$x$ax_opts$series))
|
||||
stop("ax must have a serie of data")
|
||||
groups <- lapply(ax$x$ax_opts$series, `[[`, "name")
|
||||
groups <- unlist(groups)
|
||||
as.character(groups)
|
||||
}
|
||||
|
||||
|
||||
|
102
R/data.R
102
R/data.R
|
@ -1,18 +1,100 @@
|
|||
#' UNHCR data for 2017
|
||||
|
||||
#' UNHCR data by continent of origin
|
||||
#'
|
||||
#' The dataset contains data about UNHCR's populations of concern for the year 2017.
|
||||
#' The dataset contains data about UNHCR's populations of concern summarised by continent of origin.
|
||||
#'
|
||||
#' @format A data frame with 11237 observations on the following 6 variables.
|
||||
#' @format A data frame with 913 observations and the following 4 variables:
|
||||
#' \describe{
|
||||
#' \item{\code{country_origin}}{Country of origin of population}
|
||||
#' \item{\code{country_residence}}{Country / territory of asylum/residence of population}
|
||||
#' \item{\code{year}}{Year concerned.}
|
||||
#' \item{\code{population_type}}{Populations of concern : Refugees, Asylum-seekers, Internally displaced persons (IDPs), Returned refugees,
|
||||
#' Returned IDPs, Stateless persons, Others of concern.}
|
||||
#' \item{\code{value}}{Number of people concerned}
|
||||
#' \item{\code{continent_residence}}{Continent of origin of population}
|
||||
#' \item{\code{continent_origin}}{Continent of residence of population}
|
||||
#' \item{\code{continent_origin}}{Continent of residence of population.}
|
||||
#' \item{\code{n}}{Number of people concerned.}
|
||||
#' }
|
||||
#' @source UNHCR (The UN Refugee Agency) (\url{http://popstats.unhcr.org/en/overview})
|
||||
"unhcr_popstats_2017"
|
||||
#' @source UNHCR (The UN Refugee Agency) (\url{https://data.unhcr.org/})
|
||||
"unhcr_ts"
|
||||
|
||||
|
||||
|
||||
#' Electricity consumption and forecasting
|
||||
#'
|
||||
#' Electricity consumption per day in France for january and february of year 2020.
|
||||
#'
|
||||
#' @format A data frame with 120 observations and the following 3 variables:
|
||||
#' \describe{
|
||||
#' \item{\code{date}}{date.}
|
||||
#' \item{\code{type}}{Type of data : realized or forecast.}
|
||||
#' \item{\code{value}}{Value in giga-watt per hour.}
|
||||
#' }
|
||||
#' @source Rte (Electricity Transmission Network in France) (\url{https://data.rte-france.com/})
|
||||
"consumption"
|
||||
|
||||
|
||||
#' Candlestick demo data
|
||||
#'
|
||||
#'
|
||||
#' @format A data frame with 60 observations and the following 5 variables:
|
||||
#' \describe{
|
||||
#' \item{\code{datetime}}{Timestamp.}
|
||||
#' \item{\code{open}}{Open value.}
|
||||
#' \item{\code{high}}{Highest value.}
|
||||
#' \item{\code{low}}{Lowest value.}
|
||||
#' \item{\code{close}}{Close value.}
|
||||
#' }
|
||||
#' @source Apexcharts (\url{https://apexcharts.com/javascript-chart-demos/candlestick-charts/basic/})
|
||||
"candles"
|
||||
|
||||
|
||||
#' @title Paris Climate
|
||||
#'
|
||||
#' @description Average temperature and precipitation in Paris for the period 1971-2000.
|
||||
#'
|
||||
#'
|
||||
#' @format A data frame with 12 observations and the following 3 variables:
|
||||
#' \describe{
|
||||
#' \item{\code{month}}{Month}
|
||||
#' \item{\code{temperature}}{Temperature (in degree celsius).}
|
||||
#' \item{\code{precipitation}}{Precipitation (in mm).}
|
||||
#' }
|
||||
#' @source Wikipedia (\url{https://fr.wikipedia.org/wiki/Climat_de_Paris})
|
||||
"climate_paris"
|
||||
|
||||
|
||||
#' @title eco2mix data
|
||||
#'
|
||||
#' @description The dataset contains data about electricity consumption and production in France between 2012 and 2022.
|
||||
#'
|
||||
#' @format A data frame with 3,033 observations and 3 variables.
|
||||
#'
|
||||
#' @source Rte (Réseau et transport d'électricité) (\url{https://www.rte-france.com/eco2mix} and \url{https://opendata.reseaux-energies.fr/})
|
||||
"eco2mix"
|
||||
|
||||
|
||||
#' @title Temperature data
|
||||
#'
|
||||
#' @description The dataset contains data about temperatures in France between 2018 and 2022.
|
||||
#'
|
||||
#' @format A data frame with 365 observations and 6 variables.
|
||||
#'
|
||||
#' @source Enedis (\url{https://data.enedis.fr/explore/dataset/donnees-de-temperature-et-de-pseudo-rayonnement/})
|
||||
"temperatures"
|
||||
|
||||
|
||||
#' @title Life expectancy data
|
||||
#'
|
||||
#' @description The dataset contains data about life expectancy in 1972 and 2007 for 10 countries.
|
||||
#'
|
||||
#' @format A data frame with 10 observations and 4 variables.
|
||||
#'
|
||||
#' @source gapminder package (\url{https://jennybc.github.io/gapminder/} and \url{https://www.gapminder.org/data/})
|
||||
"life_expec"
|
||||
|
||||
#' @title Life expectancy data (long format)
|
||||
#'
|
||||
#' @description The dataset contains data about life expectancy in 1972 and 2007 for 10 countries.
|
||||
#'
|
||||
#' @format A data frame with 20 observations and 3 variables.
|
||||
#'
|
||||
#' @source gapminder package (\url{https://jennybc.github.io/gapminder/} and \url{https://www.gapminder.org/data/})
|
||||
"life_expec_long"
|
||||
|
||||
|
|
|
@ -0,0 +1,180 @@
|
|||
|
||||
#' @importFrom rlang eval_tidy
|
||||
get_facets <- function(data, rows, cols, type = c("wrap", "grid")) {
|
||||
type <- match.arg(type)
|
||||
byrows <- lapply(X = rows, FUN = eval_tidy, data = data)
|
||||
bycols <- lapply(X = cols, FUN = eval_tidy, data = data)
|
||||
facets <- split(x = data, f = c(bycols, byrows), sep = "|__|")
|
||||
facets <- lapply(
|
||||
X = seq_along(facets),
|
||||
FUN = function(i) {
|
||||
facet <- facets[[i]]
|
||||
attr(facet, "keys") <- strsplit(
|
||||
x = names(facets)[i],
|
||||
split = "|__|", fixed = TRUE
|
||||
)[[1]]
|
||||
facet
|
||||
}
|
||||
)
|
||||
label_row <- lapply(byrows, unique)
|
||||
label_row <- lapply(label_row, sort)
|
||||
label_row <- apply(expand.grid(label_row), 1, paste, collapse = "*")
|
||||
label_col <- lapply(bycols, unique)
|
||||
label_col <- lapply(label_col, sort)
|
||||
label_col <- apply(expand.grid(label_col), 1, paste, collapse = "*")
|
||||
list(
|
||||
facets = facets,
|
||||
nrow = if (identical(type, "grid")) n_facet(byrows) else NULL,
|
||||
ncol = if (identical(type, "grid")) n_facet(bycols) else NULL,
|
||||
label_row = label_row,
|
||||
label_col = label_col
|
||||
)
|
||||
}
|
||||
|
||||
n_facet <- function(l) {
|
||||
l <- lapply(l, function(x) {
|
||||
length(unique(x))
|
||||
})
|
||||
Reduce(`*`, l)
|
||||
}
|
||||
|
||||
#' @importFrom rlang %||% is_list is_named
|
||||
set_scale <- function(ax, values, scales = c("fixed", "free", "free_y", "free_x"), axis = c("x", "y", "y2")) {
|
||||
if (is.null(scales))
|
||||
return(ax)
|
||||
scales <- match.arg(scales)
|
||||
axis <- match.arg(axis)
|
||||
if (identical(axis, "y2")) {
|
||||
axis <- "y"
|
||||
wyaxis <- 2
|
||||
} else {
|
||||
wyaxis <- 1
|
||||
}
|
||||
if (is.null(values))
|
||||
return(ax)
|
||||
|
||||
if (inherits(values, c("numeric", "integer", "Date", "POSIXt"))) {
|
||||
range_vals <- range(pretty(values, n = 10), na.rm = TRUE)
|
||||
} else {
|
||||
range_vals <- NULL
|
||||
}
|
||||
|
||||
waxis <- switch(
|
||||
axis,
|
||||
"x" = "xaxis",
|
||||
"y" = "yaxis"
|
||||
)
|
||||
|
||||
this_axis <- ax$x$ax_opts[[waxis]]
|
||||
if (inherits(this_axis, "yaxis2")) {
|
||||
ax$x$ax_opts[[waxis]][[wyaxis]] <- set_scale_axis(
|
||||
this_axis[[wyaxis]],
|
||||
range_vals = range_vals,
|
||||
scales = scales,
|
||||
axis = axis
|
||||
)
|
||||
# ax$x$ax_opts[[waxis]][[2]] <- set_scale_axis(
|
||||
# this_axis[[2]],
|
||||
# range_vals = range_vals,
|
||||
# scales = scales,
|
||||
# axis = axis
|
||||
# )
|
||||
} else {
|
||||
ax$x$ax_opts[[waxis]] <- set_scale_axis(
|
||||
this_axis,
|
||||
range_vals = range_vals,
|
||||
scales = scales,
|
||||
axis = axis
|
||||
)
|
||||
}
|
||||
|
||||
return(ax)
|
||||
}
|
||||
|
||||
|
||||
scale_fmt <- function(x, time = inherits(x, c("Date", "POSIXt"))) {
|
||||
if (is.null(x))
|
||||
return(NULL)
|
||||
if (time)
|
||||
x <- format_date(x)
|
||||
x
|
||||
}
|
||||
|
||||
|
||||
set_scale_axis <- function(this_axis,
|
||||
range_vals,
|
||||
scales = c("fixed", "free", "free_y", "free_x"),
|
||||
axis = c("x", "y")) {
|
||||
scales <- match.arg(scales)
|
||||
axis <- match.arg(axis)
|
||||
if (scales == "fixed") {
|
||||
this_axis$min <- this_axis$min %||% scale_fmt(range_vals[1])
|
||||
this_axis$max <- this_axis$max %||% scale_fmt(range_vals[2])
|
||||
} else if (scales == "free") {
|
||||
this_axis$min <- NULL
|
||||
this_axis$max <- NULL
|
||||
} else if (scales == "free_x") {
|
||||
if (axis == "y") {
|
||||
this_axis$min <- this_axis$min %||% scale_fmt(range_vals[1])
|
||||
this_axis$max <- this_axis$max %||% scale_fmt(range_vals[2])
|
||||
} else {
|
||||
this_axis$min <- NULL
|
||||
this_axis$max <- NULL
|
||||
}
|
||||
} else if (scales == "free_y") {
|
||||
if (axis == "x") {
|
||||
this_axis$min <- this_axis$min %||% scale_fmt(range_vals[1])
|
||||
this_axis$max <- this_axis$max %||% scale_fmt(range_vals[2])
|
||||
} else {
|
||||
this_axis$min <- NULL
|
||||
this_axis$max <- NULL
|
||||
}
|
||||
}
|
||||
return(this_axis)
|
||||
}
|
||||
|
||||
|
||||
get_option <- function(ax, opt1, opt2 = NULL) {
|
||||
if (is.null(opt2)) {
|
||||
ax$x$ax_opts[[opt1]]
|
||||
} else {
|
||||
ax$x$ax_opts[[opt1]][[opt2]]
|
||||
}
|
||||
}
|
||||
remove_option <- function(ax, opt1, opt2 = NULL) {
|
||||
if (is.null(opt2)) {
|
||||
ax$x$ax_opts[[opt1]] <- NULL
|
||||
} else {
|
||||
ax$x$ax_opts[[opt1]][[opt2]] <- NULL
|
||||
}
|
||||
ax
|
||||
}
|
||||
|
||||
|
||||
get_yaxis_serie <- function(ax, which = 1) {
|
||||
series <- ax$x$ax_opts$series
|
||||
yaxis <- ax$x$ax_opts$yaxis
|
||||
if (inherits(yaxis, c("yaxis", "yaxis2"))) {
|
||||
yaxis <- yaxis[[which]]
|
||||
name <- yaxis$serieName
|
||||
if (!is.null(name)) {
|
||||
series_names <- vapply(series, FUN = `[[`, "name", FUN.VALUE = character(1))
|
||||
indice <- which(name == series_names)
|
||||
} else {
|
||||
indice <- which
|
||||
}
|
||||
unlist(lapply(series[[indice]]$data, FUN = `[[`, "y"))
|
||||
} else {
|
||||
unlist(lapply(
|
||||
X = seq_along(series),
|
||||
FUN = function(indice) {
|
||||
unlist(lapply(series[[indice]]$data, FUN = `[[`, "y"))
|
||||
}
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
has_yaxis2 <- function(ax) {
|
||||
inherits(ax$x$ax_opts$yaxis, "yaxis2")
|
||||
}
|
|
@ -0,0 +1,498 @@
|
|||
|
||||
|
||||
#' @importFrom rlang eval_tidy is_null is_function
|
||||
build_facets <- function(chart) {
|
||||
data <- chart$x$data
|
||||
mapall <- lapply(chart$x$mapping, eval_tidy, data = data)
|
||||
labeller <- chart$x$facet$labeller
|
||||
title <- get_option(chart, "title")
|
||||
chart <- remove_option(chart, "title")
|
||||
subtitle <- get_option(chart, "subtitle")
|
||||
chart <- remove_option(chart, "subtitle")
|
||||
xaxis_title <- get_option(chart, "xaxis", "title")
|
||||
chart <- remove_option(chart, "xaxis", "title")
|
||||
yaxis_title <- get_option(chart, "yaxis", "title")
|
||||
chart <- remove_option(chart, "yaxis", "title")
|
||||
facets_list <- get_facets(
|
||||
data = data,
|
||||
rows = chart$x$facet$facets_row,
|
||||
cols = chart$x$facet$facets_col,
|
||||
type = chart$x$facet$type
|
||||
)
|
||||
facets_data <- facets_list$facets
|
||||
nrow_ <- facets_list$nrow %||% chart$x$facet$nrow
|
||||
ncol_ <- facets_list$ncol %||% chart$x$facet$ncol
|
||||
nums <- seq_along(facets_data)
|
||||
dims <- get_grid_dims(nums, nrow = nrow_, ncol = ncol_)
|
||||
grid <- matrix(
|
||||
data = c(
|
||||
nums,
|
||||
rep(NA, times = (dims$nrow * dims$ncol) - length(nums))
|
||||
),
|
||||
nrow = dims$nrow,
|
||||
ncol = dims$ncol,
|
||||
byrow = TRUE
|
||||
)
|
||||
lrow <- get_last_row(grid)
|
||||
facet_data_add_line <- if (!is.null(chart$x$add_line)) {
|
||||
get_facets(
|
||||
data = chart$x$add_line$data,
|
||||
rows = chart$x$facet$facets_row,
|
||||
cols = chart$x$facet$facets_col,
|
||||
type = chart$x$facet$type
|
||||
)$facets
|
||||
}
|
||||
facets <- lapply(
|
||||
X = nums,
|
||||
FUN = function(i) {
|
||||
new <- chart
|
||||
facet <- facets_data[[i]]
|
||||
if (identical(chart$x$facet$type, "wrap") && !is_null(labeller) && is_function(labeller)) {
|
||||
keys <- attr(facet, "keys")
|
||||
text <- labeller(keys)
|
||||
new <- ax_title(new, text = text, margin = 0, floating = length(text) <= 1)
|
||||
}
|
||||
mapdata <- lapply(chart$x$mapping, eval_tidy, data = facet)
|
||||
if (chart$x$facet$scales %in% c("fixed", "free_y") & chart$x$type %in% c("bar")) {
|
||||
mapdata <- complete_mapdata(mapdata, mapall)
|
||||
}
|
||||
if (chart$x$facet$scales %in% c("fixed", "free_x") & chart$x$type %in% c("column")) {
|
||||
mapdata <- complete_mapdata(mapdata, mapall)
|
||||
}
|
||||
new$x$ax_opts$series <- make_series(mapdata, chart$x$mapping, chart$x$type, chart$x$serie_name)
|
||||
new <- set_scale(new, mapall$x, scales = chart$x$facet$scales, axis = "x")
|
||||
new <- set_scale(new, mapall$y, scales = chart$x$facet$scales, axis = "y")
|
||||
if (chart$x$facet$scales %in% c("fixed", "free_x")) {
|
||||
new <- ax_yaxis(new, show = i %in% grid[, 1])
|
||||
}
|
||||
# if (chart$x$facet$scales %in% c("fixed", "free_y")) {
|
||||
# new <- ax_xaxis(new, labels = list(show = i %in% lrow), axisTicks = list(show = TRUE))
|
||||
# }
|
||||
if (chart$x$facet$scales %in% c("fixed", "free_y") & chart$x$type %in% c("bar", "column")) {
|
||||
new <- ax_xaxis(new, labels = list(show = i %in% lrow))
|
||||
}
|
||||
if (!is.null(new$x$colors_manual)) {
|
||||
new <- ax_colors_manual(ax = new, values = new$x$colors_manual)
|
||||
}
|
||||
if (!is.null(facet_data_add_line)) {
|
||||
maplinedata <- lapply(chart$x$add_line$mapping, eval_tidy, data = facet_data_add_line[[i]])
|
||||
if (chart$x$facet$scales %in% c("fixed", "free_y") & chart$x$type %in% c("bar")) {
|
||||
maplinedata <- complete_mapdata(maplinedata, mapall)
|
||||
}
|
||||
if (chart$x$facet$scales %in% c("fixed", "free_x") & chart$x$type %in% c("column")) {
|
||||
maplinedata <- complete_mapdata(maplinedata, mapall)
|
||||
}
|
||||
new$x$ax_opts$series <- c(
|
||||
new$x$ax_opts$series,
|
||||
make_series(
|
||||
mapdata = maplinedata,
|
||||
mapping = chart$x$add_line$mapping,
|
||||
type = chart$x$add_line$type,
|
||||
serie_name = chart$x$add_line$serie_name,
|
||||
force_datetime_names = c("x", "y")
|
||||
)
|
||||
)
|
||||
# new <- add_line(
|
||||
# ax = new,
|
||||
# mapping = chart$x$add_line$mapping,
|
||||
# data = facet_data_add_line[[i]],
|
||||
# type = chart$x$add_line$type,
|
||||
# serie_name = chart$x$add_line$serie_name
|
||||
# )
|
||||
}
|
||||
if (has_yaxis2(new)) {
|
||||
values <- get_yaxis_serie(chart, 2)
|
||||
new <- set_scale(new, values, scales = chart$x$facet$scales, axis = "y2")
|
||||
}
|
||||
new$height <- chart$height %||% chart$x$facet$chart_height
|
||||
new$x$facet <- NULL
|
||||
class(new) <- setdiff(class(new), "apex_facet")
|
||||
return(new)
|
||||
}
|
||||
)
|
||||
list(
|
||||
facets = facets,
|
||||
type = chart$x$facet$type,
|
||||
nrow = facets_list$nrow,
|
||||
ncol = facets_list$ncol,
|
||||
label_row = facets_list$label_row,
|
||||
label_col = facets_list$label_col,
|
||||
title = title,
|
||||
subtitle = subtitle,
|
||||
xaxis_title = xaxis_title,
|
||||
yaxis_title = yaxis_title
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
get_last_row <- function(mat) {
|
||||
apply(X = mat, MARGIN = 2, FUN = function(x) {
|
||||
x <- x[!is.na(x)]
|
||||
x[length(x)]
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
#' @title Facets for ApexCharts
|
||||
#'
|
||||
#' @description Create matrix of charts by row and column faceting variable (`ax_facet_grid`),
|
||||
#' or by specified number of row and column for faceting variable(s) (`ax_facet_wrap`).
|
||||
#'
|
||||
#' @param ax An [apexchart()] `htmlwidget` object.
|
||||
#' @param facets Variable(s) to use for facetting, wrapped in `vars(...)`.
|
||||
#' @param nrow,ncol Number of row and column in output matrix.
|
||||
#' @param scales Should scales be fixed (`"fixed"`, the default),
|
||||
#' free (`"free"`), or free in one dimension (`"free_x"`, `"free_y"`)?
|
||||
#' @param labeller A function with one argument containing for each facet the value of the faceting variable.
|
||||
#' @param chart_height Individual chart height, ignored if an height is defined in `apex()` or `apexcharter()`.
|
||||
#' @param grid_width Total width for the grid, regardless of the number of column.
|
||||
#'
|
||||
#' @return An [apexchart()] `htmlwidget` object with an additionnal class `"apex_facet"`.
|
||||
#'
|
||||
#' @details # Warning
|
||||
#' To properly render in Shiny applications, use [apexfacetOutput()] (in UI) and [renderApexfacet()] (in Server).
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @name apex-facets
|
||||
#'
|
||||
#' @importFrom rlang quos syms
|
||||
#'
|
||||
#' @example examples/facet_wrap.R
|
||||
ax_facet_wrap <- function(ax,
|
||||
facets,
|
||||
nrow = NULL,
|
||||
ncol = NULL,
|
||||
scales = c("fixed", "free", "free_y", "free_x"),
|
||||
labeller = label_value,
|
||||
chart_height = "300px",
|
||||
grid_width = "100%") {
|
||||
if (!inherits(ax, "apex"))
|
||||
stop("ax_facet_wrap only works with charts generated with apex()", call. = FALSE)
|
||||
scales <- match.arg(scales)
|
||||
if (is.character(facets))
|
||||
facets <- quos(!!!syms(facets))
|
||||
ax$x$facet <- list(
|
||||
facets_row = facets,
|
||||
nrow = nrow,
|
||||
ncol = ncol,
|
||||
scales = scales,
|
||||
labeller = labeller,
|
||||
chart_height = chart_height,
|
||||
grid_width = grid_width,
|
||||
type = "wrap"
|
||||
)
|
||||
class(ax) <- c("apex_facet", class(ax))
|
||||
return(ax)
|
||||
}
|
||||
|
||||
|
||||
#' @param rows,cols A set of variables or expressions quoted by `vars()`
|
||||
#' and defining faceting groups on the rows or columns dimension.
|
||||
#' @export
|
||||
#'
|
||||
#' @rdname apex-facets
|
||||
#'
|
||||
#' @example examples/facet_grid.R
|
||||
ax_facet_grid <- function(ax,
|
||||
rows = NULL,
|
||||
cols = NULL,
|
||||
scales = c("fixed", "free", "free_y", "free_x"),
|
||||
labeller = label_value,
|
||||
chart_height = "300px",
|
||||
grid_width = "100%") {
|
||||
if (!inherits(ax, "apex"))
|
||||
stop("ax_facet_wrap only works with charts generated with apex()", call. = FALSE)
|
||||
scales <- match.arg(scales)
|
||||
if (!is.null(rows) && is.character(rows))
|
||||
rows <- quos(!!!syms(rows))
|
||||
if (!is.null(cols) && is.character(cols))
|
||||
cols <- quos(!!!syms(cols))
|
||||
ax$x$facet <- list(
|
||||
facets_row = rows,
|
||||
facets_col = cols,
|
||||
nrow = NULL,
|
||||
ncol = NULL,
|
||||
scales = scales,
|
||||
labeller = labeller,
|
||||
chart_height = chart_height,
|
||||
grid_width = grid_width,
|
||||
type = "grid"
|
||||
)
|
||||
class(ax) <- c("apex_facet", class(ax))
|
||||
return(ax)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Tag ---------------------------------------------------------------------
|
||||
|
||||
#' @importFrom rlang %||%
|
||||
#' @importFrom htmltools tags css validateCssUnit
|
||||
build_facet_tag <- function(x) {
|
||||
facets <- build_facets(x)
|
||||
content <- facets$facets
|
||||
d <- get_grid_dims(content, x$x$facet$nrow, x$x$facet$ncol)
|
||||
row_after <- col_before <- NULL
|
||||
if (!is.null(facets$xaxis_title)) {
|
||||
if (identical(facets$type, "wrap")) {
|
||||
area <- paste(
|
||||
d$nrow + 1,
|
||||
1,
|
||||
d$nrow + 1,
|
||||
d$ncol + 2,
|
||||
sep = " / "
|
||||
)
|
||||
} else {
|
||||
area <- paste(
|
||||
(facets$nrow %||% 1) + 1 + !is.null(facets$ncol),
|
||||
1,
|
||||
(facets$nrow %||% 1) + 1 + !is.null(facets$ncol),
|
||||
(facets$ncol %||% 1) + 2,
|
||||
sep = " / "
|
||||
)
|
||||
}
|
||||
TAGX <- tags$div(
|
||||
class = "apexcharter-facet-xaxis-title",
|
||||
facets$xaxis_title$text,
|
||||
style = make_styles(facets$xaxis_title$style),
|
||||
style = paste("grid-area:", area, ";")
|
||||
)
|
||||
content <- c(content, list(TAGX))
|
||||
row_after <- "30px"
|
||||
}
|
||||
if (!is.null(facets$yaxis_title)) {
|
||||
if (identical(facets$type, "wrap")) {
|
||||
area <- paste(
|
||||
1,
|
||||
1,
|
||||
d$nrow + 1,
|
||||
2,
|
||||
sep = " / "
|
||||
)
|
||||
} else {
|
||||
area <- paste(
|
||||
1,
|
||||
1,
|
||||
(facets$nrow %||% 1) + 1 + !is.null(facets$ncol),
|
||||
2,
|
||||
sep = " / "
|
||||
)
|
||||
}
|
||||
TAGY <- tags$div(
|
||||
class = "apexcharter-facet-yaxis-title apexcharter-facet-rotate180",
|
||||
facets$yaxis_title$text,
|
||||
style = make_styles(facets$yaxis_title$style),
|
||||
style = paste("grid-area:", area, ";")
|
||||
)
|
||||
content <- c(content, list(TAGY))
|
||||
col_before <- "30px"
|
||||
}
|
||||
if (identical(facets$type, "wrap")) {
|
||||
TAG <- build_grid(
|
||||
content = content,
|
||||
nrow = d$nrow,
|
||||
ncol = d$ncol,
|
||||
row_after = row_after,
|
||||
col_before = col_before
|
||||
)
|
||||
} else if (identical(facets$type, "grid")) {
|
||||
if (!is.null(facets$nrow)) {
|
||||
for (i in seq_along(facets$label_row)) {
|
||||
content <- append(
|
||||
x = content,
|
||||
values = tagList(tags$div(
|
||||
class = "apexcharter-facet-row-label",
|
||||
x$x$facet$labeller(facets$label_row[i])
|
||||
)),
|
||||
after = ((facets$ncol %||% 1 + 1) * i) - 1
|
||||
)
|
||||
}
|
||||
}
|
||||
if (!is.null(facets$ncol)) {
|
||||
content <- tagList(
|
||||
lapply(
|
||||
X = facets$label_col,
|
||||
FUN = function(label_col) {
|
||||
tags$div(x$x$facet$labeller(label_col), class = "apexcharter-facet-col-label")
|
||||
}
|
||||
),
|
||||
if (!is.null(facets$nrow)) tags$div(),
|
||||
content
|
||||
)
|
||||
}
|
||||
TAG <- build_grid(
|
||||
content,
|
||||
nrow = facets$nrow %||% 1,
|
||||
ncol = facets$ncol %||% 1,
|
||||
row_before = if (!is.null(facets$ncol)) "30px",
|
||||
col_after = if (!is.null(facets$nrow)) "30px",
|
||||
row_gap = "3px",
|
||||
col_gap = "3px",
|
||||
row_after = row_after,
|
||||
col_before = col_before
|
||||
)
|
||||
} else {
|
||||
stop("Facetting must be wrap or grid", call. = FALSE)
|
||||
}
|
||||
if (!is.null(facets$subtitle)) {
|
||||
TAG <- tagList(
|
||||
tags$div(
|
||||
class = "apexcharter-facet-subtitle",
|
||||
facets$subtitle$text,
|
||||
style = make_styles(facets$subtitle$style)
|
||||
),
|
||||
TAG
|
||||
)
|
||||
}
|
||||
if (!is.null(facets$title)) {
|
||||
TAG <- tagList(
|
||||
tags$div(
|
||||
class = "apexcharter-facet-title",
|
||||
facets$title$text,
|
||||
style = make_styles(facets$title$style)
|
||||
),
|
||||
TAG
|
||||
)
|
||||
}
|
||||
TAG <- tags$div(
|
||||
style = css(width = validateCssUnit(x$x$facet$grid_width)),
|
||||
class = "apexcharter-facet",
|
||||
TAG
|
||||
)
|
||||
return(TAG)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Shiny -------------------------------------------------------------------
|
||||
|
||||
|
||||
#' @title Shiny bindings for faceting with apexcharter
|
||||
#'
|
||||
#' @description Output and render functions for using apexcharter faceting within Shiny
|
||||
#' applications and interactive Rmd documents.
|
||||
#'
|
||||
#' @param outputId output variable to read from
|
||||
#'
|
||||
#' @return An Apexcharts output that can be included in the application UI.
|
||||
#' @export
|
||||
#'
|
||||
#' @name apexcharter-shiny-facets
|
||||
#'
|
||||
#' @importFrom htmltools tagList
|
||||
#' @importFrom shiny uiOutput
|
||||
#' @importFrom htmlwidgets getDependency
|
||||
#'
|
||||
#' @example examples/facet-wrap-shiny.R
|
||||
apexfacetOutput <- function(outputId) {
|
||||
tagList(
|
||||
uiOutput(outputId = outputId),
|
||||
getDependency(name = "apexcharter", package = "apexcharter")
|
||||
)
|
||||
}
|
||||
|
||||
#' @param expr An expression that generates a apexcharter facet with [ax_facet_wrap()] or [ax_facet_grid()].
|
||||
#' @param env The environment in which to evaluate `expr`.
|
||||
#' @param quoted Is `expr` a quoted expression (with `quote()`)? This
|
||||
#' is useful if you want to save an expression in a variable.
|
||||
#'
|
||||
#' @seealso [ax_facet_wrap()], [ax_facet_grid()]
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @rdname apexcharter-shiny-facets
|
||||
#'
|
||||
#' @importFrom shiny exprToFunction createRenderFunction createWebDependency
|
||||
#' @importFrom htmltools renderTags resolveDependencies
|
||||
renderApexfacet <- function(expr, env = parent.frame(), quoted = FALSE) { # nocov start
|
||||
func <- exprToFunction(expr, env, quoted)
|
||||
createRenderFunction(
|
||||
func = func,
|
||||
transform = function(result, shinysession, name, ...) {
|
||||
if (is.null(result) || length(result) == 0)
|
||||
return(NULL)
|
||||
if (!inherits(result, "apex_facet")) {
|
||||
stop(
|
||||
"renderApexfacet: 'expr' must return an apexcharter facet object.",
|
||||
call. = FALSE
|
||||
)
|
||||
}
|
||||
TAG <- build_facet_tag(result)
|
||||
rendered <- renderTags(TAG)
|
||||
deps <- lapply(
|
||||
X = resolveDependencies(rendered$dependencies),
|
||||
FUN = createWebDependency
|
||||
)
|
||||
list(
|
||||
html = rendered$html,
|
||||
deps = deps
|
||||
)
|
||||
}, apexfacetOutput, list()
|
||||
)
|
||||
} # nocov end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Print methods -----------------------------------------------------------
|
||||
|
||||
#' @export
|
||||
print.apex_facet <- function(x, ...) { # nocov start
|
||||
TAG <- build_facet_tag(x)
|
||||
print(htmltools::browsable(TAG))
|
||||
} # nocov end
|
||||
|
||||
knit_print.apex_facet <- function(x, ..., options = NULL) { # nocov start
|
||||
TAG <- build_facet_tag(x)
|
||||
knitr::knit_print(htmltools::browsable(TAG), options = options, ...)
|
||||
} # nocov end
|
||||
|
||||
|
||||
|
||||
|
||||
# Complete ----------------------------------------------------------------
|
||||
|
||||
complete_mapdata <- function(mapdata, mapall) {
|
||||
data <- as.data.frame(mapdata)
|
||||
full_x <- unique(mapall$x)
|
||||
full_data <- data.frame(
|
||||
xorder = seq_along(full_x),
|
||||
x = full_x,
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
full_data <- merge(
|
||||
x = full_data,
|
||||
y = data,
|
||||
by = "x",
|
||||
all.x = TRUE,
|
||||
sort = FALSE
|
||||
)
|
||||
full_data <- full_data[order(full_data$xorder), ]
|
||||
full_data$xorder <- NULL
|
||||
full_data$y[is.na(full_data$y)] <- 0
|
||||
return(as.list(full_data))
|
||||
}
|
||||
|
||||
complete_data <- function(data, vars, fill_var, fill_value = 0) {
|
||||
full_data <- expand.grid(lapply(
|
||||
X = data[, vars],
|
||||
FUN = unique
|
||||
))
|
||||
full_data <- merge(
|
||||
x = full_data,
|
||||
y = data,
|
||||
by = vars,
|
||||
all.x = TRUE,
|
||||
sort = FALSE
|
||||
)
|
||||
full_data[[fill_var]][is.na(full_data[[fill_var]])] <- fill_value
|
||||
return(full_data)
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
|
||||
#' Format numbers (with D3)
|
||||
#'
|
||||
#' @param format Format for numbers, currency, percentage, e.g. \code{".0\%"} for rounded percentage.
|
||||
#' See online documentation : \url{https://github.com/d3/d3-format}.
|
||||
#' @param prefix Character string to append before formatted value.
|
||||
#' @param suffix Character string to append after formatted value.
|
||||
#' @param locale Localization to use, for example \code{"fr-FR"} for french,
|
||||
#' see possible values here: \url{https://github.com/d3/d3-format/tree/master/locale}.
|
||||
#'
|
||||
#' @return a \code{JS} function
|
||||
#' @export
|
||||
#'
|
||||
#' @importFrom htmlwidgets JS
|
||||
#'
|
||||
#' @example examples/format.R
|
||||
format_num <- function(format, prefix = "", suffix = "", locale = "en-US") {
|
||||
check_locale_d3(locale)
|
||||
path <- system.file(file.path("d3-format-locale", paste0(locale, ".json")), package = "apexcharter")
|
||||
if (path != "") {
|
||||
locale <- paste(readLines(con = path, encoding = "UTF-8"), collapse = "")
|
||||
}
|
||||
JS(sprintf(
|
||||
"function(value) {var locale = formatLocale(JSON.parse('%s')); return '%s' + locale.format('%s')(value) + '%s';}",
|
||||
locale, prefix, format, suffix
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
check_locale_d3 <- function(x) {
|
||||
json <- list.files(system.file("d3-format-locale", package = "apexcharter"))
|
||||
njson <- gsub("\\.json", "", json)
|
||||
if (!x %in% njson) {
|
||||
stop(paste(
|
||||
"Invalid D3 locale, must be one of:",
|
||||
paste(njson, collapse = ", ")
|
||||
), call. = FALSE)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#' Format date in JS
|
||||
#'
|
||||
#' @param x Date to use in JavaScript
|
||||
#'
|
||||
#' @return a JavaScript string
|
||||
#' @export
|
||||
#'
|
||||
format_date <- function(x) {
|
||||
stopifnot(length(x) == 1)
|
||||
JS(sprintf("new Date('%s').getTime()", x))
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,221 @@
|
|||
|
||||
get_grid_dims <- function(content, nrow = NULL, ncol = NULL) {
|
||||
n <- length(content)
|
||||
if (is.null(nrow) & !is.null(ncol))
|
||||
nrow <- ceiling(n / ncol)
|
||||
if (!is.null(nrow) & is.null(ncol))
|
||||
ncol <- ceiling(n / nrow)
|
||||
if (is.null(nrow) & is.null(ncol)) {
|
||||
if (n %% 3 < 1) {
|
||||
ncol <- 3
|
||||
nrow <- ceiling(n / ncol)
|
||||
} else {
|
||||
ncol <- 2
|
||||
nrow <- ceiling(n / ncol)
|
||||
}
|
||||
}
|
||||
list(nrow = nrow, ncol = ncol)
|
||||
}
|
||||
|
||||
|
||||
#' @importFrom htmltools tags
|
||||
build_grid <- function(content,
|
||||
nrow = NULL,
|
||||
ncol = NULL,
|
||||
row_gap = "5px",
|
||||
col_gap = "0px",
|
||||
row_before = NULL,
|
||||
row_after = NULL,
|
||||
col_before = NULL,
|
||||
col_after = NULL,
|
||||
height = NULL,
|
||||
width = NULL) {
|
||||
d <- get_grid_dims(content, nrow, ncol)
|
||||
col_style <- paste("grid-template-columns:", col_before, sprintf("repeat(%s, 1fr)", d$ncol), col_after, ";")
|
||||
row_style <- paste("grid-template-rows:", row_before, sprintf("repeat(%s, 1fr)", d$nrow), row_after, ";")
|
||||
tags$div(
|
||||
class = "apexcharter-grid-container",
|
||||
style = if (!is.null(height)) paste0("height:", height, ";"),
|
||||
style = if (!is.null(width)) paste0("width:", width, ";"),
|
||||
style = "display: grid;",
|
||||
style = col_style,
|
||||
style = row_style,
|
||||
style = sprintf("grid-column-gap: %s;", col_gap),
|
||||
style = sprintf("grid-row-gap: %s;", row_gap),
|
||||
content
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
#' Create a grid of ApexCharts
|
||||
#'
|
||||
#' @param ... Several \code{apexcharts} \code{htmlwidget} objects.
|
||||
#' @param nrow,ncol Number of rows and columns.
|
||||
#' @param row_gap,col_gap Gap between rows and columns.
|
||||
#' @param grid_area Custom grid area to make elements take more than a single
|
||||
#' cell in grid, see \url{https://cssgrid-generator.netlify.app/} for examples.
|
||||
#' @param height,width Height and width of the main grid.
|
||||
#' @param .list A list of \code{apexcharts} \code{htmlwidget} objects.
|
||||
#'
|
||||
#' @return Custom \code{apex_grid} object.
|
||||
#'
|
||||
#' @note You have to provide either height for the grid or individual chart height to make it work.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @importFrom htmltools tags
|
||||
#'
|
||||
#' @example examples/apex_grid.R
|
||||
apex_grid <- function(...,
|
||||
nrow = NULL,
|
||||
ncol = NULL,
|
||||
row_gap = "10px",
|
||||
col_gap = "0px",
|
||||
grid_area = NULL,
|
||||
height = NULL,
|
||||
width = NULL,
|
||||
.list = NULL) {
|
||||
content <- c(list(...), .list)
|
||||
if (!is.null(grid_area)) {
|
||||
stopifnot(length(grid_area) == length(content))
|
||||
content <- lapply(
|
||||
X = seq_along(content),
|
||||
FUN = function(i) {
|
||||
tags$div(
|
||||
style = paste0("grid-area:", grid_area[i]),
|
||||
content[i]
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
grid <- list(
|
||||
content = content,
|
||||
nrow = nrow,
|
||||
ncol = ncol,
|
||||
col_gap = col_gap,
|
||||
row_gap = row_gap,
|
||||
height = height,
|
||||
width = width
|
||||
)
|
||||
class(grid) <- c("apex_grid", class(grid))
|
||||
return(grid)
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Shiny -------------------------------------------------------------------
|
||||
|
||||
|
||||
#' @title Shiny bindings for grid with apexcharter
|
||||
#'
|
||||
#' @description Output and render functions for using apexcharter grid within Shiny
|
||||
#' applications and interactive Rmd documents.
|
||||
#'
|
||||
#' @param outputId output variable to read from
|
||||
#'
|
||||
#' @return An Apexcharts output that can be included in the application UI.
|
||||
#' @export
|
||||
#'
|
||||
#' @name apexcharter-shiny-grid
|
||||
#'
|
||||
#' @importFrom htmltools tagList
|
||||
#' @importFrom shiny uiOutput
|
||||
#' @importFrom htmlwidgets getDependency
|
||||
#'
|
||||
#' @example examples/grid-shiny.R
|
||||
apexgridOutput <- function(outputId) {
|
||||
tagList(
|
||||
uiOutput(outputId = outputId),
|
||||
getDependency(name = "apexcharter", package = "apexcharter")
|
||||
)
|
||||
}
|
||||
|
||||
#' @param expr An expression that generates a apexcharter grid.
|
||||
#' @param env The environment in which to evaluate \code{expr}.
|
||||
#' @param quoted Is \code{expr} a quoted expression (with \code{quote()})? This
|
||||
#' is useful if you want to save an expression in a variable.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @rdname apexcharter-shiny-grid
|
||||
#'
|
||||
#' @importFrom shiny exprToFunction createRenderFunction createWebDependency
|
||||
#' @importFrom htmltools renderTags resolveDependencies
|
||||
renderApexgrid <- function(expr, env = parent.frame(), quoted = FALSE) { # nocov start
|
||||
func <- exprToFunction(expr, env, quoted)
|
||||
createRenderFunction(
|
||||
func = func,
|
||||
transform = function(result, shinysession, name, ...) {
|
||||
if (is.null(result) || length(result) == 0)
|
||||
return(NULL)
|
||||
if (!inherits(result, "apex_grid")) {
|
||||
stop(
|
||||
"renderApexgrid: 'expr' must return an apexcharter grid object.",
|
||||
call. = FALSE
|
||||
)
|
||||
}
|
||||
TAG <- build_grid(
|
||||
result$content,
|
||||
nrow = result$nrow,
|
||||
ncol = result$ncol,
|
||||
col_gap = result$col_gap,
|
||||
row_gap = result$row_gap,
|
||||
height = result$height,
|
||||
width = result$width
|
||||
)
|
||||
rendered <- renderTags(TAG)
|
||||
deps <- lapply(
|
||||
X = resolveDependencies(rendered$dependencies),
|
||||
FUN = createWebDependency
|
||||
)
|
||||
list(
|
||||
html = rendered$html,
|
||||
deps = deps
|
||||
)
|
||||
}, apexgridOutput, list()
|
||||
)
|
||||
} # nocov end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Print methods -----------------------------------------------------------
|
||||
# nocov start
|
||||
#' @export
|
||||
print.apex_grid <- function(x, ...) {
|
||||
TAG <- build_grid(
|
||||
x$content,
|
||||
nrow = x$nrow,
|
||||
ncol = x$ncol,
|
||||
col_gap = x$col_gap,
|
||||
row_gap = x$row_gap,
|
||||
height = x$height,
|
||||
width = x$width
|
||||
)
|
||||
print(htmltools::browsable(TAG))
|
||||
}
|
||||
|
||||
knit_print.apex_grid <- function(x, ..., options = NULL) {
|
||||
TAG <- build_grid(
|
||||
x$content,
|
||||
nrow = x$nrow,
|
||||
ncol = x$ncol,
|
||||
col_gap = x$col_gap,
|
||||
row_gap = x$row_gap,
|
||||
height = x$height,
|
||||
width = x$width
|
||||
)
|
||||
knitr::knit_print(htmltools::browsable(TAG), options = options, ...)
|
||||
}
|
||||
# nocov end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
30
R/labs.R
30
R/labs.R
|
@ -1,7 +1,7 @@
|
|||
|
||||
#' Modify axis, legend, and chart labels
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param title Text for the title.
|
||||
#' @param subtitle Text for the subtitle.
|
||||
#' @param x Text for the x-axis label.
|
||||
|
@ -16,25 +16,39 @@
|
|||
#' tmin = c(3, 3, 5, 7, 11, 14, 16, 16, 13, 10, 6, 3)
|
||||
#' )
|
||||
#'
|
||||
#' apex(meteo_paris, type = "column", aes(x = month, y = tmin)) %>%
|
||||
#' apex(meteo_paris, type = "column", aes(x = month, y = tmin)) %>%
|
||||
#' ax_labs(
|
||||
#' title = "Average minimal temperature in Paris",
|
||||
#' subtitle = "Data from NOAA",
|
||||
#' x = "Month",
|
||||
#' y = "Temperature (°C)"
|
||||
#' x = "Month",
|
||||
#' y = "Temperature (\u00b0C)"
|
||||
#' )
|
||||
ax_labs <- function(ax, title = NULL, subtitle = NULL, x = NULL, y = NULL) {
|
||||
if (!is.null(title)) {
|
||||
ax <- ax_title(ax = ax, text = title)
|
||||
ax <- ax_title(
|
||||
ax = ax,
|
||||
text = title,
|
||||
style = list(fontWeight = 700, fontSize = "16px")
|
||||
)
|
||||
}
|
||||
if (!is.null(subtitle)) {
|
||||
ax <- ax_subtitle(ax = ax, text = subtitle)
|
||||
ax <- ax_subtitle(
|
||||
ax = ax,
|
||||
text = subtitle,
|
||||
style = list(fontWeight = 400, fontSize = "14px")
|
||||
)
|
||||
}
|
||||
if (!is.null(x)) {
|
||||
ax <- ax_xaxis(ax = ax, title = list(text = x))
|
||||
ax <- ax_xaxis(
|
||||
ax = ax,
|
||||
title = list(text = x, style = list(fontWeight = 400, fontSize = "14px"))
|
||||
)
|
||||
}
|
||||
if (!is.null(y)) {
|
||||
ax <- ax_yaxis(ax = ax, title = list(text = y))
|
||||
ax <- ax_yaxis(
|
||||
ax = ax,
|
||||
title = list(text = y, style = list(fontWeight = 400, fontSize = "14px"))
|
||||
)
|
||||
}
|
||||
ax
|
||||
}
|
||||
|
|
|
@ -0,0 +1,138 @@
|
|||
|
||||
#' @title Add a line to a chart
|
||||
#'
|
||||
#' @description Add a line to an existing chart (bar, scatter and line types supported).
|
||||
#' On scatter charts you can also add a smooth line.
|
||||
#'
|
||||
#' @template ax-default
|
||||
#' @param mapping Default list of aesthetic mappings to use for chart.
|
||||
#' @param data A \code{data.frame} to use to add a line, if \code{NULL} (default),
|
||||
#' the \code{data.frame} provided in \code{apex()} will be used.
|
||||
#' @param type Type of line.
|
||||
#' @param serie_name Name for the serie displayed in tooltip and legend.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @name add-line
|
||||
#'
|
||||
#' @example examples/mixed-charts.R
|
||||
add_line <- function(ax,
|
||||
mapping,
|
||||
data = NULL,
|
||||
type = c("line", "spline"),
|
||||
serie_name = NULL) {
|
||||
type <- match.arg(type)
|
||||
if (!inherits(ax, "apex"))
|
||||
stop("add_line: ax must have been created with apex() function.", call. = FALSE)
|
||||
if (is.null(ax$x$mixed_type)) {
|
||||
apex_type <- ax$x$ax_opts$chart$type
|
||||
ax$x$mixed_type <- apex_type
|
||||
} else {
|
||||
apex_type <- ax$x$mixed_type
|
||||
}
|
||||
if (!isTRUE(apex_type %in% c("line", "bar", "scatter", "candlestick", "rangeArea")))
|
||||
stop("add_line: apex() must be a column, scatter or candlestick chart.", call. = FALSE)
|
||||
if (!identical(apex_type, "rangeArea"))
|
||||
ax$x$ax_opts$chart$type <- "line"
|
||||
if (is.null(data))
|
||||
data <- ax$x$data
|
||||
data <- as.data.frame(data)
|
||||
mapdata <- lapply(mapping, rlang::eval_tidy, data = data)
|
||||
ax$x$ax_opts$series <- c(
|
||||
ax$x$ax_opts$series,
|
||||
make_series(mapdata, mapping, type, serie_name, force_datetime_names = c("x", "y"))
|
||||
)
|
||||
ax$x$add_line <- list(
|
||||
data = data,
|
||||
mapping = mapping,
|
||||
type = type,
|
||||
serie_name = serie_name
|
||||
)
|
||||
if (identical(apex_type, "scatter")) {
|
||||
if (is.null(ax$x$ax_opts$markers$size)) {
|
||||
ax$x$ax_opts$markers$size <- c(6, 0)
|
||||
} else {
|
||||
ax$x$ax_opts$markers$size <- c(ax$x$ax_opts$markers$size, 0)
|
||||
}
|
||||
}
|
||||
if (identical(apex_type, "bar")) {
|
||||
if (is.null(ax$x$ax_opts$stroke$width)) {
|
||||
ax$x$ax_opts$stroke$width <- c(0, 4)
|
||||
} else {
|
||||
ax$x$ax_opts$stroke$width <- c(ax$x$ax_opts$stroke$width, 4)
|
||||
}
|
||||
}
|
||||
if (identical(apex_type, "candlestick")) {
|
||||
if (is.null(ax$x$ax_opts$stroke$width)) {
|
||||
ax$x$ax_opts$stroke$width <- c(1, 4)
|
||||
} else {
|
||||
ax$x$ax_opts$stroke$width <- c(ax$x$ax_opts$stroke$width, 4)
|
||||
}
|
||||
}
|
||||
if (identical(type, "line")) {
|
||||
ax$x$ax_opts$stroke$curve <- "straight"
|
||||
} else if (identical(type, "spline")) {
|
||||
ax$x$ax_opts$stroke$curve <- "smooth"
|
||||
}
|
||||
return(ax)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#' @param formula Formula passed to the \code{method}, default to \code{y ~ x} from main aesthetics.
|
||||
#' @param model Model to use between \code{\link{lm}} or \code{\link{loess}}.
|
||||
#' @param n Number of points used for predictions.
|
||||
#' @param ... Arguments passed to \code{model}.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @importFrom stats lm loess predict
|
||||
#' @importFrom rlang !! sym
|
||||
#'
|
||||
#' @name add-line
|
||||
add_smooth_line <- function(ax,
|
||||
formula = y ~ x,
|
||||
model = c("lm", "loess"),
|
||||
n = 100,
|
||||
...,
|
||||
type = c("line", "spline"),
|
||||
serie_name = NULL) {
|
||||
model <- match.arg(model)
|
||||
type <- match.arg(type)
|
||||
if (!inherits(ax, "apex"))
|
||||
stop("add_smooth_line: ax must have been created with apex() function.", call. = FALSE)
|
||||
if (is.null(ax$x$mixed_type)) {
|
||||
apex_type <- ax$x$ax_opts$chart$type
|
||||
ax$x$mixed_type <- apex_type
|
||||
} else {
|
||||
apex_type <- ax$x$mixed_type
|
||||
}
|
||||
if (!isTRUE(apex_type %in% c("scatter")))
|
||||
stop("add_smooth_line: apex() must be a scatter chart.", call. = FALSE)
|
||||
ax$x$ax_opts$chart$type <- "line"
|
||||
data <- as.data.frame(ax$x$data)
|
||||
mapping <- ax$x$mapping
|
||||
mapdata <- lapply(mapping, rlang::eval_tidy, data = data)
|
||||
if (identical(model, "lm")) {
|
||||
model_results <- lm(formula = formula, data = mapdata, ...)
|
||||
} else if (identical(model, "loess")) {
|
||||
model_results <- loess(formula = formula, data = mapdata, ...)
|
||||
}
|
||||
new_data <- data.frame(x = seq(
|
||||
from = min(mapdata$x, na.rm = TRUE),
|
||||
to = max(mapdata$x, na.rm = TRUE),
|
||||
length.out = n
|
||||
))
|
||||
new_data$smooth <- predict(model_results, new_data)
|
||||
add_line(
|
||||
ax = ax,
|
||||
mapping = aes(x = `!!`(sym("x")), y = `!!`(sym("smooth"))),
|
||||
data = new_data,
|
||||
type = type,
|
||||
serie_name = serie_name
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
|
||||
#' @importFrom shiny registerInputHandler
|
||||
.onLoad <- function(...) { # nocov start
|
||||
shiny::registerInputHandler("apex_click", function(data, ...) {
|
||||
if (is.null(data)) {
|
||||
NULL
|
||||
} else {
|
||||
value <- ununlist(data$value)
|
||||
if (isTRUE(data$datetime)) {
|
||||
if (is.list(value)) {
|
||||
value <- rapply(value, to_posix, how = "replace")
|
||||
} else {
|
||||
value <- to_posix(value)
|
||||
}
|
||||
}
|
||||
return(value)
|
||||
}
|
||||
}, force = TRUE)
|
||||
shiny::registerInputHandler("apex_datetime", function(data, ...) {
|
||||
if (is.null(data)) {
|
||||
NULL
|
||||
} else {
|
||||
result <- try({
|
||||
data$x <- list(
|
||||
min = to_posix(data$x$min),
|
||||
max = to_posix(data$x$max)
|
||||
)
|
||||
data
|
||||
}, silent = TRUE)
|
||||
if (inherits(result, "try-error")) {
|
||||
warning("apexcharter: Failed to parse dates!", call. = FALSE)
|
||||
data
|
||||
} else {
|
||||
result
|
||||
}
|
||||
}
|
||||
}, force = TRUE)
|
||||
register_s3_method("knitr", "knit_print", "apex_facet")
|
||||
register_s3_method("knitr", "knit_print", "apex_grid")
|
||||
} # nocov end
|
134
R/parse-data.R
134
R/parse-data.R
|
@ -31,9 +31,10 @@ parse_df <- function(data, add_names = FALSE) {
|
|||
X = data[],
|
||||
FUN = function(x) {
|
||||
if (inherits(x, "Date")) {
|
||||
# as.numeric(x) * 86400000
|
||||
format(x)
|
||||
# js_date(x)
|
||||
as.numeric(x) * 1000 * 60*60*24
|
||||
} else if (inherits(x, "POSIXt")) {
|
||||
# js_date(x)
|
||||
as.numeric(x) * 1000
|
||||
} else if (inherits(x, "factor")) {
|
||||
as.character(x)
|
||||
|
@ -62,3 +63,132 @@ parse_df <- function(data, add_names = FALSE) {
|
|||
)
|
||||
return(ll)
|
||||
}
|
||||
|
||||
|
||||
|
||||
#' @importFrom htmlwidgets JS
|
||||
js_date <- function(x) {
|
||||
if (inherits(x, "POSIXt"))
|
||||
x <- format(x, format = "%Y-%m-%d %H:%M:%S")
|
||||
lapply(sprintf("new Date('%s').getTime()", x), JS)
|
||||
}
|
||||
|
||||
parse_timeline_data <- function(.list) {
|
||||
if (is.null(.list$group)) {
|
||||
lapply(
|
||||
X = seq_len(length(.list[[1]])),
|
||||
FUN = function(i) {
|
||||
val <- lapply(.list, `[[`, i)
|
||||
l <- list(
|
||||
x = as.character(val$x),
|
||||
y = js_date(c(val$start, val$end))
|
||||
)
|
||||
if (!is.null(val$fill)) {
|
||||
l$fillColor <- val$fill
|
||||
}
|
||||
l
|
||||
}
|
||||
)
|
||||
} else {
|
||||
grouped <- as.data.frame(.list, stringsAsFactors = FALSE)
|
||||
grouped$group <- NULL
|
||||
grouped <- split(
|
||||
x = grouped,
|
||||
f = .list$group
|
||||
)
|
||||
grouped <- lapply(grouped, as.list)
|
||||
lapply(
|
||||
X = names(grouped),
|
||||
FUN = function(name) {
|
||||
list(
|
||||
name = name,
|
||||
data = parse_timeline_data(grouped[[name]])
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
parse_dumbbell_data <- function(.list) {
|
||||
if (is.null(.list$group)) {
|
||||
lapply(
|
||||
X = seq_len(length(.list[[1]])),
|
||||
FUN = function(i) {
|
||||
val <- lapply(.list, `[[`, i)
|
||||
l <- list(
|
||||
x = as.character(val$y),
|
||||
y = list(val$x, val$xend)
|
||||
)
|
||||
if (!is.null(val$fill)) {
|
||||
l$fillColor <- val$fill
|
||||
}
|
||||
l
|
||||
}
|
||||
)
|
||||
} else {
|
||||
grouped <- as.data.frame(.list, stringsAsFactors = FALSE)
|
||||
grouped$group <- NULL
|
||||
grouped <- split(
|
||||
x = grouped,
|
||||
f = .list$group
|
||||
)
|
||||
grouped <- lapply(grouped, as.list)
|
||||
lapply(
|
||||
X = names(grouped),
|
||||
FUN = function(name) {
|
||||
list(
|
||||
name = name,
|
||||
data = parse_dumbbell_data(grouped[[name]])
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
parse_candlestick_data <- function(.list) {
|
||||
list(list(
|
||||
type = "candlestick",
|
||||
data = lapply(
|
||||
X = seq_len(length(.list[[1]])),
|
||||
FUN = function(i) {
|
||||
val <- lapply(.list, `[[`, i)
|
||||
list(
|
||||
# x = js_date(val$x)[[1]],
|
||||
x = as.numeric(val$x) * 1000,
|
||||
y = c(val$open, val$high, val$low, val$close)
|
||||
)
|
||||
}
|
||||
)
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
#' @importFrom graphics boxplot
|
||||
parse_boxplot_data <- function(.list, serie_name = NULL) {
|
||||
if (!is.numeric(.list$y) & is.numeric(.list$x)) {
|
||||
.list[c("x", "y")] <- .list[c("y", "x")]
|
||||
}
|
||||
boxed <- boxplot(y ~ x, data = .list, plot = FALSE)
|
||||
list(dropNulls(list(
|
||||
serie_name = serie_name,
|
||||
type = "boxPlot",
|
||||
data = lapply(
|
||||
X = seq_along(boxed$names),
|
||||
FUN = function(i) {
|
||||
list(
|
||||
x = boxed$names[i],
|
||||
y = c(
|
||||
boxed$stats[1, i],
|
||||
boxed$stats[2, i],
|
||||
boxed$stats[3, i],
|
||||
boxed$stats[4, i],
|
||||
boxed$stats[5, i]
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
)))
|
||||
}
|
||||
|
|
102
R/proxy.R
102
R/proxy.R
|
@ -1,26 +1,28 @@
|
|||
|
||||
#' @title Proxy for \code{apexchart}
|
||||
#'
|
||||
#'
|
||||
#' @description Allow to update a chart in Shiny application.
|
||||
#'
|
||||
#' @param shinyId single-element character vector indicating the output ID of the
|
||||
#' chart to modify (if invoked from a Shiny module, the namespace will be added
|
||||
#' automatically)
|
||||
#' @param session the Shiny session object to which the chart belongs; usually the
|
||||
#' default value will suffice
|
||||
#' default value will suffice
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @importFrom shiny getDefaultReactiveDomain
|
||||
#'
|
||||
apexchartProxy <- function(shinyId, session = shiny::getDefaultReactiveDomain()) {
|
||||
|
||||
|
||||
if (is.null(session)) {
|
||||
stop("apexchartProxy must be called from the server function of a Shiny app")
|
||||
}
|
||||
|
||||
|
||||
if (!is.null(session$ns) && nzchar(session$ns(NULL)) && substring(shinyId, 1, nchar(session$ns(""))) != session$ns("")) {
|
||||
shinyId <- session$ns(shinyId)
|
||||
}
|
||||
|
||||
|
||||
structure(
|
||||
list(
|
||||
session = session,
|
||||
|
@ -41,7 +43,7 @@ apexchartProxy <- function(shinyId, session = shiny::getDefaultReactiveDomain())
|
|||
#' @return A \code{apexchartProxy} \code{htmlwidget} object.
|
||||
#' @noRd
|
||||
.ax_proxy <- function(proxy, name, ...) {
|
||||
if (!"apexchart_Proxy" %in% class(proxy))
|
||||
if (!"apexchart_Proxy" %in% class(proxy))
|
||||
stop("This function must be used with a apexchartProxy object", call. = FALSE)
|
||||
proxy$session$sendCustomMessage(
|
||||
type = sprintf("update-apexchart-%s", name),
|
||||
|
@ -50,7 +52,7 @@ apexchartProxy <- function(shinyId, session = shiny::getDefaultReactiveDomain())
|
|||
proxy
|
||||
}
|
||||
.ax_proxy2 <- function(proxy, name, l) {
|
||||
if (!"apexchart_Proxy" %in% class(proxy))
|
||||
if (!"apexchart_Proxy" %in% class(proxy))
|
||||
stop("This function must be used with a apexchartProxy object", call. = FALSE)
|
||||
proxy$session$sendCustomMessage(
|
||||
type = sprintf("update-apexchart-%s", name),
|
||||
|
@ -62,9 +64,9 @@ apexchartProxy <- function(shinyId, session = shiny::getDefaultReactiveDomain())
|
|||
|
||||
|
||||
|
||||
#' @title Proxy for updating series.
|
||||
#'
|
||||
#' @description Allows you to update the series array overriding the existing one.
|
||||
#' @title Proxy for updating series.
|
||||
#'
|
||||
#' @description Allows you to update the series array overriding the existing one.
|
||||
#'
|
||||
#' @param proxy A \code{apexchartProxy} \code{htmlwidget} object.
|
||||
#' @param newSeries The series array to override the existing one.
|
||||
|
@ -73,10 +75,10 @@ apexchartProxy <- function(shinyId, session = shiny::getDefaultReactiveDomain())
|
|||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#'
|
||||
#'
|
||||
#' if (interactive()) {
|
||||
#' library(shiny)
|
||||
#'
|
||||
#'
|
||||
#' ui <- fluidPage(
|
||||
#' fluidRow(
|
||||
#' column(
|
||||
|
@ -86,15 +88,15 @@ apexchartProxy <- function(shinyId, session = shiny::getDefaultReactiveDomain())
|
|||
#' )
|
||||
#' )
|
||||
#' )
|
||||
#'
|
||||
#'
|
||||
#' server <- function(input, output, session) {
|
||||
#'
|
||||
#'
|
||||
#' rv <- reactiveValues()
|
||||
#' rv$df <- data.frame(
|
||||
#' date = Sys.Date() + 1:20,
|
||||
#' values = sample(10:90, 20, TRUE)
|
||||
#' )
|
||||
#'
|
||||
#'
|
||||
#' observe({
|
||||
#' invalidateLater(1000, session)
|
||||
#' df <- isolate(rv$df)
|
||||
|
@ -107,17 +109,17 @@ apexchartProxy <- function(shinyId, session = shiny::getDefaultReactiveDomain())
|
|||
#' )
|
||||
#' rv$df <- df
|
||||
#' })
|
||||
#'
|
||||
#'
|
||||
#' output$chart <- renderApexchart({
|
||||
#' # Generate chart once
|
||||
#' apex(isolate(rv$df), aes(date, values), "spline") %>%
|
||||
#' apex(isolate(rv$df), aes(date, values), "spline") %>%
|
||||
#' ax_xaxis(
|
||||
#' range = 10 * 24 * 60 * 60 * 1000
|
||||
#' # Fixed range for x-axis : 10 days
|
||||
#' # days*hours*minutes*seconds*milliseconds
|
||||
#' )
|
||||
#' })
|
||||
#'
|
||||
#'
|
||||
#' observe({
|
||||
#' # Update chart to add new data
|
||||
#' apexchartProxy("chart") %>%
|
||||
|
@ -126,24 +128,24 @@ apexchartProxy <- function(shinyId, session = shiny::getDefaultReactiveDomain())
|
|||
#' T
|
||||
#' )
|
||||
#' })
|
||||
#'
|
||||
#'
|
||||
#' }
|
||||
#'
|
||||
#'
|
||||
#' shinyApp(ui, server)
|
||||
#' }
|
||||
#'
|
||||
#'
|
||||
ax_proxy_series <- function(proxy, newSeries, animate = TRUE) {
|
||||
.ax_proxy2(
|
||||
proxy = proxy,
|
||||
name = "series",
|
||||
proxy = proxy,
|
||||
name = "series",
|
||||
l = list(newSeries = newSeries, animate = animate)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
#' @title Proxy for updating options
|
||||
#'
|
||||
#' @title Proxy for updating options
|
||||
#'
|
||||
#' @description Allows you to update the configuration object.
|
||||
#'
|
||||
#' @param proxy A \code{apexchartProxy} \code{htmlwidget} object.
|
||||
|
@ -151,11 +153,13 @@ ax_proxy_series <- function(proxy, newSeries, animate = TRUE) {
|
|||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @importFrom htmlwidgets JSEvals
|
||||
#'
|
||||
#' @examples
|
||||
#'
|
||||
#'
|
||||
#' if (interactive()) {
|
||||
#' library(shiny)
|
||||
#'
|
||||
#'
|
||||
#' ui <- fluidPage(
|
||||
#' fluidRow(
|
||||
#' column(
|
||||
|
@ -174,20 +178,20 @@ ax_proxy_series <- function(proxy, newSeries, animate = TRUE) {
|
|||
#' )
|
||||
#' )
|
||||
#' server <- function(input, output, session) {
|
||||
#'
|
||||
#'
|
||||
#' output$chart <- renderApexchart({
|
||||
#' apexchart() %>%
|
||||
#' ax_chart(type = "bar") %>%
|
||||
#' ax_chart(type = "bar") %>%
|
||||
#' ax_series(list(
|
||||
#' name = "Example",
|
||||
#' data = c(23, 43, 76, 31)
|
||||
#' )) %>%
|
||||
#' )) %>%
|
||||
#' ax_xaxis(
|
||||
#' categories = c("Label A", "Label B",
|
||||
#' "Label C", "Label D")
|
||||
#' )
|
||||
#' })
|
||||
#'
|
||||
#'
|
||||
#' observe({
|
||||
#' apexchartProxy("chart") %>%
|
||||
#' ax_proxy_options(list(
|
||||
|
@ -199,19 +203,43 @@ ax_proxy_series <- function(proxy, newSeries, animate = TRUE) {
|
|||
#' )
|
||||
#' ))
|
||||
#' })
|
||||
#'
|
||||
#'
|
||||
#' }
|
||||
#'
|
||||
#'
|
||||
#' shinyApp(ui, server)
|
||||
#' }
|
||||
#'
|
||||
#'
|
||||
ax_proxy_options <- function(proxy, options) {
|
||||
.ax_proxy2(
|
||||
proxy = proxy,
|
||||
name = "options",
|
||||
l = list(options = options)
|
||||
proxy = proxy,
|
||||
name = "options",
|
||||
l = list(options = options, evals = JSEvals(options))
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#' @title Toggle series with proxy
|
||||
#'
|
||||
#' @description This method allows you to toggle the visibility of series programmatically.
|
||||
#' Useful when you have a custom legend.
|
||||
#'
|
||||
#' @param proxy A \code{apexchartProxy} \code{htmlwidget} object.
|
||||
#' @param series_name The series name which you want to toggle visibility for.
|
||||
#'
|
||||
#' @noRd
|
||||
#'
|
||||
#' @example examples/proxy-toggle.R
|
||||
ax_proxy_toggle_series <- function(proxy, series_name) {
|
||||
.ax_proxy2(
|
||||
proxy = proxy,
|
||||
name = "toggle-series",
|
||||
l = list(seriesName = list1(series_name))
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,271 @@
|
|||
|
||||
#' @title Retrieve click information in Shiny
|
||||
#'
|
||||
#' @description According to type of chart, different values are retrieved:
|
||||
#' * **bar and column:** retrieve category (x-axis).
|
||||
#' * **pie and donut:** retrieve label.
|
||||
#' * **time-series:** retrieve x-axis value, you have to display markers
|
||||
#' with size > 0 and set tooltip's options `intersect = TRUE` and `shared = FALSE`.
|
||||
#' * **scatter:** retrieve XY coordinates.
|
||||
#'
|
||||
#' @template ax-default
|
||||
#' @param inputId The id that will be used server-side for retrieving click.
|
||||
#' @param multiple Allow multiple selection: \code{TRUE} or \code{FALSE} (default).
|
||||
#' @param effect_type Type of effect for selected element, default is to use lightly darken color.
|
||||
#' @param effect_value A larger value intensifies the select effect, accept value between 0 and 1.
|
||||
#' @param session The Shiny session.
|
||||
#'
|
||||
#' @note If x-axis is of type datetime, value retrieved is of class \code{POSIXct}.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @importFrom shiny getDefaultReactiveDomain
|
||||
#'
|
||||
#' @examples
|
||||
#'
|
||||
#' library(apexcharter)
|
||||
#'
|
||||
#' # Not in Shiny but you can still click on bars
|
||||
#' data.frame(
|
||||
#' month = month.abb,
|
||||
#' value = sample(1:100, 12)
|
||||
#' ) %>%
|
||||
#' apex(aes(month, value)) %>%
|
||||
#' set_input_click("month_click", multiple = TRUE)
|
||||
#'
|
||||
#'
|
||||
#' # Interactive examples:
|
||||
#' if (interactive()) {
|
||||
#'
|
||||
#' run_demo_input("click")
|
||||
#'
|
||||
#' }
|
||||
set_input_click <- function(ax, inputId, multiple = FALSE,
|
||||
effect_type = c("darken", "lighten", "none"),
|
||||
effect_value = 0.35,
|
||||
session = shiny::getDefaultReactiveDomain()) {
|
||||
effect_type <- match.arg(effect_type)
|
||||
if (is.null(session))
|
||||
session <- list(ns = identity)
|
||||
ax <- ax_states(ax, active = list(
|
||||
allowMultipleDataPointsSelection = isTRUE(multiple),
|
||||
filter = list(
|
||||
type = effect_type,
|
||||
value = effect_value
|
||||
)
|
||||
))
|
||||
ax$x$shinyEvents$click <- list(
|
||||
inputId = session$ns(inputId)
|
||||
)
|
||||
ax
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#' Retrieve zoom information in Shiny
|
||||
#'
|
||||
#' @template ax-default
|
||||
#' @param inputId The id that will be used server-side for retrieving zoom.
|
||||
#' @param session The Shiny session.
|
||||
#'
|
||||
#' @note If x-axis is of type datetime, value retrieved is of class \code{POSIXct}.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @importFrom shiny getDefaultReactiveDomain
|
||||
#'
|
||||
#' @examples
|
||||
#' if (interactive()) {
|
||||
#'
|
||||
#' run_demo_input("zoom")
|
||||
#'
|
||||
#' }
|
||||
set_input_zoom <- function(ax, inputId,
|
||||
session = shiny::getDefaultReactiveDomain()) {
|
||||
if (is.null(session))
|
||||
session <- list(ns = identity)
|
||||
ax$x$shinyEvents$zoomed <- list(
|
||||
inputId = session$ns(inputId)
|
||||
)
|
||||
ax
|
||||
}
|
||||
|
||||
|
||||
#' Retrieve selection information in Shiny
|
||||
#'
|
||||
#' @template ax-default
|
||||
#' @param inputId The id that will be used server-side for retrieving selection.
|
||||
#' @param type Allow selection either on x-axis, y-axis or on both axis.
|
||||
#' @param fill_color Background color of the selection rect which is drawn when user drags on the chart.
|
||||
#' @param fill_opacity Opacity of background color of the selection rectangle.
|
||||
#' @param stroke_width Border thickness of the selection rectangle.
|
||||
#' @param stroke_dasharray Creates dashes in borders of selection rectangle.
|
||||
#' Higher number creates more space between dashes in the border.
|
||||
#' @param stroke_color Colors of selection border.
|
||||
#' @param stroke_opacity Opacity of selection border.
|
||||
#' @param xmin,xmax Start value of x-axis. Both \code{min} and \code{max} must be provided.
|
||||
#' @param ymin,ymax Start value of y-axis. Both \code{min} and \code{max} must be provided.
|
||||
#' @param session The Shiny session.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @examples
|
||||
#'
|
||||
#' library(apexcharter)
|
||||
#' data("economics", package = "ggplot2")
|
||||
#'
|
||||
#' # Not in Shiny so no events
|
||||
#' # but you can still select an area on chart
|
||||
#' apex(economics, aes(date, psavert), type = "line") %>%
|
||||
#' set_input_selection("selection")
|
||||
#'
|
||||
#' # Default selection at start
|
||||
#' apex(economics, aes(date, psavert), type = "line") %>%
|
||||
#' set_input_selection(
|
||||
#' inputId = "selection",
|
||||
#' xmin = format_date("1980-01-01"),
|
||||
#' xmax = format_date("1985-01-01")
|
||||
#' )
|
||||
set_input_selection <- function(ax,
|
||||
inputId,
|
||||
type = c("x", "xy", "y"),
|
||||
fill_color = "#24292e",
|
||||
fill_opacity = 0.1,
|
||||
stroke_width = 1,
|
||||
stroke_dasharray = 3,
|
||||
stroke_color = "#24292e",
|
||||
stroke_opacity = 0.4,
|
||||
xmin = NULL,
|
||||
xmax = NULL,
|
||||
ymin = NULL,
|
||||
ymax = NULL,
|
||||
session = shiny::getDefaultReactiveDomain()) {
|
||||
type <- match.arg(type)
|
||||
if (is.null(session))
|
||||
session <- list(ns = identity)
|
||||
selection <- list(
|
||||
enabled = TRUE, type = type,
|
||||
fill = list(color = fill_color, opacity = fill_opacity),
|
||||
stroke = list(
|
||||
width = stroke_width, dashArray = stroke_dasharray,
|
||||
color = stroke_color, opacity = stroke_opacity
|
||||
)
|
||||
)
|
||||
if (!is.null(xmin) & !is.null(xmax)) {
|
||||
selection$xaxis <- list(min = xmin, max = xmax)
|
||||
}
|
||||
if (!is.null(ymin) & !is.null(ymax)) {
|
||||
selection$yaxis <- list(min = ymin, max = ymax)
|
||||
}
|
||||
ax <- ax_chart(
|
||||
ax = ax,
|
||||
selection = selection,
|
||||
toolbar = list(autoSelected = "selection")
|
||||
)
|
||||
ax$x$shinyEvents$selection <- list(
|
||||
inputId = session$ns(inputId),
|
||||
type = type
|
||||
)
|
||||
ax
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#' Retrieve chart's base64 dataURI.
|
||||
#'
|
||||
#' @template ax-default
|
||||
#' @param inputId The id that will be used server-side for retrieving data.
|
||||
#' @param session The Shiny session.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @example examples/export-2.R
|
||||
set_input_export <- function(ax, inputId,
|
||||
session = shiny::getDefaultReactiveDomain()) { # nocov start
|
||||
if (is.null(session))
|
||||
session <- list(ns = identity)
|
||||
ax$x$shinyEvents$export <- list(
|
||||
inputId = session$ns(inputId)
|
||||
)
|
||||
ax
|
||||
} # nocov end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Demo --------------------------------------------------------------------
|
||||
|
||||
# nocov start
|
||||
|
||||
#' Run Shiny input events examples
|
||||
#'
|
||||
#' @param example Name of the example.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @importFrom shiny shinyAppFile
|
||||
#'
|
||||
#' @examples
|
||||
#' if (interactive()) {
|
||||
#'
|
||||
#' run_demo_input("click")
|
||||
#' run_demo_input("zoom")
|
||||
#' run_demo_input("selection")
|
||||
#'
|
||||
#' }
|
||||
run_demo_input <- function(example = c("click", "zoom", "selection")) {
|
||||
example <- match.arg(example)
|
||||
shiny::shinyAppFile(
|
||||
appFile = system.file("examples/input", example, "app.R", package = "apexcharter"),
|
||||
options = list("display.mode" = "showcase")
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#' Run Shiny synchronization example
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @importFrom shiny shinyAppFile
|
||||
#'
|
||||
#' @examples
|
||||
#' if (interactive()) {
|
||||
#'
|
||||
#' run_demo_sync()
|
||||
#'
|
||||
#' }
|
||||
run_demo_sync <- function() {
|
||||
shiny::shinyAppFile(
|
||||
appFile = system.file("examples/sync", "app.R", package = "apexcharter"),
|
||||
options = list("display.mode" = "showcase")
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
#' Run Shiny spark boxes example
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @importFrom shiny shinyAppFile
|
||||
#'
|
||||
#' @examples
|
||||
#' if (interactive()) {
|
||||
#'
|
||||
#' run_demo_sparkbox()
|
||||
#'
|
||||
#' }
|
||||
run_demo_sparkbox <- function() {
|
||||
shiny::shinyAppFile(
|
||||
appFile = system.file("examples/spark", "app.R", package = "apexcharter"),
|
||||
options = list("display.mode" = "showcase")
|
||||
)
|
||||
}
|
||||
|
||||
# nocov end
|
|
@ -0,0 +1,116 @@
|
|||
|
||||
#' Create a box with a sparkline
|
||||
#'
|
||||
#' @param data A \code{data.frame}-like object with at least two columns,
|
||||
#' first is mapped to x-axis, second to y-axis.
|
||||
#' @param title Title to display in the box.
|
||||
#' @param subtitle Subtitle to display in the box.
|
||||
#' @param color Color of the chart.
|
||||
#' @param background Background color of the box.
|
||||
#' @param type Type of chart, currently type supported are :
|
||||
#' \code{"area"} (default), \code{"line"}, \code{"spline"}, \code{"column"}.
|
||||
#' @param synchronize Give a common id to charts to synchronize them (tooltip and zoom).
|
||||
#' @param title_style,subtitle_style A \code{list} of named attributes to style
|
||||
#' the title / subtitle, possible values are \code{fontSize},
|
||||
#' \code{fontWeight}, \code{fontFamily}, \code{color}.
|
||||
#' @param width,height A numeric input in pixels.
|
||||
#' @param elementId Use an explicit element ID for the widget.
|
||||
#'
|
||||
#' @return An \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @export
|
||||
#'
|
||||
#' @note In Shiny use \code{sparkBoxOutput} / \code{renderSparkBox} to render boxes, see example.
|
||||
#' Boxes have CSS class \code{"apexcharter-spark-box"} if you need more styling.
|
||||
#'
|
||||
#' @importFrom htmlwidgets sizingPolicy
|
||||
#' @importFrom rlang sym
|
||||
#' @importFrom ggplot2 aes
|
||||
#'
|
||||
#' @example examples/spark_box.R
|
||||
spark_box <- function(data,
|
||||
title = NULL,
|
||||
subtitle = NULL,
|
||||
color = "#2E93fA",
|
||||
background = "#FFF",
|
||||
type = c("area", "line", "spline", "column"),
|
||||
synchronize = NULL,
|
||||
title_style = NULL,
|
||||
subtitle_style = NULL,
|
||||
width = NULL,
|
||||
height = NULL,
|
||||
elementId = NULL) {
|
||||
type <- match.arg(type)
|
||||
data <- as.data.frame(data)
|
||||
if (ncol(data) < 2)
|
||||
stop("'data' must have at least two columns!", call. = FALSE)
|
||||
x_var <- names(data)[1]
|
||||
y_var <- names(data)[2]
|
||||
spark <- apex(
|
||||
data = data,
|
||||
aes(x = !!sym(x_var), y = !!sym(y_var)),
|
||||
type = type,
|
||||
auto_update = config_update(update_options = TRUE)
|
||||
)
|
||||
spark <- ax_chart(
|
||||
ax = spark,
|
||||
sparkline = list(enabled = TRUE),
|
||||
group = synchronize
|
||||
)
|
||||
spark <- ax_yaxis(spark, show = FALSE)
|
||||
spark <- ax_colors(spark, color)
|
||||
if (!is.null(title)) {
|
||||
if (is.null(title_style))
|
||||
title_style <- list(fontSize = "24px")
|
||||
if (is.null(title_style$fontSize))
|
||||
title_style$fontSize <- "24px"
|
||||
spark <- ax_title(
|
||||
ax = spark,
|
||||
text = title,
|
||||
style = title_style
|
||||
)
|
||||
}
|
||||
if (!is.null(subtitle)) {
|
||||
if (is.null(subtitle_style))
|
||||
subtitle_style <- list(fontSize = "14px")
|
||||
if (is.null(subtitle_style$fontSize))
|
||||
subtitle_style$fontSize <- "14px"
|
||||
spark <- ax_subtitle(
|
||||
ax = spark,
|
||||
text = subtitle,
|
||||
style = subtitle_style
|
||||
)
|
||||
}
|
||||
spark$x$sparkbox <- list(
|
||||
color = color, background = background
|
||||
)
|
||||
spark$sizingPolicy <- htmlwidgets::sizingPolicy(
|
||||
defaultWidth = "100%",
|
||||
defaultHeight = "160px",
|
||||
viewer.defaultHeight = "160px",
|
||||
viewer.defaultWidth = "100%",
|
||||
viewer.fill = FALSE,
|
||||
knitr.figure = FALSE,
|
||||
knitr.defaultWidth = "100%",
|
||||
knitr.defaultHeight = "160px",
|
||||
browser.fill = FALSE,
|
||||
viewer.suppress = FALSE,
|
||||
browser.external = TRUE,
|
||||
padding = 15
|
||||
)
|
||||
return(spark)
|
||||
}
|
||||
|
||||
|
||||
#' @rdname apexcharter-shiny
|
||||
#' @export
|
||||
sparkBoxOutput <- function(outputId, width = "100%", height = "160px") { # nocov start
|
||||
htmlwidgets::shinyWidgetOutput(outputId, "apexcharter", width, height, package = "apexcharter")
|
||||
} # nocov end
|
||||
|
||||
#' @rdname apexcharter-shiny
|
||||
#' @export
|
||||
renderSparkBox <- function(expr, env = parent.frame(), quoted = FALSE) { # nocov start
|
||||
if (!quoted) { expr <- substitute(expr) } # force quoted
|
||||
htmlwidgets::shinyRenderWidget(expr, apexchartOutput, env, quoted = TRUE)
|
||||
} # nocov end
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
#' Fixed tooltip
|
||||
#'
|
||||
#' @template ax-default
|
||||
#' @param position Predefined position: \code{"topLeft"}, \code{"topRight"},
|
||||
#' \code{"bottomLeft"} or \code{"bottomRight"}.
|
||||
#' @param offsetX Sets the left offset for the tooltip container in fixed position.
|
||||
#' @param offsetY Sets the top offset for the tooltip container in fixed position.
|
||||
#'
|
||||
#' @export
|
||||
#'
|
||||
#' @example examples/set_tooltip_fixed.R
|
||||
set_tooltip_fixed <- function(ax,
|
||||
position = c("topLeft", "topRight", "bottomLeft", "bottomRight"),
|
||||
offsetX = NULL,
|
||||
offsetY = NULL) {
|
||||
position <- match.arg(position)
|
||||
ax_tooltip(ax = ax, fixed = list(
|
||||
enabled = TRUE, position = position,
|
||||
offsetX = offsetX, offsetY = offsetY
|
||||
))
|
||||
}
|
104
R/utils.R
104
R/utils.R
|
@ -1,13 +1,18 @@
|
|||
|
||||
|
||||
# dropNulls
|
||||
dropNulls <- function(x) {
|
||||
x[!vapply(x, is.null, FUN.VALUE = logical(1))]
|
||||
null_or_empty <- function(x) {
|
||||
is.null(x) || length(x) == 0
|
||||
}
|
||||
|
||||
|
||||
`%||%` <- function(x, y) {
|
||||
if (!is.null(x)) x else y
|
||||
dropNullsOrEmpty <- function(x) {
|
||||
clss <- class(x)
|
||||
x <- x[!vapply(x, null_or_empty, FUN.VALUE = logical(1))]
|
||||
class(x) <- clss
|
||||
return(x)
|
||||
}
|
||||
|
||||
dropNulls <- function(x) {
|
||||
x[!vapply(x, is.null, FUN.VALUE = logical(1))]
|
||||
}
|
||||
|
||||
formatNoSci <- function(x) {
|
||||
|
@ -16,45 +21,85 @@ formatNoSci <- function(x) {
|
|||
}
|
||||
|
||||
|
||||
ununlist <- function(x) {
|
||||
if (is.null(x))
|
||||
return(x)
|
||||
n <- names(x)
|
||||
if (!is.null(n) && all(nzchar(n))) {
|
||||
lapply(x, ununlist)
|
||||
} else {
|
||||
unlist(x)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
to_posix <- function(x) {
|
||||
if (!is.null(x)) {
|
||||
x <- as.POSIXct(x/1000, origin = "1970-01-01", tz = "UTC")
|
||||
}
|
||||
x
|
||||
}
|
||||
|
||||
|
||||
to_hyphen <- function(x) {
|
||||
tolower(gsub("([A-Z])", "-\\1", x))
|
||||
}
|
||||
|
||||
make_styles <- function(styles) {
|
||||
styles <- dropNulls(styles)
|
||||
if (length(styles) < 1)
|
||||
return(NULL)
|
||||
styles <- sprintf("%s: %s;", to_hyphen(names(styles)), unlist(styles, use.names = FALSE))
|
||||
paste(styles, collapse = " ")
|
||||
}
|
||||
|
||||
|
||||
|
||||
#' Utility function to create ApexChart parameters JSON
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param name Slot's name to edit
|
||||
#' @param ... Arguments for the slot
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#'
|
||||
#' @importFrom utils modifyList
|
||||
#'
|
||||
#' @noRd
|
||||
.ax_opt <- function(ax, name, ...) {
|
||||
|
||||
|
||||
if (is.null(ax$x$ax_opts[[name]])) {
|
||||
ax$x$ax_opts[[name]] <- list(...)
|
||||
} else {
|
||||
ax$x$ax_opts[[name]] <- utils::modifyList(x = ax$x$ax_opts[[name]], val = list(...), keep.null = TRUE)
|
||||
ax$x$ax_opts[[name]] <- modifyList(
|
||||
x = ax$x$ax_opts[[name]],
|
||||
val = list(...),
|
||||
keep.null = TRUE
|
||||
)
|
||||
}
|
||||
|
||||
ax$x$ax_opts[[name]] <- dropNullsOrEmpty(ax$x$ax_opts[[name]])
|
||||
return(ax)
|
||||
}
|
||||
|
||||
#' Utility function to create ApexChart parameters JSON
|
||||
#'
|
||||
#' @param ax A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @template ax-default
|
||||
#' @param name Slot's name to edit
|
||||
#' @param l List of arguments for the slot
|
||||
#'
|
||||
#' @return A \code{apexcharts} \code{htmlwidget} object.
|
||||
#' @importFrom utils modifyList
|
||||
#'
|
||||
#' @noRd
|
||||
.ax_opt2 <- function(ax, name, l) {
|
||||
|
||||
|
||||
if (is.null(ax$x$ax_opts[[name]])) {
|
||||
ax$x$ax_opts[[name]] <- l
|
||||
} else {
|
||||
ax$x$ax_opts[[name]] <- utils::modifyList(x = ax$x$ax_opts[[name]], val = l, keep.null = TRUE)
|
||||
ax$x$ax_opts[[name]] <- modifyList(
|
||||
x = ax$x$ax_opts[[name]],
|
||||
val = l,
|
||||
keep.null = TRUE
|
||||
)
|
||||
}
|
||||
|
||||
ax$x$ax_opts[[name]] <- dropNullsOrEmpty(ax$x$ax_opts[[name]])
|
||||
return(ax)
|
||||
}
|
||||
|
||||
|
@ -65,4 +110,29 @@ formatNoSci <- function(x) {
|
|||
|
||||
|
||||
|
||||
# From vignette('knit_print', package = 'knitr')
|
||||
# and https://github.com/rstudio/htmltools/pull/108/files
|
||||
|
||||
register_s3_method <- function(pkg, generic, class, fun = NULL) { # nocov start
|
||||
stopifnot(is.character(pkg), length(pkg) == 1)
|
||||
stopifnot(is.character(generic), length(generic) == 1)
|
||||
stopifnot(is.character(class), length(class) == 1)
|
||||
|
||||
if (is.null(fun)) {
|
||||
fun <- get(paste0(generic, ".", class), envir = parent.frame())
|
||||
} else {
|
||||
stopifnot(is.function(fun))
|
||||
}
|
||||
|
||||
if (pkg %in% loadedNamespaces()) {
|
||||
registerS3method(generic, class, fun, envir = asNamespace(pkg))
|
||||
}
|
||||
|
||||
# Always register hook in case package is later unloaded & reloaded
|
||||
setHook(
|
||||
packageEvent(pkg, "onLoad"),
|
||||
function(...) {
|
||||
registerS3method(generic, class, fun, envir = asNamespace(pkg))
|
||||
}
|
||||
)
|
||||
} # nocov end
|
||||
|
|
67
README.md
67
README.md
|
@ -1,31 +1,28 @@
|
|||
# apexcharter
|
||||
|
||||
> Htmlwidget for [apexcharts.js](https://github.com/apexcharts/apexcharts.js) : A modern JavaScript charting library to build interactive charts and visualizations with simple API.
|
||||
> Htmlwidget for [apexcharts.js](https://github.com/apexcharts/apexcharts.js) : A modern JavaScript charting library to build interactive charts and visualizations with simple API. See the [online documentation](https://dreamrs.github.io/apexcharter/) for examples.
|
||||
|
||||
[![version](http://www.r-pkg.org/badges/version/apexcharter)](https://CRAN.R-project.org/package=apexcharter)
|
||||
[![Travis build status](https://travis-ci.org/dreamRs/apexcharter.svg?branch=master)](https://travis-ci.org/dreamRs/apexcharter)
|
||||
[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)
|
||||
|
||||
|
||||
:warning: Use RStudio >= 1.2 to properly display charts
|
||||
|
||||
|
||||
Note: Once again, development is heavily inspired by amazing [highcharter](http://jkunst.com/highcharter/).
|
||||
<!-- badges: start -->
|
||||
[![CRAN status](https://www.r-pkg.org/badges/version/apexcharter)](https://CRAN.R-project.org/package=apexcharter)
|
||||
[![cran checks](https://badges.cranchecks.info/worst/apexcharter.svg)](https://cran.r-project.org/web/checks/check_results_apexcharter.html)
|
||||
[![Codecov test coverage](https://codecov.io/gh/dreamRs/apexcharter/branch/master/graph/badge.svg)](https://app.codecov.io/gh/dreamRs/apexcharter?branch=master)
|
||||
[![R-CMD-check](https://github.com/dreamRs/apexcharter/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/dreamRs/apexcharter/actions/workflows/R-CMD-check.yaml)
|
||||
<!-- badges: end -->
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
Install from CRAN with:
|
||||
Install from [CRAN](https://CRAN.R-project.org/package=apexcharter) with:
|
||||
|
||||
```r
|
||||
install.packages("apexcharter")
|
||||
```
|
||||
|
||||
Or install the development version from [GitHub](https://github.com/) with:
|
||||
Or install the development version from [GitHub](https://github.com/dreamRs/apexcharter) with:
|
||||
|
||||
``` r
|
||||
# install.packages("devtools")
|
||||
devtools::install_github("dreamRs/apexcharter")
|
||||
```r
|
||||
# install.packages("remotes")
|
||||
remotes::install_github("dreamRs/apexcharter")
|
||||
```
|
||||
|
||||
|
||||
|
@ -37,11 +34,8 @@ Use `apex` function to quickly create visualizations :
|
|||
|
||||
```r
|
||||
library(apexcharter)
|
||||
|
||||
data("mpg", package = "ggplot2")
|
||||
n_manufac <- dplyr::count(mpg, manufacturer)
|
||||
|
||||
apex(data = n_manufac, type = "bar", mapping = aes(x = manufacturer, y = n))
|
||||
apex(data = mpg, type = "bar", mapping = aes(manufacturer))
|
||||
```
|
||||
![](man/figures/apex-bar.png)
|
||||
|
||||
|
@ -63,7 +57,6 @@ All methods from ApexCharts are available with function like `ax_*` compatible w
|
|||
```r
|
||||
library(apexcharter)
|
||||
data(mpg, package = "ggplot2")
|
||||
n_manufac <- dplyr::count(mpg, manufacturer)
|
||||
|
||||
apexchart() %>%
|
||||
ax_chart(type = "bar") %>%
|
||||
|
@ -82,10 +75,10 @@ apexchart() %>%
|
|||
) %>%
|
||||
ax_series(list(
|
||||
name = "Count",
|
||||
data = n_manufac$n
|
||||
data = tapply(mpg$manufacturer, mpg$manufacturer, length)
|
||||
)) %>%
|
||||
ax_colors("#112446") %>%
|
||||
ax_xaxis(categories = n_manufac$manufacturer) %>%
|
||||
ax_xaxis(categories = unique(mpg$manufacturer)) %>%
|
||||
ax_title(text = "Number of models") %>%
|
||||
ax_subtitle(text = "Data from ggplot2")
|
||||
```
|
||||
|
@ -97,7 +90,7 @@ apexchart() %>%
|
|||
|
||||
Pass a list of parameters to the function:
|
||||
|
||||
``` r
|
||||
```r
|
||||
apexchart(ax_opts = list(
|
||||
chart = list(
|
||||
type = "line"
|
||||
|
@ -136,11 +129,35 @@ apexchart(ax_opts = list(
|
|||
yaxis = list(
|
||||
title = list(text = "Temperature"),
|
||||
labels = list(
|
||||
formatter = htmlwidgets::JS("function(value) {return value + '°C';}")
|
||||
formatter = htmlwidgets::JS("function(value) {return value + '\u00b0C';}")
|
||||
)
|
||||
)
|
||||
))
|
||||
```
|
||||
|
||||
![alt text](man/figures/raw-api.png)
|
||||
![](man/figures/raw-api.png)
|
||||
|
||||
|
||||
|
||||
## Development
|
||||
|
||||
This package use [{packer}](https://github.com/JohnCoene/packer) to manage JavaScript assets, see packer's [documentation](https://packer.john-coene.com/#/) for more.
|
||||
|
||||
Install nodes modules with:
|
||||
|
||||
```r
|
||||
packer::npm_install()
|
||||
```
|
||||
|
||||
Modify `srcjs/widgets/apexcharter.js`, then run:
|
||||
|
||||
```r
|
||||
packer::bundle()
|
||||
```
|
||||
|
||||
Re-install R package and try `apexcharter()` or `apex()` functions.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
33
_pkgdown.yml
33
_pkgdown.yml
|
@ -1,28 +1,17 @@
|
|||
url: https://dreamrs.github.io/apexcharter/
|
||||
|
||||
template:
|
||||
params:
|
||||
bootswatch: flatly
|
||||
|
||||
bootstrap: 5
|
||||
bootswatch: zephyr
|
||||
bslib:
|
||||
base_font: {google: "Poppins"}
|
||||
primary: "#112446"
|
||||
navbar-dark-color: "#FFFFFF"
|
||||
secondary: "#DFDFDF"
|
||||
navbar-dark-active-color: "#DFDFDF"
|
||||
|
||||
navbar:
|
||||
type: default
|
||||
left:
|
||||
- icon: fa-home fa-lg
|
||||
href: index.html
|
||||
- text: Get started
|
||||
href: articles/starting-with-apexcharts.html
|
||||
- text: Reference
|
||||
href: reference/index.html
|
||||
- text: Articles
|
||||
menu:
|
||||
- text: "Labs: title, subtitle & axis"
|
||||
href: articles/labs.html
|
||||
- text: "Options & styles for lines"
|
||||
href: articles/lines.html
|
||||
- text: News
|
||||
href: news/index.html
|
||||
right:
|
||||
- icon: fa-github fa-lg
|
||||
href: https://github.com/dreamRs/apexcharter
|
||||
bg: primary
|
||||
|
||||
authors:
|
||||
Victor Perrier:
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
comment: false
|
||||
|
||||
coverage:
|
||||
status:
|
||||
project:
|
||||
default:
|
||||
target: auto
|
||||
threshold: 1%
|
||||
informational: true
|
||||
patch:
|
||||
default:
|
||||
target: auto
|
||||
threshold: 1%
|
||||
informational: true
|
|
@ -1,17 +1,13 @@
|
|||
## Test environments
|
||||
* local OS Widows 10 install, R 3.6.1
|
||||
* ubuntu 14.04 (on travis-ci), R 3.6.1
|
||||
* local Ubuntu 22.04 install, R 4.2.2
|
||||
* ubuntu 22.04, Windows 10, macOS (on GitHub Actions), R 4.2.2
|
||||
* win-builder (devel and release)
|
||||
|
||||
## R CMD check results
|
||||
|
||||
0 errors | 0 warnings | 0 note
|
||||
|
||||
* This is a new release.
|
||||
|
||||
Update JavaScript library.
|
||||
Fix issue with sizing in Shiny.
|
||||
|
||||
Updated JavaScript dependencies and new features.
|
||||
Thank you!
|
||||
|
||||
Victor
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
# ------------------------------------------------------------------------
|
||||
#
|
||||
# Title : Candlestick data
|
||||
# By : Victor
|
||||
# Date : 2020-06-13
|
||||
#
|
||||
# ------------------------------------------------------------------------
|
||||
|
||||
|
||||
library(jsonlite)
|
||||
|
||||
cdle <- read_json(path = "data-raw/candlestick.json")
|
||||
|
||||
cdle <- lapply(
|
||||
X = cdle,
|
||||
FUN = function(x) {
|
||||
data.frame(
|
||||
datetime = x$x,
|
||||
open = x$y[[1]],
|
||||
high = x$y[[2]],
|
||||
low = x$y[[3]],
|
||||
close = x$y[[4]],
|
||||
stringsAsFactors = FALSE
|
||||
)
|
||||
}
|
||||
)
|
||||
cdle <- do.call(rbind, cdle)
|
||||
cdle$datetime <- as.POSIXct(cdle$datetime, format = "%Y-%m-%dT%H:%M:%S", tz = "UTC")
|
||||
cdle
|
||||
|
||||
|
||||
apex(cdle, aes(x = datetime, open = open, close = close, low = low, high = high), type = "candlestick")
|
||||
|
||||
candles <- as.data.frame(cdle)
|
||||
|
||||
usethis::use_data(candles, overwrite = TRUE)
|
|
@ -0,0 +1 @@
|
|||
[{"x":"2018-10-05T22:30:00.000Z","y":[6629.81,6650.5,6623.04,6633.33]},{"x":"2018-10-05T23:00:00.000Z","y":[6632.01,6643.59,6620,6630.11]},{"x":"2018-10-05T23:30:00.000Z","y":[6630.71,6648.95,6623.34,6635.65]},{"x":"2018-10-06T00:00:00.000Z","y":[6635.65,6651,6629.67,6638.24]},{"x":"2018-10-06T00:30:00.000Z","y":[6638.24,6640,6620,6624.47]},{"x":"2018-10-06T01:00:00.000Z","y":[6624.53,6636.03,6621.68,6624.31]},{"x":"2018-10-06T01:30:00.000Z","y":[6624.61,6632.2,6617,6626.02]},{"x":"2018-10-06T02:00:00.000Z","y":[6627,6627.62,6584.22,6603.02]},{"x":"2018-10-06T02:30:00.000Z","y":[6605,6608.03,6598.95,6604.01]},{"x":"2018-10-06T03:00:00.000Z","y":[6604.5,6614.4,6602.26,6608.02]},{"x":"2018-10-06T03:30:00.000Z","y":[6608.02,6610.68,6601.99,6608.91]},{"x":"2018-10-06T04:00:00.000Z","y":[6608.91,6618.99,6608.01,6612]},{"x":"2018-10-06T04:30:00.000Z","y":[6612,6615.13,6605.09,6612]},{"x":"2018-10-06T05:00:00.000Z","y":[6612,6624.12,6608.43,6622.95]},{"x":"2018-10-06T05:30:00.000Z","y":[6623.91,6623.91,6615,6615.67]},{"x":"2018-10-06T06:00:00.000Z","y":[6618.69,6618.74,6610,6610.4]},{"x":"2018-10-06T06:30:00.000Z","y":[6611,6622.78,6610.4,6614.9]},{"x":"2018-10-06T07:00:00.000Z","y":[6614.9,6626.2,6613.33,6623.45]},{"x":"2018-10-06T07:30:00.000Z","y":[6623.48,6627,6618.38,6620.35]},{"x":"2018-10-06T08:00:00.000Z","y":[6619.43,6620.35,6610.05,6615.53]},{"x":"2018-10-06T08:30:00.000Z","y":[6615.53,6617.93,6610,6615.19]},{"x":"2018-10-06T09:00:00.000Z","y":[6615.19,6621.6,6608.2,6620]},{"x":"2018-10-06T09:30:00.000Z","y":[6619.54,6625.17,6614.15,6620]},{"x":"2018-10-06T10:00:00.000Z","y":[6620.33,6634.15,6617.24,6624.61]},{"x":"2018-10-06T10:30:00.000Z","y":[6625.95,6626,6611.66,6617.58]},{"x":"2018-10-06T11:00:00.000Z","y":[6619,6625.97,6595.27,6598.86]},{"x":"2018-10-06T11:30:00.000Z","y":[6598.86,6598.88,6570,6587.16]},{"x":"2018-10-06T12:00:00.000Z","y":[6588.86,6600,6580,6593.4]},{"x":"2018-10-06T12:30:00.000Z","y":[6593.99,6598.89,6585,6587.81]},{"x":"2018-10-06T13:00:00.000Z","y":[6587.81,6592.73,6567.14,6578]},{"x":"2018-10-06T13:30:00.000Z","y":[6578.35,6581.72,6567.39,6579]},{"x":"2018-10-06T14:00:00.000Z","y":[6579.38,6580.92,6566.77,6575.96]},{"x":"2018-10-06T14:30:00.000Z","y":[6575.96,6589,6571.77,6588.92]},{"x":"2018-10-06T15:00:00.000Z","y":[6588.92,6594,6577.55,6589.22]},{"x":"2018-10-06T15:30:00.000Z","y":[6589.3,6598.89,6589.1,6596.08]},{"x":"2018-10-06T16:00:00.000Z","y":[6597.5,6600,6588.39,6596.25]},{"x":"2018-10-06T16:30:00.000Z","y":[6598.03,6600,6588.73,6595.97]},{"x":"2018-10-06T17:00:00.000Z","y":[6595.97,6602.01,6588.17,6602]},{"x":"2018-10-06T17:30:00.000Z","y":[6602,6607,6596.51,6599.95]},{"x":"2018-10-06T18:00:00.000Z","y":[6600.63,6601.21,6590.39,6591.02]},{"x":"2018-10-06T18:30:00.000Z","y":[6591.02,6603.08,6591,6591]},{"x":"2018-10-06T19:00:00.000Z","y":[6591,6601.32,6585,6592]},{"x":"2018-10-06T19:30:00.000Z","y":[6593.13,6596.01,6590,6593.34]},{"x":"2018-10-06T20:00:00.000Z","y":[6593.34,6604.76,6582.63,6593.86]},{"x":"2018-10-06T20:30:00.000Z","y":[6593.86,6604.28,6586.57,6600.01]},{"x":"2018-10-06T21:00:00.000Z","y":[6601.81,6603.21,6592.78,6596.25]},{"x":"2018-10-06T21:30:00.000Z","y":[6596.25,6604.2,6590,6602.99]},{"x":"2018-10-06T22:00:00.000Z","y":[6602.99,6606,6584.99,6587.81]},{"x":"2018-10-06T22:30:00.000Z","y":[6587.81,6595,6583.27,6591.96]},{"x":"2018-10-06T23:00:00.000Z","y":[6591.97,6596.07,6585,6588.39]},{"x":"2018-10-06T23:30:00.000Z","y":[6587.6,6598.21,6587.6,6594.27]},{"x":"2018-10-07T00:00:00.000Z","y":[6596.44,6601,6590,6596.55]},{"x":"2018-10-07T00:30:00.000Z","y":[6598.91,6605,6596.61,6600.02]},{"x":"2018-10-07T01:00:00.000Z","y":[6600.55,6605,6589.14,6593.01]},{"x":"2018-10-07T01:30:00.000Z","y":[6593.15,6605,6592,6603.06]},{"x":"2018-10-07T02:00:00.000Z","y":[6603.07,6604.5,6599.09,6603.89]},{"x":"2018-10-07T02:30:00.000Z","y":[6604.44,6604.44,6600,6603.5]},{"x":"2018-10-07T03:00:00.000Z","y":[6603.5,6603.99,6597.5,6603.86]},{"x":"2018-10-07T03:30:00.000Z","y":[6603.85,6605,6600,6604.07]},{"x":"2018-10-07T04:00:00.000Z","y":[6604.98,6606,6604.07,6606]}]
|
|
@ -0,0 +1,119 @@
|
|||
|
||||
# ------------------------------------------------------------------------
|
||||
#
|
||||
# Title : Paris climate
|
||||
# By : Victor
|
||||
# Date : 2020-07-24
|
||||
#
|
||||
# ------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
# Packages ----------------------------------------------------------------
|
||||
|
||||
library(rvest)
|
||||
library(data.table)
|
||||
library(janitor)
|
||||
|
||||
|
||||
|
||||
|
||||
# Data --------------------------------------------------------------------
|
||||
|
||||
tables_list <- read_html(x = "https://fr.wikipedia.org/wiki/Climat_de_Paris") %>%
|
||||
html_table(fill = TRUE)
|
||||
|
||||
|
||||
# Temperature
|
||||
temperature <- tables_list[[1]]
|
||||
setDT(temperature)
|
||||
setnames(temperature, make_clean_names)
|
||||
temperature <- temperature[periode == "1971-2000" & mois == "Température moyenne (°C)"]
|
||||
temperature[, periode := NULL]
|
||||
temperature[, annee := NULL]
|
||||
temperature[, mois := NULL]
|
||||
setnames(temperature, month.abb)
|
||||
|
||||
t_data <- melt(
|
||||
data = temperature,
|
||||
measure.vars = names(temperature),
|
||||
variable.name = "month",
|
||||
value.name = "temperature",
|
||||
variable.factor = FALSE
|
||||
)
|
||||
t_data[, temperature := type.convert(temperature, dec = ",")]
|
||||
t_data
|
||||
|
||||
|
||||
# Precipitation
|
||||
precipitation <- tables_list[[3]]
|
||||
setDT(precipitation)
|
||||
setnames(precipitation, make_clean_names)
|
||||
precipitation <- precipitation[periode == "1971-2000" & mois == "Précipitations (mm)"]
|
||||
precipitation[, periode := NULL]
|
||||
precipitation[, annee := NULL]
|
||||
precipitation[, mois := NULL]
|
||||
setnames(precipitation, month.abb)
|
||||
|
||||
p_data <- melt(
|
||||
data = precipitation,
|
||||
measure.vars = names(precipitation),
|
||||
variable.name = "month",
|
||||
value.name = "precipitation",
|
||||
variable.factor = FALSE
|
||||
)
|
||||
p_data[, precipitation := type.convert(precipitation, dec = ",")]
|
||||
p_data
|
||||
|
||||
|
||||
climate_paris <- merge(t_data, p_data, by = "month", sort = FALSE)
|
||||
climate_paris
|
||||
|
||||
|
||||
climate_paris <- as.data.frame(climate_paris)
|
||||
usethis::use_data(climate_paris, overwrite = TRUE)
|
||||
|
||||
|
||||
|
||||
# Test chart --------------------------------------------------------------
|
||||
|
||||
library(apexcharter)
|
||||
|
||||
ax <- apex(climate_paris, aes(month, precipitation), type = "column", serie_name = "Precipitation")
|
||||
ax$x$ax_opts$series <- c(
|
||||
ax$x$ax_opts$series,
|
||||
list(list(
|
||||
name = "Temperature",
|
||||
type = "line",
|
||||
data = parse_df(climate_paris[, list(month, temperature)], add_names = c("x", "y"))
|
||||
))
|
||||
)
|
||||
ax %>%
|
||||
ax_chart(type = "line") %>%
|
||||
ax_markers(size = c(6, 0)) %>%
|
||||
ax_stroke(width = c(0, 4)) %>%
|
||||
ax_yaxis(
|
||||
title = list(text = "Precipitation (in mm)")
|
||||
) %>%
|
||||
ax_yaxis2(
|
||||
opposite = TRUE,
|
||||
decimalsInFloat = 0,
|
||||
title = list(text = "Temperature (in degree celsius)")
|
||||
) %>%
|
||||
ax_dataLabels(
|
||||
enabled = TRUE, enabledOnSeries = list(1)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
apex(climate_paris, aes(month, precipitation), type = "column", serie_name = "Precipitation") %>%
|
||||
add_line(aes(month, temperature), serie_name = "Temperature")
|
||||
|
||||
|
||||
apex(climate_paris, aes(month, precipitation), type = "column", serie_name = "Precipitation") %>%
|
||||
add_line(aes(month, temperature), data = climate_paris, serie_name = "Temperature") %>%
|
||||
add_line(aes(month, temperature + 5), data = climate_paris, serie_name = "Temperature 2")
|
||||
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
# ------------------------------------------------------------------------
|
||||
#
|
||||
# eCO2mix data
|
||||
# https://www.rte-france.com/eco2mix
|
||||
#
|
||||
# ------------------------------------------------------------------------
|
||||
|
||||
|
||||
# Packages ----------------------------------------------------------------
|
||||
|
||||
library(data.table)
|
||||
library(fasttime)
|
||||
|
||||
|
||||
complete <- function(data, vars, fill = list()) {
|
||||
data <- data[do.call(CJ, c(
|
||||
lapply(
|
||||
X = mget(vars),
|
||||
FUN = function(var) {
|
||||
if (inherits(var, "factor")) {
|
||||
if (anyNA(var)) {
|
||||
factor(c(levels(var), NA_character_), levels = levels(var), ordered = is.ordered(var))
|
||||
} else {
|
||||
factor(levels(var), levels = levels(var), ordered = is.ordered(var))
|
||||
}
|
||||
} else {
|
||||
unique(var)
|
||||
}
|
||||
}
|
||||
),
|
||||
list(sorted = FALSE)
|
||||
)), on = vars]
|
||||
if (length(fill) > 0 && all(nzchar(names(fill)))) {
|
||||
for (fillvar in names(fill)) {
|
||||
data[is.na(get(fillvar)), (fillvar) := fill[[fillvar]]]
|
||||
}
|
||||
}
|
||||
data[]
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Download data -----------------------------------------------------------
|
||||
|
||||
# Source: https://odre.opendatasoft.com/explore/dataset/eco2mix-national-cons-def/
|
||||
# and https://odre.opendatasoft.com/explore/dataset/eco2mix-national-tr
|
||||
|
||||
|
||||
# Read & transform data ---------------------------------------------------
|
||||
|
||||
# eco2mix <- fread(file = "data-raw/inputs/eco2mix-national-cons-def.csv")
|
||||
# eco2mix <- eco2mix[, c(5, 6, 9:17)]
|
||||
# setnames(eco2mix, c("datetime", "consumption", "fuel", "coal", "gas", "nuclear", "wind", "solar", "hydraulic", "pumping", "bioenergies"))
|
||||
|
||||
eco2mix_tr <- fread(file = "data-raw/inputs/eco2mix-national-tr.csv")
|
||||
eco2mix_tr <- eco2mix_tr[, c(5, 6, 9:17)]
|
||||
setnames(eco2mix_tr, c("datetime", "consumption", "fuel", "coal", "gas", "nuclear", "wind", "solar", "hydraulic", "pumping", "bioenergies"))
|
||||
|
||||
eco2mix <- copy(eco2mix_tr)
|
||||
# eco2mix <- rbind(eco2mix, eco2mix_tr)
|
||||
|
||||
eco2mix <- eco2mix[!is.na(consumption)]
|
||||
eco2mix[, consumption := NULL]
|
||||
# eco2mix[, date := as.Date(format(datetime, format = "%Y-%m-%d"))]
|
||||
# eco2mix[, datetime := NULL]
|
||||
# setcolorder(eco2mix, "date")
|
||||
eco2mix <- eco2mix[minute(datetime) != 15]
|
||||
eco2mix <- eco2mix[minute(datetime) != 45]
|
||||
eco2mix <- eco2mix[datetime >= (max(datetime) - 24*60*60*7)]
|
||||
eco2mix <- melt(
|
||||
data = eco2mix,
|
||||
id.vars = 1,
|
||||
variable.name = "source",
|
||||
value.name = "production",
|
||||
na.rm = TRUE,
|
||||
variable.factor = FALSE
|
||||
)
|
||||
eco2mix <- eco2mix[, list(production = round(mean(production))), by = list(datetime, source)]
|
||||
eco2mix[, source := factor(
|
||||
x = source,
|
||||
levels = c("pumping", "wind", "solar", "nuclear", "hydraulic", "gas", "coal", "fuel", "bioenergies"),
|
||||
ordered = TRUE
|
||||
)]
|
||||
eco2mix <- complete(eco2mix, c("datetime", "source"), list(production = 0))
|
||||
setorder(eco2mix, source, datetime)
|
||||
|
||||
eco2mix[]
|
||||
|
||||
|
||||
# Use data ----------------------------------------------------------------
|
||||
|
||||
setDF(eco2mix)
|
||||
usethis::use_data(eco2mix, internal = FALSE, overwrite = TRUE, compress = "xz")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Test example ------------------------------------------------------------
|
||||
|
||||
apex(eco2mix[source == "consumption"], aes(date, production), type = "line")
|
||||
|
||||
# data("eco2mix", package = "apexcharter")
|
||||
apex(eco2mix, aes(datetime, production, fill = source), type = "area") %>%
|
||||
ax_chart(animations = list(enabled = FALSE), stacked = TRUE) %>%
|
||||
ax_stroke(width = 1) %>%
|
||||
ax_fill(opacity = 1, type = "solid") %>%
|
||||
ax_tooltip(x = list(format = "dd MMM, HH:mm")) %>%
|
||||
ax_yaxis(labels = list(formatter = format_num("~", suffix = "MW"))) %>%
|
||||
ax_colors_manual(
|
||||
list(
|
||||
"bioenergies" = "#156956",
|
||||
"fuel" = "#80549f",
|
||||
"coal" = "#a68832",
|
||||
"solar" = "#d66b0d",
|
||||
"gas" = "#f20809",
|
||||
"wind" = "#72cbb7",
|
||||
"hydraulic" = "#2672b0",
|
||||
"nuclear" = "#e4a701",
|
||||
"pumping" = "#0e4269"
|
||||
)
|
||||
) %>%
|
||||
ax_labs(
|
||||
title = "Electricity generation by sector in France",
|
||||
subtitle = "Data from \u00e9CO\u2082mix"
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
## code to prepare `elec-data` dataset goes here
|
||||
|
||||
|
||||
|
||||
# Packages ----------------------------------------------------------------
|
||||
|
||||
library(data.table)
|
||||
library(lubridate)
|
||||
library(rte.data)
|
||||
library(apexcharter)
|
||||
|
||||
|
||||
|
||||
|
||||
# Consumption & forecast --------------------------------------------------
|
||||
|
||||
consumption <- get_consumption(
|
||||
resource = "short_term",
|
||||
type = c("REALISED", "D-1"),
|
||||
start_date = "2020-01-01",
|
||||
end_date = "2020-03-01"
|
||||
)
|
||||
|
||||
apex(consumption, aes(start_date, value, group = type), "line")
|
||||
|
||||
|
||||
consumption <- consumption[, list(value = round(sum(value) / 4000)), by = list(date = as_date(start_date), type)]
|
||||
consumption[type == "REALISED", type := "Realised"]
|
||||
consumption[type == "D-1", type := "Forecast D-1"]
|
||||
|
||||
apex(consumption, aes(date, value, group = type), "line")
|
||||
|
||||
consumption <- as.data.frame(consumption)
|
||||
usethis::use_data(consumption, overwrite = TRUE)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Actual generation -------------------------------------------------------
|
||||
|
||||
actual_generation <- get_actual_generation(
|
||||
resource = "actual_generations_per_production_type",
|
||||
start_date = "2017-06-12",
|
||||
end_date = "2017-06-13"
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
|
||||
|
||||
# Package -----------------------------------------------------------------
|
||||
|
||||
library(data.table)
|
||||
library(gapminder)
|
||||
|
||||
|
||||
|
||||
# Data --------------------------------------------------------------------
|
||||
|
||||
life_expec_long <- as.data.table(gapminder::gapminder)
|
||||
life_expec_long <- life_expec_long[year %in% c(1972, 2007), list(country, year, lifeExp)]
|
||||
|
||||
# life_expec <- life_expec[country %in% sample(unique(country), 10)]
|
||||
life_expec_long <- life_expec_long[country %in% c("Botswana", "Ghana", "Iran", "Liberia", "Malaysia", "Mexico",
|
||||
"Nigeria", "Pakistan", "Philippines", "Zambia")]
|
||||
life_expec_long[, country := as.character(country)]
|
||||
life_expec_long[, lifeExp := round(lifeExp, 1)]
|
||||
life_expec <- dcast(life_expec_long, country ~ year, value.var = "lifeExp")
|
||||
life_expec[, type := fifelse(`1972` > `2007`, "decreased", "increased")]
|
||||
|
||||
life_expec_long <- melt(data = life_expec, id.vars = c("country", "type"), variable.name = "year", value.name = "lifeExp")
|
||||
|
||||
|
||||
# Use data ----------------------------------------------------------------
|
||||
|
||||
setDF(life_expec)
|
||||
usethis::use_data(life_expec, internal = FALSE, overwrite = TRUE, compress = "xz")
|
||||
|
||||
setDF(life_expec_long)
|
||||
usethis::use_data(life_expec_long, internal = FALSE, overwrite = TRUE, compress = "xz")
|
||||
|
||||
|
||||
|
||||
|
||||
# Test example ------------------------------------------------------------
|
||||
|
||||
|
||||
pkgload::load_all()
|
||||
|
||||
apex(life_expec, aes(country, x = `1972`, xend = `2007`), type = "dumbbell") %>%
|
||||
ax_plotOptions(
|
||||
bar = bar_opts(
|
||||
dumbbellColors = list(list("#3d85c6", "#fb6003"))
|
||||
)
|
||||
) %>%
|
||||
ax_colors("#BABABA") %>%
|
||||
ax_labs(
|
||||
title = "Life expectancy : 1972 vs. 2007",
|
||||
subtitle = "Data from Gapminder dataset",
|
||||
x = "Life expectancy at birth, in years"
|
||||
)
|
||||
|
||||
|
||||
|
||||
apex(life_expec, aes(country, x = `1972`, xend = `2007`, group = type), type = "dumbbell") %>%
|
||||
ax_xaxis(type = "category", categories = unique(life_expec$country)) %>%
|
||||
ax_plotOptions(
|
||||
bar = bar_opts(
|
||||
dumbbellColors = list(list("#3d85c6", "#fb6003"), list("#3d85c6", "#fb6003"))
|
||||
)
|
||||
) %>%
|
||||
ax_colors(c("#3d85c6", "#fb6003")) %>%
|
||||
ax_labs(
|
||||
title = "Life expectancy : 1972 vs. 2007",
|
||||
subtitle = "Data from Gapminder dataset",
|
||||
x = "Life expectancy at birth, in years"
|
||||
)
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
# ------------------------------------------------------------------------
|
||||
#
|
||||
# temperature data for France
|
||||
# https://data.enedis.fr/explore/dataset/donnees-de-temperature-et-de-pseudo-rayonnement
|
||||
#
|
||||
# ------------------------------------------------------------------------
|
||||
|
||||
|
||||
# Packages ----------------------------------------------------------------
|
||||
|
||||
library(data.table)
|
||||
library(fasttime)
|
||||
|
||||
|
||||
# Data --------------------------------------------------------------------
|
||||
|
||||
temperatures <- fread(file = "data-raw/inputs/donnees-de-temperature-et-de-pseudo-rayonnement.csv")
|
||||
temperatures <- temperatures[, c(6, 7, 8, 2)]
|
||||
setnames(temperatures, c("year", "month", "day", "temperature"))
|
||||
temperatures <- temperatures[year > 2017]
|
||||
temperatures <- temperatures[, list(temperature = round(mean(temperature, na.rm = TRUE), 1)), by = c("year", "month", "day")]
|
||||
temperatures <- dcast(data = temperatures, formula = month + day ~ year, value.var = "temperature")
|
||||
temperatures <- temperatures[!(month == 2 & day == 29)]
|
||||
|
||||
temperatures[, low := do.call(pmin, c(as.list(.SD), na.rm = TRUE)), .SDcols = as.character(2018:2021)]
|
||||
temperatures[, high := do.call(pmax, c(as.list(.SD), na.rm = TRUE)), .SDcols = as.character(2018:2021)]
|
||||
temperatures[, average := rowMeans(.SD, na.rm = TRUE), .SDcols = as.character(2018:2021)]
|
||||
temperatures[, (as.character(2018:2021)) := NULL]
|
||||
# setnames(temperatures, "2022", "temperature")
|
||||
|
||||
temperatures[, date := as.Date("2022-01-01") + (seq_len(.N) - 1)]
|
||||
temperatures[, (c("month", "day")) := NULL]
|
||||
setcolorder(temperatures, "date")
|
||||
|
||||
temperatures[]
|
||||
|
||||
|
||||
# Save --------------------------------------------------------------------
|
||||
|
||||
setDF(temperatures)
|
||||
usethis::use_data(temperatures, internal = FALSE, overwrite = TRUE, compress = "xz")
|
||||
|
||||
|
||||
|
||||
# Test example ------------------------------------------------------------
|
||||
|
||||
|
||||
pkgload::load_all()
|
||||
|
||||
apex(temperatures, aes(x = date, ymin = low, ymax = high), type = "rangeArea", serie_name = "Low/High (2018-2021)") %>%
|
||||
add_line(aes(date, `2023`)) %>%
|
||||
ax_chart(animations = list(enabled = FALSE)) %>%
|
||||
ax_yaxis(tickAmount = 7, labels = list(formatter = format_num("~", suffix = "°C"))) %>%
|
||||
ax_colors(c("#8485854D", "#FF0000")) %>%
|
||||
ax_stroke(width = c(1, 2)) %>%
|
||||
ax_fill(opacity = 1, type = "solid") %>%
|
||||
ax_labs(
|
||||
title = "Temperatures in 2023 with range from 2018 to 2021",
|
||||
subtitle = "Data from ENEDIS"
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -163,6 +163,29 @@ unhcr_popstats <- merge(
|
|||
|
||||
|
||||
|
||||
|
||||
# Timeserie by continent --------------------------------------------------
|
||||
|
||||
unhcr_ts <- unhcr_popstats[!is.na(continent_origin), list(
|
||||
n = sum(value, na.rm = TRUE)
|
||||
), by = list(year, population_type, continent_origin)]
|
||||
|
||||
setorder(unhcr_ts, continent_origin, population_type, year)
|
||||
|
||||
|
||||
|
||||
unhcr_ts[, population_type := stringi::stri_trans_general(str = population_type, id = "ASCII-Latin")]
|
||||
unhcr_ts[, continent_origin := stringi::stri_trans_general(str = continent_origin, id = "ASCII-Latin")]
|
||||
|
||||
|
||||
unhcr_ts <- as.data.frame(unhcr_ts)
|
||||
|
||||
usethis::use_data(unhcr_ts, overwrite = TRUE)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Use data 2017 -----------------------------------------------------------
|
||||
|
||||
|
||||
|
@ -174,12 +197,18 @@ unhcr_popstats[, country_origin := stringi::stri_trans_general(str = country_ori
|
|||
|
||||
|
||||
unhcr_popstats_2017 <- unhcr_popstats[year == 2017, -c("year")]
|
||||
|
||||
# head(unhcr_popstats_2017)
|
||||
|
||||
# utils::promptData(object = unhcr_popstats_2017, filename = "tmp.Rd")
|
||||
|
||||
unhcr_popstats_2017[, country_origin := stringi::stri_trans_general(str = country_origin, id = "ASCII-Latin")]
|
||||
unhcr_popstats_2017[, country_residence := stringi::stri_trans_general(str = country_residence, id = "ASCII-Latin")]
|
||||
unhcr_popstats_2017[, population_type := stringi::stri_trans_general(str = population_type, id = "ASCII-Latin")]
|
||||
unhcr_popstats_2017[, continent_residence := stringi::stri_trans_general(str = continent_residence, id = "ASCII-Latin")]
|
||||
unhcr_popstats_2017[, continent_origin := stringi::stri_trans_general(str = continent_origin, id = "ASCII-Latin")]
|
||||
|
||||
unhcr_popstats_2017 <- as.data.frame(unhcr_popstats_2017)
|
||||
head(unhcr_popstats_2017)
|
||||
|
||||
utils::promptData(object = unhcr_popstats_2017, filename = "tmp.Rd")
|
||||
|
||||
|
||||
usethis::use_data(unhcr_popstats_2017, overwrite = TRUE)
|
||||
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,120 +0,0 @@
|
|||
|
||||
|
||||
|
||||
# Parsing options ---------------------------------------------------------
|
||||
|
||||
cx <- V8::v8()
|
||||
cx$source(file = "inst/htmlwidgets/lib/apexcharts-1.0.4/Options.js")
|
||||
ApexOpts <- cx$get("Options")
|
||||
|
||||
names(ApexOpts)
|
||||
str(ApexOpts$chart, max.level = 1)
|
||||
str(ApexOpts$chart$animations, max.level = 1)
|
||||
|
||||
|
||||
|
||||
# Utils -------------------------------------------------------------------
|
||||
|
||||
make_fun <- function(opts, name, file = "") {
|
||||
args <- names(opts[[name]])
|
||||
if (is.null(args)) {
|
||||
args <- "..."
|
||||
} else {
|
||||
args <- sprintf("%s = NULL", args)
|
||||
args <- paste(args, collapse = ",\n")
|
||||
args <- paste0(args, ", ...")
|
||||
}
|
||||
body <- paste(
|
||||
"\nparams <- c(as.list(environment()), list(...))[-1]",
|
||||
paste0(".ax_opt2(ax, \"", name, "\", l = dropNulls(params))\n"),
|
||||
sep = "\n"
|
||||
)
|
||||
res <- paste0("ax_", name, " <- function(ax, ", args, ") {", body, "}\n\n\n")
|
||||
cat(res, file = file, append = TRUE)
|
||||
return(invisible(res))
|
||||
}
|
||||
|
||||
make_opts <- function(opts, name, file = "") {
|
||||
args <- names(opts[[name]])
|
||||
if (is.null(args)) {
|
||||
args <- "..."
|
||||
body <- "list(...)"
|
||||
} else {
|
||||
body <- sprintf("%s = %s", args, args)
|
||||
body <- paste(body, collapse = ",\n")
|
||||
body <- paste0("c(list(", body, "), list(...))")
|
||||
args <- sprintf("%s = NULL", args)
|
||||
args <- paste(args, collapse = ",\n")
|
||||
args <- paste0(args, ", ...")
|
||||
}
|
||||
body <- paste0("dropNulls(", body, ")")
|
||||
res <- paste0(name, "Opts", " <- function(", args, ") {", body, "}\n\n\n")
|
||||
cat(res, file = file, append = TRUE)
|
||||
return(invisible(res))
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
# chart -------------------------------------------------------------------
|
||||
|
||||
make_fun(ApexOpts, "chart")
|
||||
|
||||
|
||||
|
||||
# plotOptions -------------------------------------------------------------
|
||||
|
||||
make_fun(ApexOpts, "plotOptions")
|
||||
|
||||
|
||||
|
||||
|
||||
# ALL ---------------------------------------------------------------------
|
||||
|
||||
lapply(
|
||||
X = names(ApexOpts),
|
||||
FUN = make_fun, opts = ApexOpts, file = "R/apex-utils.R"
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Options -----------------------------------------------------------------
|
||||
|
||||
# scroller
|
||||
str(ApexOpts$chart$scroller)
|
||||
|
||||
make_opts(ApexOpts$chart, "scroller")
|
||||
|
||||
# plotOptions -- bar
|
||||
make_opts(ApexOpts$plotOptions, "bar")
|
||||
|
||||
|
||||
|
||||
|
||||
### write funs
|
||||
|
||||
# chart
|
||||
str(ApexOpts$chart, max.level = 1)
|
||||
make_opts(ApexOpts$chart, "scroller", file = "R/apex-options.R")
|
||||
make_opts(ApexOpts$chart, "events", file = "R/apex-options.R")
|
||||
make_opts(ApexOpts$chart, "selection", file = "R/apex-options.R")
|
||||
|
||||
|
||||
# plotOptions
|
||||
str(ApexOpts$plotOptions, max.level = 1)
|
||||
make_opts(ApexOpts$plotOptions, "bar", file = "R/apex-options.R")
|
||||
make_opts(ApexOpts$plotOptions, "heatmap", file = "R/apex-options.R")
|
||||
make_opts(ApexOpts$plotOptions, "radialBar", file = "R/apex-options.R")
|
||||
make_opts(ApexOpts$plotOptions, "pie", file = "R/apex-options.R")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
|
||||
|
||||
# apexcharts.js raw api ---------------------------------------------------
|
||||
|
||||
|
||||
library(apexcharter)
|
||||
library(ggplot2) # for data
|
||||
library(dplyr)
|
||||
|
||||
|
||||
# bar ----
|
||||
|
||||
data(mpg)
|
||||
dat <- count(mpg, manufacturer)
|
||||
|
||||
apexchart(ax_opts = list(
|
||||
chart = list(type = "bar"),
|
||||
plotOptions = list(
|
||||
bar = list(
|
||||
horizontal = FALSE,
|
||||
endingShape = "flat",
|
||||
columnWidth = "70%",
|
||||
dataLabels = list(
|
||||
position = "top"
|
||||
)
|
||||
)
|
||||
),
|
||||
colors = list("#112446"),
|
||||
grid = list(
|
||||
show = TRUE,
|
||||
position = "front"
|
||||
),
|
||||
series = list(list(
|
||||
name = "Count",
|
||||
data = dat$n
|
||||
)),
|
||||
xaxis = list(categories = dat$manufacturer)
|
||||
))
|
||||
|
||||
|
||||
|
||||
# line ----
|
||||
|
||||
# recreating (mostly): https://apexcharts.com/javascript-chart-demos/line-charts/data-labels/
|
||||
|
||||
apexchart(ax_opts = list(
|
||||
chart = list(
|
||||
type = "line"
|
||||
),
|
||||
stroke = list(
|
||||
curve = "smooth"
|
||||
),
|
||||
grid = list(
|
||||
borderColor = "#e7e7e7",
|
||||
row = list(
|
||||
colors = c("#f3f3f3", "transparent"),
|
||||
opacity = 0.5
|
||||
)
|
||||
),
|
||||
dataLabels = list(
|
||||
enabled = TRUE
|
||||
),
|
||||
markers = list(style = "inverted", size = 6),
|
||||
series = list(
|
||||
list(
|
||||
name = "High",
|
||||
data = c(28, 29, 33, 36, 32, 32, 33)
|
||||
),
|
||||
list(
|
||||
name = "Low",
|
||||
data = c(12, 11, 14, 18, 17, 13, 13)
|
||||
)
|
||||
),
|
||||
title = list(
|
||||
text = "Average High & Low Temperature",
|
||||
align = "left"
|
||||
),
|
||||
xaxis = list(
|
||||
categories = month.abb[1:7]
|
||||
),
|
||||
yaxis = list(
|
||||
title = list(text = "Temperature"),
|
||||
labels = list(
|
||||
formatter = htmlwidgets::JS("function(value) {return value + '°C';}")
|
||||
)
|
||||
)
|
||||
))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,147 +0,0 @@
|
|||
<!-- Generated by pkgdown: do not edit by hand -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>License • apexcharter</title>
|
||||
|
||||
<!-- jquery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Font Awesome icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
|
||||
|
||||
<!-- clipboard.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- sticky kit -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- pkgdown -->
|
||||
<link href="pkgdown.css" rel="stylesheet">
|
||||
<script src="pkgdown.js"></script>
|
||||
|
||||
|
||||
|
||||
<meta property="og:title" content="License" />
|
||||
|
||||
|
||||
|
||||
<!-- mathjax -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container template-title-body">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!--/.nav-collapse -->
|
||||
</div><!--/.container -->
|
||||
</div><!--/.navbar -->
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="contents col-md-9">
|
||||
<div class="page-header">
|
||||
<h1>License</h1>
|
||||
</div>
|
||||
|
||||
<pre>YEAR: 2019
|
||||
COPYRIGHT HOLDER: Victor Perrier
|
||||
</pre>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://twitter.com/_pvictorr'><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"/> Victor Perrier</a>, <a href='https://twitter.com/_mfaan'><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg" /> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,151 +0,0 @@
|
|||
<!-- Generated by pkgdown: do not edit by hand -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Articles • apexcharter</title>
|
||||
|
||||
<!-- jquery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Font Awesome icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
|
||||
|
||||
<!-- clipboard.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- sticky kit -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- pkgdown -->
|
||||
<link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script>
|
||||
|
||||
|
||||
|
||||
<meta property="og:title" content="Articles" />
|
||||
|
||||
|
||||
|
||||
<!-- mathjax -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container template-article-index">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!--/.nav-collapse -->
|
||||
</div><!--/.container -->
|
||||
</div><!--/.navbar -->
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>Articles</h1>
|
||||
</div>
|
||||
|
||||
<div class="section ">
|
||||
<h3>All vignettes</h3>
|
||||
<p class="section-desc"></p>
|
||||
|
||||
<ul>
|
||||
<li><a href="labs.html">Labs: title, subtitle & axis</a></li>
|
||||
<li><a href="lines.html">Options & styles for lines</a></li>
|
||||
<li><a href="starting-with-apexcharts.html">Starting with ApexCharts</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://twitter.com/_pvictorr'><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"/> Victor Perrier</a>, <a href='https://twitter.com/_mfaan'><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg" /> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,193 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Labs: title, subtitle & axis • apexcharter</title>
|
||||
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous">
|
||||
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- sticky kit --><script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script><meta property="og:title" content="Labs: title, subtitle & axis">
|
||||
<meta property="og:description" content="">
|
||||
<meta name="twitter:card" content="summary">
|
||||
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div class="container template-article">
|
||||
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!--/.nav-collapse -->
|
||||
</div>
|
||||
<!--/.container -->
|
||||
</div>
|
||||
<!--/.navbar -->
|
||||
|
||||
|
||||
</header><script src="labs_files/htmlwidgets-1.3/htmlwidgets.js"></script><script src="labs_files/apexcharts-3.8.4/apexcharts.min.js"></script><script src="labs_files/apexcharter-binding-0.1.1.900/apexcharter.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1>Labs: title, subtitle & axis</h1>
|
||||
|
||||
|
||||
<small class="dont-index">Source: <a href="https://github.com/dreamRs/apexcharter/blob/master/vignettes/labs.Rmd"><code>vignettes/labs.Rmd</code></a></small>
|
||||
<div class="hidden name"><code>labs.Rmd</code></div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<p>Packages and data used below:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" title="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(apexcharter)</a>
|
||||
<a class="sourceLine" id="cb1-2" title="2"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(dplyr)</a>
|
||||
<a class="sourceLine" id="cb1-3" title="3"></a>
|
||||
<a class="sourceLine" id="cb1-4" title="4"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/data">data</a></span>(<span class="st">"diamonds"</span>, <span class="dt">package =</span> <span class="st">"ggplot2"</span>)</a>
|
||||
<a class="sourceLine" id="cb1-5" title="5">n_cut <-<span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/tally.html">count</a></span>(diamonds, cut)</a></code></pre></div>
|
||||
<div id="chart-title" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#chart-title" class="anchor"></a>Chart title</h2>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" title="1"><span class="kw"><a href="../reference/apex.html">apex</a></span>(<span class="dt">data =</span> n_cut, <span class="dt">type =</span> <span class="st">"column"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="../reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> cut, <span class="dt">y =</span> n)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb2-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/ax_title.html">ax_title</a></span>(<span class="dt">text =</span> <span class="st">"Cut distribution"</span>)</a></code></pre></div>
|
||||
<div id="htmlwidget-e057e8006ea4b6716be9" style="width:100%;height:350px;" class="apexcharter html-widget"></div>
|
||||
<script type="application/json" data-for="htmlwidget-e057e8006ea4b6716be9">{"x":{"ax_opts":{"chart":{"type":"bar"},"series":[{"name":"n","data":[{"x":"Fair","y":1610},{"x":"Good","y":4906},{"x":"Very Good","y":12082},{"x":"Premium","y":13791},{"x":"Ideal","y":21551}]}],"dataLabels":{"enabled":false},"plotOptions":{"bar":{"horizontal":false}},"title":{"text":"Cut distribution"}},"auto_update":true},"evals":[],"jsHooks":[]}</script><p>You can set some options, for example:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" title="1"><span class="kw"><a href="../reference/apex.html">apex</a></span>(<span class="dt">data =</span> n_cut, <span class="dt">type =</span> <span class="st">"column"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="../reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> cut, <span class="dt">y =</span> n)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb3-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/ax_title.html">ax_title</a></span>(</a>
|
||||
<a class="sourceLine" id="cb3-3" title="3"> <span class="dt">text =</span> <span class="st">"Cut distribution"</span>, </a>
|
||||
<a class="sourceLine" id="cb3-4" title="4"> <span class="dt">align =</span> <span class="st">"center"</span>,</a>
|
||||
<a class="sourceLine" id="cb3-5" title="5"> <span class="dt">style =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(<span class="dt">fontSize =</span> <span class="st">"22px"</span>)</a>
|
||||
<a class="sourceLine" id="cb3-6" title="6"> )</a></code></pre></div>
|
||||
<div id="htmlwidget-974d816d3b25ce58737c" style="width:100%;height:350px;" class="apexcharter html-widget"></div>
|
||||
<script type="application/json" data-for="htmlwidget-974d816d3b25ce58737c">{"x":{"ax_opts":{"chart":{"type":"bar"},"series":[{"name":"n","data":[{"x":"Fair","y":1610},{"x":"Good","y":4906},{"x":"Very Good","y":12082},{"x":"Premium","y":13791},{"x":"Ideal","y":21551}]}],"dataLabels":{"enabled":false},"plotOptions":{"bar":{"horizontal":false}},"title":{"text":"Cut distribution","align":"center","style":{"fontSize":"22px"}}},"auto_update":true},"evals":[],"jsHooks":[]}</script><p>Full list of parameters is available here : <a href="https://apexcharts.com/docs/options/title/" class="uri">https://apexcharts.com/docs/options/title/</a></p>
|
||||
</div>
|
||||
<div id="chart-subtitle" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#chart-subtitle" class="anchor"></a>Chart subtitle</h2>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1"><span class="kw"><a href="../reference/apex.html">apex</a></span>(<span class="dt">data =</span> n_cut, <span class="dt">type =</span> <span class="st">"column"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="../reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> cut, <span class="dt">y =</span> n)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb4-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/ax_title.html">ax_title</a></span>(<span class="dt">text =</span> <span class="st">"Cut distribution"</span>) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb4-3" title="3"><span class="st"> </span><span class="kw"><a href="../reference/ax_subtitle.html">ax_subtitle</a></span>(<span class="dt">text =</span> <span class="st">"Data from ggplot2"</span>)</a></code></pre></div>
|
||||
<div id="htmlwidget-09c5ec6a4b1d2d74f9f9" style="width:100%;height:350px;" class="apexcharter html-widget"></div>
|
||||
<script type="application/json" data-for="htmlwidget-09c5ec6a4b1d2d74f9f9">{"x":{"ax_opts":{"chart":{"type":"bar"},"series":[{"name":"n","data":[{"x":"Fair","y":1610},{"x":"Good","y":4906},{"x":"Very Good","y":12082},{"x":"Premium","y":13791},{"x":"Ideal","y":21551}]}],"dataLabels":{"enabled":false},"plotOptions":{"bar":{"horizontal":false}},"title":{"text":"Cut distribution"},"subtitle":{"text":"Data from ggplot2"}},"auto_update":true},"evals":[],"jsHooks":[]}</script><p>With same options than for title:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" title="1"><span class="kw"><a href="../reference/apex.html">apex</a></span>(<span class="dt">data =</span> n_cut, <span class="dt">type =</span> <span class="st">"column"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="../reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> cut, <span class="dt">y =</span> n)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb5-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/ax_title.html">ax_title</a></span>(</a>
|
||||
<a class="sourceLine" id="cb5-3" title="3"> <span class="dt">text =</span> <span class="st">"Cut distribution"</span>, </a>
|
||||
<a class="sourceLine" id="cb5-4" title="4"> <span class="dt">align =</span> <span class="st">"center"</span>,</a>
|
||||
<a class="sourceLine" id="cb5-5" title="5"> <span class="dt">style =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(<span class="dt">fontSize =</span> <span class="st">"22px"</span>)</a>
|
||||
<a class="sourceLine" id="cb5-6" title="6"> ) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb5-7" title="7"><span class="st"> </span><span class="kw"><a href="../reference/ax_subtitle.html">ax_subtitle</a></span>(</a>
|
||||
<a class="sourceLine" id="cb5-8" title="8"> <span class="dt">text =</span> <span class="st">"Data from ggplot2"</span>, </a>
|
||||
<a class="sourceLine" id="cb5-9" title="9"> <span class="dt">align =</span> <span class="st">"center"</span>,</a>
|
||||
<a class="sourceLine" id="cb5-10" title="10"> <span class="dt">style =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(<span class="dt">fontSize =</span> <span class="st">"16px"</span>, <span class="dt">color =</span> <span class="st">"#BDBDBD"</span>)</a>
|
||||
<a class="sourceLine" id="cb5-11" title="11"> )</a></code></pre></div>
|
||||
<div id="htmlwidget-967f2e1007f7c32e1a00" style="width:100%;height:350px;" class="apexcharter html-widget"></div>
|
||||
<script type="application/json" data-for="htmlwidget-967f2e1007f7c32e1a00">{"x":{"ax_opts":{"chart":{"type":"bar"},"series":[{"name":"n","data":[{"x":"Fair","y":1610},{"x":"Good","y":4906},{"x":"Very Good","y":12082},{"x":"Premium","y":13791},{"x":"Ideal","y":21551}]}],"dataLabels":{"enabled":false},"plotOptions":{"bar":{"horizontal":false}},"title":{"text":"Cut distribution","align":"center","style":{"fontSize":"22px"}},"subtitle":{"text":"Data from ggplot2","align":"center","style":{"fontSize":"16px","color":"#BDBDBD"}}},"auto_update":true},"evals":[],"jsHooks":[]}</script><p>Full list of parameters is available here : <a href="https://apexcharts.com/docs/options/subtitle/" class="uri">https://apexcharts.com/docs/options/subtitle/</a></p>
|
||||
</div>
|
||||
<div id="axis-title" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#axis-title" class="anchor"></a>Axis title</h2>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" title="1"><span class="kw"><a href="../reference/apex.html">apex</a></span>(<span class="dt">data =</span> n_cut, <span class="dt">type =</span> <span class="st">"column"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="../reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> cut, <span class="dt">y =</span> n)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb6-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/ax_yaxis.html">ax_yaxis</a></span>(<span class="dt">title =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(<span class="dt">text =</span> <span class="st">"Count"</span>)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb6-3" title="3"><span class="st"> </span><span class="kw"><a href="../reference/ax_xaxis.html">ax_xaxis</a></span>(<span class="dt">title =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(<span class="dt">text =</span> <span class="st">"Cut"</span>))</a></code></pre></div>
|
||||
<div id="htmlwidget-1d0690dd3bb9a09d4bd7" style="width:100%;height:350px;" class="apexcharter html-widget"></div>
|
||||
<script type="application/json" data-for="htmlwidget-1d0690dd3bb9a09d4bd7">{"x":{"ax_opts":{"chart":{"type":"bar"},"series":[{"name":"n","data":[{"x":"Fair","y":1610},{"x":"Good","y":4906},{"x":"Very Good","y":12082},{"x":"Premium","y":13791},{"x":"Ideal","y":21551}]}],"dataLabels":{"enabled":false},"plotOptions":{"bar":{"horizontal":false}},"yaxis":{"title":{"text":"Count"}},"xaxis":{"title":{"text":"Cut"}}},"auto_update":true},"evals":[],"jsHooks":[]}</script><p>With some options:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" title="1"><span class="kw"><a href="../reference/apex.html">apex</a></span>(<span class="dt">data =</span> n_cut, <span class="dt">type =</span> <span class="st">"column"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="../reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> cut, <span class="dt">y =</span> n)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb7-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/ax_yaxis.html">ax_yaxis</a></span>(<span class="dt">title =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb7-3" title="3"> <span class="dt">text =</span> <span class="st">"Count"</span>,</a>
|
||||
<a class="sourceLine" id="cb7-4" title="4"> <span class="dt">style =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(<span class="dt">fontSize =</span> <span class="st">"14px"</span>, <span class="dt">color =</span> <span class="st">"#BDBDBD"</span>)</a>
|
||||
<a class="sourceLine" id="cb7-5" title="5"> )) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb7-6" title="6"><span class="st"> </span><span class="kw"><a href="../reference/ax_xaxis.html">ax_xaxis</a></span>(<span class="dt">title =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb7-7" title="7"> <span class="dt">text =</span> <span class="st">"Cut"</span>, </a>
|
||||
<a class="sourceLine" id="cb7-8" title="8"> <span class="dt">style =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(<span class="dt">fontSize =</span> <span class="st">"14px"</span>, <span class="dt">color =</span> <span class="st">"#BDBDBD"</span>)</a>
|
||||
<a class="sourceLine" id="cb7-9" title="9"> ))</a></code></pre></div>
|
||||
<div id="htmlwidget-41dba20af0d629dd7f00" style="width:100%;height:350px;" class="apexcharter html-widget"></div>
|
||||
<script type="application/json" data-for="htmlwidget-41dba20af0d629dd7f00">{"x":{"ax_opts":{"chart":{"type":"bar"},"series":[{"name":"n","data":[{"x":"Fair","y":1610},{"x":"Good","y":4906},{"x":"Very Good","y":12082},{"x":"Premium","y":13791},{"x":"Ideal","y":21551}]}],"dataLabels":{"enabled":false},"plotOptions":{"bar":{"horizontal":false}},"yaxis":{"title":{"text":"Count","style":{"fontSize":"14px","color":"#BDBDBD"}}},"xaxis":{"title":{"text":"Cut","style":{"fontSize":"14px","color":"#BDBDBD"}}}},"auto_update":true},"evals":[],"jsHooks":[]}</script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
<div id="tocnav">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#tocnav" class="anchor"></a>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#chart-title">Chart title</a></li>
|
||||
<li><a href="#chart-subtitle">Chart subtitle</a></li>
|
||||
<li><a href="#axis-title">Axis title</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<footer><div class="copyright">
|
||||
<p>Developed by <a href="https://twitter.com/_pvictorr"><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"> Victor Perrier</a>, <a href="https://twitter.com/_mfaan"><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg"> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,104 +0,0 @@
|
|||
HTMLWidgets.widget({
|
||||
|
||||
name: 'apexcharter',
|
||||
|
||||
type: 'output',
|
||||
|
||||
factory: function(el, width, height) {
|
||||
|
||||
var ax_opts;
|
||||
var apexchart = null;
|
||||
|
||||
return {
|
||||
|
||||
renderValue: function(x) {
|
||||
|
||||
|
||||
// Global options
|
||||
ax_opts = x.ax_opts;
|
||||
|
||||
// Sizing
|
||||
if (typeof ax_opts.chart === 'undefined') {
|
||||
ax_opts.chart = {};
|
||||
}
|
||||
ax_opts.chart.width = width;
|
||||
ax_opts.chart.height = height;
|
||||
|
||||
// Generate or update chart
|
||||
if (apexchart === null) {
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
} else {
|
||||
if (x.auto_update) {
|
||||
apexchart.updateSeries(ax_opts.series);
|
||||
} else {
|
||||
apexchart.destroy();
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
getChart: function(){
|
||||
return apexchart;
|
||||
},
|
||||
|
||||
resize: function(width, height) {
|
||||
apexchart.updateOptions({
|
||||
chart: {
|
||||
width: width,
|
||||
height: height
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// From Friss tuto (https://github.com/FrissAnalytics/shinyJsTutorials/blob/master/tutorials/tutorial_03.Rmd)
|
||||
function get_widget(id){
|
||||
|
||||
// Get the HTMLWidgets object
|
||||
var htmlWidgetsObj = HTMLWidgets.find("#" + id);
|
||||
|
||||
// Use the getChart method we created to get the underlying billboard chart
|
||||
var widgetObj ;
|
||||
|
||||
if (typeof htmlWidgetsObj != 'undefined') {
|
||||
widgetObj = htmlWidgetsObj.getChart();
|
||||
}
|
||||
|
||||
return(widgetObj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (HTMLWidgets.shinyMode) {
|
||||
// update serie
|
||||
Shiny.addCustomMessageHandler('update-apexchart-series',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateSeries([{
|
||||
data: obj.data.newSeries
|
||||
}], obj.data.animate);
|
||||
}
|
||||
});
|
||||
|
||||
// update options
|
||||
Shiny.addCustomMessageHandler('update-apexchart-options',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateOptions(obj.data.options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
HTMLWidgets.widget({
|
||||
|
||||
name: 'apexcharter',
|
||||
|
||||
type: 'output',
|
||||
|
||||
factory: function(el, width, height) {
|
||||
|
||||
var ax_opts;
|
||||
var apexchart = null;
|
||||
|
||||
return {
|
||||
|
||||
renderValue: function(x) {
|
||||
|
||||
|
||||
// Global options
|
||||
ax_opts = x.ax_opts;
|
||||
|
||||
// Sizing
|
||||
if (typeof ax_opts.chart === 'undefined') {
|
||||
ax_opts.chart = {};
|
||||
}
|
||||
ax_opts.chart.width = width;
|
||||
ax_opts.chart.height = height;
|
||||
if (!ax_opts.chart.hasOwnProperty('parentHeightOffset')) {
|
||||
ax_opts.chart.parentHeightOffset = 0;
|
||||
}
|
||||
|
||||
// Generate or update chart
|
||||
if (apexchart === null) {
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
} else {
|
||||
if (x.auto_update) {
|
||||
apexchart.updateSeries(ax_opts.series);
|
||||
} else {
|
||||
apexchart.destroy();
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
getChart: function(){
|
||||
return apexchart;
|
||||
},
|
||||
|
||||
resize: function(width, height) {
|
||||
apexchart.updateOptions({
|
||||
chart: {
|
||||
width: width,
|
||||
height: height
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// From Friss tuto (https://github.com/FrissAnalytics/shinyJsTutorials/blob/master/tutorials/tutorial_03.Rmd)
|
||||
function get_widget(id){
|
||||
|
||||
// Get the HTMLWidgets object
|
||||
var htmlWidgetsObj = HTMLWidgets.find("#" + id);
|
||||
|
||||
// Use the getChart method we created to get the underlying billboard chart
|
||||
var widgetObj ;
|
||||
|
||||
if (typeof htmlWidgetsObj != 'undefined') {
|
||||
widgetObj = htmlWidgetsObj.getChart();
|
||||
}
|
||||
|
||||
return(widgetObj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (HTMLWidgets.shinyMode) {
|
||||
// update serie
|
||||
Shiny.addCustomMessageHandler('update-apexchart-series',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateSeries([{
|
||||
data: obj.data.newSeries
|
||||
}], obj.data.animate);
|
||||
}
|
||||
});
|
||||
|
||||
// update options
|
||||
Shiny.addCustomMessageHandler('update-apexchart-options',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateOptions(obj.data.options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
HTMLWidgets.widget({
|
||||
|
||||
name: 'apexcharter',
|
||||
|
||||
type: 'output',
|
||||
|
||||
factory: function(el, width, height) {
|
||||
|
||||
var ax_opts;
|
||||
var apexchart = null;
|
||||
|
||||
return {
|
||||
|
||||
renderValue: function(x) {
|
||||
|
||||
|
||||
// Global options
|
||||
ax_opts = x.ax_opts;
|
||||
|
||||
// Sizing
|
||||
if (typeof ax_opts.chart === 'undefined') {
|
||||
ax_opts.chart = {};
|
||||
}
|
||||
ax_opts.chart.width = width;
|
||||
ax_opts.chart.height = height;
|
||||
|
||||
// Generate or update chart
|
||||
if (apexchart === null) {
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
} else {
|
||||
if (x.auto_update) {
|
||||
apexchart.updateSeries(ax_opts.series);
|
||||
} else {
|
||||
apexchart.destroy();
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
getChart: function(){
|
||||
return apexchart;
|
||||
},
|
||||
|
||||
resize: function(width, height) {
|
||||
apexchart.updateOptions({
|
||||
chart: {
|
||||
width: width,
|
||||
height: height
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// From Friss tuto (https://github.com/FrissAnalytics/shinyJsTutorials/blob/master/tutorials/tutorial_03.Rmd)
|
||||
function get_widget(id){
|
||||
|
||||
// Get the HTMLWidgets object
|
||||
var htmlWidgetsObj = HTMLWidgets.find("#" + id);
|
||||
|
||||
// Use the getChart method we created to get the underlying billboard chart
|
||||
var widgetObj ;
|
||||
|
||||
if (typeof htmlWidgetsObj != 'undefined') {
|
||||
widgetObj = htmlWidgetsObj.getChart();
|
||||
}
|
||||
|
||||
return(widgetObj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (HTMLWidgets.shinyMode) {
|
||||
// update serie
|
||||
Shiny.addCustomMessageHandler('update-apexchart-series',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateSeries([{
|
||||
data: obj.data.newSeries
|
||||
}], obj.data.animate);
|
||||
}
|
||||
});
|
||||
|
||||
// update options
|
||||
Shiny.addCustomMessageHandler('update-apexchart-options',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateOptions(obj.data.options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,839 +0,0 @@
|
|||
(function() {
|
||||
// If window.HTMLWidgets is already defined, then use it; otherwise create a
|
||||
// new object. This allows preceding code to set options that affect the
|
||||
// initialization process (though none currently exist).
|
||||
window.HTMLWidgets = window.HTMLWidgets || {};
|
||||
|
||||
// See if we're running in a viewer pane. If not, we're in a web browser.
|
||||
var viewerMode = window.HTMLWidgets.viewerMode =
|
||||
/\bviewer_pane=1\b/.test(window.location);
|
||||
|
||||
// See if we're running in Shiny mode. If not, it's a static document.
|
||||
// Note that static widgets can appear in both Shiny and static modes, but
|
||||
// obviously, Shiny widgets can only appear in Shiny apps/documents.
|
||||
var shinyMode = window.HTMLWidgets.shinyMode =
|
||||
typeof(window.Shiny) !== "undefined" && !!window.Shiny.outputBindings;
|
||||
|
||||
// We can't count on jQuery being available, so we implement our own
|
||||
// version if necessary.
|
||||
function querySelectorAll(scope, selector) {
|
||||
if (typeof(jQuery) !== "undefined" && scope instanceof jQuery) {
|
||||
return scope.find(selector);
|
||||
}
|
||||
if (scope.querySelectorAll) {
|
||||
return scope.querySelectorAll(selector);
|
||||
}
|
||||
}
|
||||
|
||||
function asArray(value) {
|
||||
if (value === null)
|
||||
return [];
|
||||
if ($.isArray(value))
|
||||
return value;
|
||||
return [value];
|
||||
}
|
||||
|
||||
// Implement jQuery's extend
|
||||
function extend(target /*, ... */) {
|
||||
if (arguments.length == 1) {
|
||||
return target;
|
||||
}
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
for (var prop in source) {
|
||||
if (source.hasOwnProperty(prop)) {
|
||||
target[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
// IE8 doesn't support Array.forEach.
|
||||
function forEach(values, callback, thisArg) {
|
||||
if (values.forEach) {
|
||||
values.forEach(callback, thisArg);
|
||||
} else {
|
||||
for (var i = 0; i < values.length; i++) {
|
||||
callback.call(thisArg, values[i], i, values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Replaces the specified method with the return value of funcSource.
|
||||
//
|
||||
// Note that funcSource should not BE the new method, it should be a function
|
||||
// that RETURNS the new method. funcSource receives a single argument that is
|
||||
// the overridden method, it can be called from the new method. The overridden
|
||||
// method can be called like a regular function, it has the target permanently
|
||||
// bound to it so "this" will work correctly.
|
||||
function overrideMethod(target, methodName, funcSource) {
|
||||
var superFunc = target[methodName] || function() {};
|
||||
var superFuncBound = function() {
|
||||
return superFunc.apply(target, arguments);
|
||||
};
|
||||
target[methodName] = funcSource(superFuncBound);
|
||||
}
|
||||
|
||||
// Add a method to delegator that, when invoked, calls
|
||||
// delegatee.methodName. If there is no such method on
|
||||
// the delegatee, but there was one on delegator before
|
||||
// delegateMethod was called, then the original version
|
||||
// is invoked instead.
|
||||
// For example:
|
||||
//
|
||||
// var a = {
|
||||
// method1: function() { console.log('a1'); }
|
||||
// method2: function() { console.log('a2'); }
|
||||
// };
|
||||
// var b = {
|
||||
// method1: function() { console.log('b1'); }
|
||||
// };
|
||||
// delegateMethod(a, b, "method1");
|
||||
// delegateMethod(a, b, "method2");
|
||||
// a.method1();
|
||||
// a.method2();
|
||||
//
|
||||
// The output would be "b1", "a2".
|
||||
function delegateMethod(delegator, delegatee, methodName) {
|
||||
var inherited = delegator[methodName];
|
||||
delegator[methodName] = function() {
|
||||
var target = delegatee;
|
||||
var method = delegatee[methodName];
|
||||
|
||||
// The method doesn't exist on the delegatee. Instead,
|
||||
// call the method on the delegator, if it exists.
|
||||
if (!method) {
|
||||
target = delegator;
|
||||
method = inherited;
|
||||
}
|
||||
|
||||
if (method) {
|
||||
return method.apply(target, arguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Implement a vague facsimilie of jQuery's data method
|
||||
function elementData(el, name, value) {
|
||||
if (arguments.length == 2) {
|
||||
return el["htmlwidget_data_" + name];
|
||||
} else if (arguments.length == 3) {
|
||||
el["htmlwidget_data_" + name] = value;
|
||||
return el;
|
||||
} else {
|
||||
throw new Error("Wrong number of arguments for elementData: " +
|
||||
arguments.length);
|
||||
}
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
|
||||
function escapeRegExp(str) {
|
||||
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||
}
|
||||
|
||||
function hasClass(el, className) {
|
||||
var re = new RegExp("\\b" + escapeRegExp(className) + "\\b");
|
||||
return re.test(el.className);
|
||||
}
|
||||
|
||||
// elements - array (or array-like object) of HTML elements
|
||||
// className - class name to test for
|
||||
// include - if true, only return elements with given className;
|
||||
// if false, only return elements *without* given className
|
||||
function filterByClass(elements, className, include) {
|
||||
var results = [];
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
if (hasClass(elements[i], className) == include)
|
||||
results.push(elements[i]);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
function on(obj, eventName, func) {
|
||||
if (obj.addEventListener) {
|
||||
obj.addEventListener(eventName, func, false);
|
||||
} else if (obj.attachEvent) {
|
||||
obj.attachEvent(eventName, func);
|
||||
}
|
||||
}
|
||||
|
||||
function off(obj, eventName, func) {
|
||||
if (obj.removeEventListener)
|
||||
obj.removeEventListener(eventName, func, false);
|
||||
else if (obj.detachEvent) {
|
||||
obj.detachEvent(eventName, func);
|
||||
}
|
||||
}
|
||||
|
||||
// Translate array of values to top/right/bottom/left, as usual with
|
||||
// the "padding" CSS property
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/padding
|
||||
function unpackPadding(value) {
|
||||
if (typeof(value) === "number")
|
||||
value = [value];
|
||||
if (value.length === 1) {
|
||||
return {top: value[0], right: value[0], bottom: value[0], left: value[0]};
|
||||
}
|
||||
if (value.length === 2) {
|
||||
return {top: value[0], right: value[1], bottom: value[0], left: value[1]};
|
||||
}
|
||||
if (value.length === 3) {
|
||||
return {top: value[0], right: value[1], bottom: value[2], left: value[1]};
|
||||
}
|
||||
if (value.length === 4) {
|
||||
return {top: value[0], right: value[1], bottom: value[2], left: value[3]};
|
||||
}
|
||||
}
|
||||
|
||||
// Convert an unpacked padding object to a CSS value
|
||||
function paddingToCss(paddingObj) {
|
||||
return paddingObj.top + "px " + paddingObj.right + "px " + paddingObj.bottom + "px " + paddingObj.left + "px";
|
||||
}
|
||||
|
||||
// Makes a number suitable for CSS
|
||||
function px(x) {
|
||||
if (typeof(x) === "number")
|
||||
return x + "px";
|
||||
else
|
||||
return x;
|
||||
}
|
||||
|
||||
// Retrieves runtime widget sizing information for an element.
|
||||
// The return value is either null, or an object with fill, padding,
|
||||
// defaultWidth, defaultHeight fields.
|
||||
function sizingPolicy(el) {
|
||||
var sizingEl = document.querySelector("script[data-for='" + el.id + "'][type='application/htmlwidget-sizing']");
|
||||
if (!sizingEl)
|
||||
return null;
|
||||
var sp = JSON.parse(sizingEl.textContent || sizingEl.text || "{}");
|
||||
if (viewerMode) {
|
||||
return sp.viewer;
|
||||
} else {
|
||||
return sp.browser;
|
||||
}
|
||||
}
|
||||
|
||||
// @param tasks Array of strings (or falsy value, in which case no-op).
|
||||
// Each element must be a valid JavaScript expression that yields a
|
||||
// function. Or, can be an array of objects with "code" and "data"
|
||||
// properties; in this case, the "code" property should be a string
|
||||
// of JS that's an expr that yields a function, and "data" should be
|
||||
// an object that will be added as an additional argument when that
|
||||
// function is called.
|
||||
// @param target The object that will be "this" for each function
|
||||
// execution.
|
||||
// @param args Array of arguments to be passed to the functions. (The
|
||||
// same arguments will be passed to all functions.)
|
||||
function evalAndRun(tasks, target, args) {
|
||||
if (tasks) {
|
||||
forEach(tasks, function(task) {
|
||||
var theseArgs = args;
|
||||
if (typeof(task) === "object") {
|
||||
theseArgs = theseArgs.concat([task.data]);
|
||||
task = task.code;
|
||||
}
|
||||
var taskFunc = eval("(" + task + ")");
|
||||
if (typeof(taskFunc) !== "function") {
|
||||
throw new Error("Task must be a function! Source:\n" + task);
|
||||
}
|
||||
taskFunc.apply(target, theseArgs);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function initSizing(el) {
|
||||
var sizing = sizingPolicy(el);
|
||||
if (!sizing)
|
||||
return;
|
||||
|
||||
var cel = document.getElementById("htmlwidget_container");
|
||||
if (!cel)
|
||||
return;
|
||||
|
||||
if (typeof(sizing.padding) !== "undefined") {
|
||||
document.body.style.margin = "0";
|
||||
document.body.style.padding = paddingToCss(unpackPadding(sizing.padding));
|
||||
}
|
||||
|
||||
if (sizing.fill) {
|
||||
document.body.style.overflow = "hidden";
|
||||
document.body.style.width = "100%";
|
||||
document.body.style.height = "100%";
|
||||
document.documentElement.style.width = "100%";
|
||||
document.documentElement.style.height = "100%";
|
||||
if (cel) {
|
||||
cel.style.position = "absolute";
|
||||
var pad = unpackPadding(sizing.padding);
|
||||
cel.style.top = pad.top + "px";
|
||||
cel.style.right = pad.right + "px";
|
||||
cel.style.bottom = pad.bottom + "px";
|
||||
cel.style.left = pad.left + "px";
|
||||
el.style.width = "100%";
|
||||
el.style.height = "100%";
|
||||
}
|
||||
|
||||
return {
|
||||
getWidth: function() { return cel.offsetWidth; },
|
||||
getHeight: function() { return cel.offsetHeight; }
|
||||
};
|
||||
|
||||
} else {
|
||||
el.style.width = px(sizing.width);
|
||||
el.style.height = px(sizing.height);
|
||||
|
||||
return {
|
||||
getWidth: function() { return el.offsetWidth; },
|
||||
getHeight: function() { return el.offsetHeight; }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Default implementations for methods
|
||||
var defaults = {
|
||||
find: function(scope) {
|
||||
return querySelectorAll(scope, "." + this.name);
|
||||
},
|
||||
renderError: function(el, err) {
|
||||
var $el = $(el);
|
||||
|
||||
this.clearError(el);
|
||||
|
||||
// Add all these error classes, as Shiny does
|
||||
var errClass = "shiny-output-error";
|
||||
if (err.type !== null) {
|
||||
// use the classes of the error condition as CSS class names
|
||||
errClass = errClass + " " + $.map(asArray(err.type), function(type) {
|
||||
return errClass + "-" + type;
|
||||
}).join(" ");
|
||||
}
|
||||
errClass = errClass + " htmlwidgets-error";
|
||||
|
||||
// Is el inline or block? If inline or inline-block, just display:none it
|
||||
// and add an inline error.
|
||||
var display = $el.css("display");
|
||||
$el.data("restore-display-mode", display);
|
||||
|
||||
if (display === "inline" || display === "inline-block") {
|
||||
$el.hide();
|
||||
if (err.message !== "") {
|
||||
var errorSpan = $("<span>").addClass(errClass);
|
||||
errorSpan.text(err.message);
|
||||
$el.after(errorSpan);
|
||||
}
|
||||
} else if (display === "block") {
|
||||
// If block, add an error just after the el, set visibility:none on the
|
||||
// el, and position the error to be on top of the el.
|
||||
// Mark it with a unique ID and CSS class so we can remove it later.
|
||||
$el.css("visibility", "hidden");
|
||||
if (err.message !== "") {
|
||||
var errorDiv = $("<div>").addClass(errClass).css("position", "absolute")
|
||||
.css("top", el.offsetTop)
|
||||
.css("left", el.offsetLeft)
|
||||
// setting width can push out the page size, forcing otherwise
|
||||
// unnecessary scrollbars to appear and making it impossible for
|
||||
// the element to shrink; so use max-width instead
|
||||
.css("maxWidth", el.offsetWidth)
|
||||
.css("height", el.offsetHeight);
|
||||
errorDiv.text(err.message);
|
||||
$el.after(errorDiv);
|
||||
|
||||
// Really dumb way to keep the size/position of the error in sync with
|
||||
// the parent element as the window is resized or whatever.
|
||||
var intId = setInterval(function() {
|
||||
if (!errorDiv[0].parentElement) {
|
||||
clearInterval(intId);
|
||||
return;
|
||||
}
|
||||
errorDiv
|
||||
.css("top", el.offsetTop)
|
||||
.css("left", el.offsetLeft)
|
||||
.css("maxWidth", el.offsetWidth)
|
||||
.css("height", el.offsetHeight);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
},
|
||||
clearError: function(el) {
|
||||
var $el = $(el);
|
||||
var display = $el.data("restore-display-mode");
|
||||
$el.data("restore-display-mode", null);
|
||||
|
||||
if (display === "inline" || display === "inline-block") {
|
||||
if (display)
|
||||
$el.css("display", display);
|
||||
$(el.nextSibling).filter(".htmlwidgets-error").remove();
|
||||
} else if (display === "block"){
|
||||
$el.css("visibility", "inherit");
|
||||
$(el.nextSibling).filter(".htmlwidgets-error").remove();
|
||||
}
|
||||
},
|
||||
sizing: {}
|
||||
};
|
||||
|
||||
// Called by widget bindings to register a new type of widget. The definition
|
||||
// object can contain the following properties:
|
||||
// - name (required) - A string indicating the binding name, which will be
|
||||
// used by default as the CSS classname to look for.
|
||||
// - initialize (optional) - A function(el) that will be called once per
|
||||
// widget element; if a value is returned, it will be passed as the third
|
||||
// value to renderValue.
|
||||
// - renderValue (required) - A function(el, data, initValue) that will be
|
||||
// called with data. Static contexts will cause this to be called once per
|
||||
// element; Shiny apps will cause this to be called multiple times per
|
||||
// element, as the data changes.
|
||||
window.HTMLWidgets.widget = function(definition) {
|
||||
if (!definition.name) {
|
||||
throw new Error("Widget must have a name");
|
||||
}
|
||||
if (!definition.type) {
|
||||
throw new Error("Widget must have a type");
|
||||
}
|
||||
// Currently we only support output widgets
|
||||
if (definition.type !== "output") {
|
||||
throw new Error("Unrecognized widget type '" + definition.type + "'");
|
||||
}
|
||||
// TODO: Verify that .name is a valid CSS classname
|
||||
|
||||
// Support new-style instance-bound definitions. Old-style class-bound
|
||||
// definitions have one widget "object" per widget per type/class of
|
||||
// widget; the renderValue and resize methods on such widget objects
|
||||
// take el and instance arguments, because the widget object can't
|
||||
// store them. New-style instance-bound definitions have one widget
|
||||
// object per widget instance; the definition that's passed in doesn't
|
||||
// provide renderValue or resize methods at all, just the single method
|
||||
// factory(el, width, height)
|
||||
// which returns an object that has renderValue(x) and resize(w, h).
|
||||
// This enables a far more natural programming style for the widget
|
||||
// author, who can store per-instance state using either OO-style
|
||||
// instance fields or functional-style closure variables (I guess this
|
||||
// is in contrast to what can only be called C-style pseudo-OO which is
|
||||
// what we required before).
|
||||
if (definition.factory) {
|
||||
definition = createLegacyDefinitionAdapter(definition);
|
||||
}
|
||||
|
||||
if (!definition.renderValue) {
|
||||
throw new Error("Widget must have a renderValue function");
|
||||
}
|
||||
|
||||
// For static rendering (non-Shiny), use a simple widget registration
|
||||
// scheme. We also use this scheme for Shiny apps/documents that also
|
||||
// contain static widgets.
|
||||
window.HTMLWidgets.widgets = window.HTMLWidgets.widgets || [];
|
||||
// Merge defaults into the definition; don't mutate the original definition.
|
||||
var staticBinding = extend({}, defaults, definition);
|
||||
overrideMethod(staticBinding, "find", function(superfunc) {
|
||||
return function(scope) {
|
||||
var results = superfunc(scope);
|
||||
// Filter out Shiny outputs, we only want the static kind
|
||||
return filterByClass(results, "html-widget-output", false);
|
||||
};
|
||||
});
|
||||
window.HTMLWidgets.widgets.push(staticBinding);
|
||||
|
||||
if (shinyMode) {
|
||||
// Shiny is running. Register the definition with an output binding.
|
||||
// The definition itself will not be the output binding, instead
|
||||
// we will make an output binding object that delegates to the
|
||||
// definition. This is because we foolishly used the same method
|
||||
// name (renderValue) for htmlwidgets definition and Shiny bindings
|
||||
// but they actually have quite different semantics (the Shiny
|
||||
// bindings receive data that includes lots of metadata that it
|
||||
// strips off before calling htmlwidgets renderValue). We can't
|
||||
// just ignore the difference because in some widgets it's helpful
|
||||
// to call this.renderValue() from inside of resize(), and if
|
||||
// we're not delegating, then that call will go to the Shiny
|
||||
// version instead of the htmlwidgets version.
|
||||
|
||||
// Merge defaults with definition, without mutating either.
|
||||
var bindingDef = extend({}, defaults, definition);
|
||||
|
||||
// This object will be our actual Shiny binding.
|
||||
var shinyBinding = new Shiny.OutputBinding();
|
||||
|
||||
// With a few exceptions, we'll want to simply use the bindingDef's
|
||||
// version of methods if they are available, otherwise fall back to
|
||||
// Shiny's defaults. NOTE: If Shiny's output bindings gain additional
|
||||
// methods in the future, and we want them to be overrideable by
|
||||
// HTMLWidget binding definitions, then we'll need to add them to this
|
||||
// list.
|
||||
delegateMethod(shinyBinding, bindingDef, "getId");
|
||||
delegateMethod(shinyBinding, bindingDef, "onValueChange");
|
||||
delegateMethod(shinyBinding, bindingDef, "onValueError");
|
||||
delegateMethod(shinyBinding, bindingDef, "renderError");
|
||||
delegateMethod(shinyBinding, bindingDef, "clearError");
|
||||
delegateMethod(shinyBinding, bindingDef, "showProgress");
|
||||
|
||||
// The find, renderValue, and resize are handled differently, because we
|
||||
// want to actually decorate the behavior of the bindingDef methods.
|
||||
|
||||
shinyBinding.find = function(scope) {
|
||||
var results = bindingDef.find(scope);
|
||||
|
||||
// Only return elements that are Shiny outputs, not static ones
|
||||
var dynamicResults = results.filter(".html-widget-output");
|
||||
|
||||
// It's possible that whatever caused Shiny to think there might be
|
||||
// new dynamic outputs, also caused there to be new static outputs.
|
||||
// Since there might be lots of different htmlwidgets bindings, we
|
||||
// schedule execution for later--no need to staticRender multiple
|
||||
// times.
|
||||
if (results.length !== dynamicResults.length)
|
||||
scheduleStaticRender();
|
||||
|
||||
return dynamicResults;
|
||||
};
|
||||
|
||||
// Wrap renderValue to handle initialization, which unfortunately isn't
|
||||
// supported natively by Shiny at the time of this writing.
|
||||
|
||||
shinyBinding.renderValue = function(el, data) {
|
||||
Shiny.renderDependencies(data.deps);
|
||||
// Resolve strings marked as javascript literals to objects
|
||||
if (!(data.evals instanceof Array)) data.evals = [data.evals];
|
||||
for (var i = 0; data.evals && i < data.evals.length; i++) {
|
||||
window.HTMLWidgets.evaluateStringMember(data.x, data.evals[i]);
|
||||
}
|
||||
if (!bindingDef.renderOnNullValue) {
|
||||
if (data.x === null) {
|
||||
el.style.visibility = "hidden";
|
||||
return;
|
||||
} else {
|
||||
el.style.visibility = "inherit";
|
||||
}
|
||||
}
|
||||
if (!elementData(el, "initialized")) {
|
||||
initSizing(el);
|
||||
|
||||
elementData(el, "initialized", true);
|
||||
if (bindingDef.initialize) {
|
||||
var result = bindingDef.initialize(el, el.offsetWidth,
|
||||
el.offsetHeight);
|
||||
elementData(el, "init_result", result);
|
||||
}
|
||||
}
|
||||
bindingDef.renderValue(el, data.x, elementData(el, "init_result"));
|
||||
evalAndRun(data.jsHooks.render, elementData(el, "init_result"), [el, data.x]);
|
||||
};
|
||||
|
||||
// Only override resize if bindingDef implements it
|
||||
if (bindingDef.resize) {
|
||||
shinyBinding.resize = function(el, width, height) {
|
||||
// Shiny can call resize before initialize/renderValue have been
|
||||
// called, which doesn't make sense for widgets.
|
||||
if (elementData(el, "initialized")) {
|
||||
bindingDef.resize(el, width, height, elementData(el, "init_result"));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Shiny.outputBindings.register(shinyBinding, bindingDef.name);
|
||||
}
|
||||
};
|
||||
|
||||
var scheduleStaticRenderTimerId = null;
|
||||
function scheduleStaticRender() {
|
||||
if (!scheduleStaticRenderTimerId) {
|
||||
scheduleStaticRenderTimerId = setTimeout(function() {
|
||||
scheduleStaticRenderTimerId = null;
|
||||
window.HTMLWidgets.staticRender();
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Render static widgets after the document finishes loading
|
||||
// Statically render all elements that are of this widget's class
|
||||
window.HTMLWidgets.staticRender = function() {
|
||||
var bindings = window.HTMLWidgets.widgets || [];
|
||||
forEach(bindings, function(binding) {
|
||||
var matches = binding.find(document.documentElement);
|
||||
forEach(matches, function(el) {
|
||||
var sizeObj = initSizing(el, binding);
|
||||
|
||||
if (hasClass(el, "html-widget-static-bound"))
|
||||
return;
|
||||
el.className = el.className + " html-widget-static-bound";
|
||||
|
||||
var initResult;
|
||||
if (binding.initialize) {
|
||||
initResult = binding.initialize(el,
|
||||
sizeObj ? sizeObj.getWidth() : el.offsetWidth,
|
||||
sizeObj ? sizeObj.getHeight() : el.offsetHeight
|
||||
);
|
||||
elementData(el, "init_result", initResult);
|
||||
}
|
||||
|
||||
if (binding.resize) {
|
||||
var lastSize = {
|
||||
w: sizeObj ? sizeObj.getWidth() : el.offsetWidth,
|
||||
h: sizeObj ? sizeObj.getHeight() : el.offsetHeight
|
||||
};
|
||||
var resizeHandler = function(e) {
|
||||
var size = {
|
||||
w: sizeObj ? sizeObj.getWidth() : el.offsetWidth,
|
||||
h: sizeObj ? sizeObj.getHeight() : el.offsetHeight
|
||||
};
|
||||
if (size.w === 0 && size.h === 0)
|
||||
return;
|
||||
if (size.w === lastSize.w && size.h === lastSize.h)
|
||||
return;
|
||||
lastSize = size;
|
||||
binding.resize(el, size.w, size.h, initResult);
|
||||
};
|
||||
|
||||
on(window, "resize", resizeHandler);
|
||||
|
||||
// This is needed for cases where we're running in a Shiny
|
||||
// app, but the widget itself is not a Shiny output, but
|
||||
// rather a simple static widget. One example of this is
|
||||
// an rmarkdown document that has runtime:shiny and widget
|
||||
// that isn't in a render function. Shiny only knows to
|
||||
// call resize handlers for Shiny outputs, not for static
|
||||
// widgets, so we do it ourselves.
|
||||
if (window.jQuery) {
|
||||
window.jQuery(document).on(
|
||||
"shown.htmlwidgets shown.bs.tab.htmlwidgets shown.bs.collapse.htmlwidgets",
|
||||
resizeHandler
|
||||
);
|
||||
window.jQuery(document).on(
|
||||
"hidden.htmlwidgets hidden.bs.tab.htmlwidgets hidden.bs.collapse.htmlwidgets",
|
||||
resizeHandler
|
||||
);
|
||||
}
|
||||
|
||||
// This is needed for the specific case of ioslides, which
|
||||
// flips slides between display:none and display:block.
|
||||
// Ideally we would not have to have ioslide-specific code
|
||||
// here, but rather have ioslides raise a generic event,
|
||||
// but the rmarkdown package just went to CRAN so the
|
||||
// window to getting that fixed may be long.
|
||||
if (window.addEventListener) {
|
||||
// It's OK to limit this to window.addEventListener
|
||||
// browsers because ioslides itself only supports
|
||||
// such browsers.
|
||||
on(document, "slideenter", resizeHandler);
|
||||
on(document, "slideleave", resizeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
var scriptData = document.querySelector("script[data-for='" + el.id + "'][type='application/json']");
|
||||
if (scriptData) {
|
||||
var data = JSON.parse(scriptData.textContent || scriptData.text);
|
||||
// Resolve strings marked as javascript literals to objects
|
||||
if (!(data.evals instanceof Array)) data.evals = [data.evals];
|
||||
for (var k = 0; data.evals && k < data.evals.length; k++) {
|
||||
window.HTMLWidgets.evaluateStringMember(data.x, data.evals[k]);
|
||||
}
|
||||
binding.renderValue(el, data.x, initResult);
|
||||
evalAndRun(data.jsHooks.render, initResult, [el, data.x]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
invokePostRenderHandlers();
|
||||
}
|
||||
|
||||
// Wait until after the document has loaded to render the widgets.
|
||||
if (document.addEventListener) {
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
document.removeEventListener("DOMContentLoaded", arguments.callee, false);
|
||||
window.HTMLWidgets.staticRender();
|
||||
}, false);
|
||||
} else if (document.attachEvent) {
|
||||
document.attachEvent("onreadystatechange", function() {
|
||||
if (document.readyState === "complete") {
|
||||
document.detachEvent("onreadystatechange", arguments.callee);
|
||||
window.HTMLWidgets.staticRender();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
window.HTMLWidgets.getAttachmentUrl = function(depname, key) {
|
||||
// If no key, default to the first item
|
||||
if (typeof(key) === "undefined")
|
||||
key = 1;
|
||||
|
||||
var link = document.getElementById(depname + "-" + key + "-attachment");
|
||||
if (!link) {
|
||||
throw new Error("Attachment " + depname + "/" + key + " not found in document");
|
||||
}
|
||||
return link.getAttribute("href");
|
||||
};
|
||||
|
||||
window.HTMLWidgets.dataframeToD3 = function(df) {
|
||||
var names = [];
|
||||
var length;
|
||||
for (var name in df) {
|
||||
if (df.hasOwnProperty(name))
|
||||
names.push(name);
|
||||
if (typeof(df[name]) !== "object" || typeof(df[name].length) === "undefined") {
|
||||
throw new Error("All fields must be arrays");
|
||||
} else if (typeof(length) !== "undefined" && length !== df[name].length) {
|
||||
throw new Error("All fields must be arrays of the same length");
|
||||
}
|
||||
length = df[name].length;
|
||||
}
|
||||
var results = [];
|
||||
var item;
|
||||
for (var row = 0; row < length; row++) {
|
||||
item = {};
|
||||
for (var col = 0; col < names.length; col++) {
|
||||
item[names[col]] = df[names[col]][row];
|
||||
}
|
||||
results.push(item);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
window.HTMLWidgets.transposeArray2D = function(array) {
|
||||
if (array.length === 0) return array;
|
||||
var newArray = array[0].map(function(col, i) {
|
||||
return array.map(function(row) {
|
||||
return row[i]
|
||||
})
|
||||
});
|
||||
return newArray;
|
||||
};
|
||||
// Split value at splitChar, but allow splitChar to be escaped
|
||||
// using escapeChar. Any other characters escaped by escapeChar
|
||||
// will be included as usual (including escapeChar itself).
|
||||
function splitWithEscape(value, splitChar, escapeChar) {
|
||||
var results = [];
|
||||
var escapeMode = false;
|
||||
var currentResult = "";
|
||||
for (var pos = 0; pos < value.length; pos++) {
|
||||
if (!escapeMode) {
|
||||
if (value[pos] === splitChar) {
|
||||
results.push(currentResult);
|
||||
currentResult = "";
|
||||
} else if (value[pos] === escapeChar) {
|
||||
escapeMode = true;
|
||||
} else {
|
||||
currentResult += value[pos];
|
||||
}
|
||||
} else {
|
||||
currentResult += value[pos];
|
||||
escapeMode = false;
|
||||
}
|
||||
}
|
||||
if (currentResult !== "") {
|
||||
results.push(currentResult);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
// Function authored by Yihui/JJ Allaire
|
||||
window.HTMLWidgets.evaluateStringMember = function(o, member) {
|
||||
var parts = splitWithEscape(member, '.', '\\');
|
||||
for (var i = 0, l = parts.length; i < l; i++) {
|
||||
var part = parts[i];
|
||||
// part may be a character or 'numeric' member name
|
||||
if (o !== null && typeof o === "object" && part in o) {
|
||||
if (i == (l - 1)) { // if we are at the end of the line then evalulate
|
||||
if (typeof o[part] === "string")
|
||||
o[part] = eval("(" + o[part] + ")");
|
||||
} else { // otherwise continue to next embedded object
|
||||
o = o[part];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Retrieve the HTMLWidget instance (i.e. the return value of an
|
||||
// HTMLWidget binding's initialize() or factory() function)
|
||||
// associated with an element, or null if none.
|
||||
window.HTMLWidgets.getInstance = function(el) {
|
||||
return elementData(el, "init_result");
|
||||
};
|
||||
|
||||
// Finds the first element in the scope that matches the selector,
|
||||
// and returns the HTMLWidget instance (i.e. the return value of
|
||||
// an HTMLWidget binding's initialize() or factory() function)
|
||||
// associated with that element, if any. If no element matches the
|
||||
// selector, or the first matching element has no HTMLWidget
|
||||
// instance associated with it, then null is returned.
|
||||
//
|
||||
// The scope argument is optional, and defaults to window.document.
|
||||
window.HTMLWidgets.find = function(scope, selector) {
|
||||
if (arguments.length == 1) {
|
||||
selector = scope;
|
||||
scope = document;
|
||||
}
|
||||
|
||||
var el = scope.querySelector(selector);
|
||||
if (el === null) {
|
||||
return null;
|
||||
} else {
|
||||
return window.HTMLWidgets.getInstance(el);
|
||||
}
|
||||
};
|
||||
|
||||
// Finds all elements in the scope that match the selector, and
|
||||
// returns the HTMLWidget instances (i.e. the return values of
|
||||
// an HTMLWidget binding's initialize() or factory() function)
|
||||
// associated with the elements, in an array. If elements that
|
||||
// match the selector don't have an associated HTMLWidget
|
||||
// instance, the returned array will contain nulls.
|
||||
//
|
||||
// The scope argument is optional, and defaults to window.document.
|
||||
window.HTMLWidgets.findAll = function(scope, selector) {
|
||||
if (arguments.length == 1) {
|
||||
selector = scope;
|
||||
scope = document;
|
||||
}
|
||||
|
||||
var nodes = scope.querySelectorAll(selector);
|
||||
var results = [];
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
results.push(window.HTMLWidgets.getInstance(nodes[i]));
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
var postRenderHandlers = [];
|
||||
function invokePostRenderHandlers() {
|
||||
while (postRenderHandlers.length) {
|
||||
var handler = postRenderHandlers.shift();
|
||||
if (handler) {
|
||||
handler();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register the given callback function to be invoked after the
|
||||
// next time static widgets are rendered.
|
||||
window.HTMLWidgets.addPostRenderHandler = function(callback) {
|
||||
postRenderHandlers.push(callback);
|
||||
};
|
||||
|
||||
// Takes a new-style instance-bound definition, and returns an
|
||||
// old-style class-bound definition. This saves us from having
|
||||
// to rewrite all the logic in this file to accomodate both
|
||||
// types of definitions.
|
||||
function createLegacyDefinitionAdapter(defn) {
|
||||
var result = {
|
||||
name: defn.name,
|
||||
type: defn.type,
|
||||
initialize: function(el, width, height) {
|
||||
return defn.factory(el, width, height);
|
||||
},
|
||||
renderValue: function(el, x, instance) {
|
||||
return instance.renderValue(x);
|
||||
},
|
||||
resize: function(el, width, height, instance) {
|
||||
return instance.resize(width, height);
|
||||
}
|
||||
};
|
||||
|
||||
if (defn.find)
|
||||
result.find = defn.find;
|
||||
if (defn.renderError)
|
||||
result.renderError = defn.renderError;
|
||||
if (defn.clearError)
|
||||
result.clearError = defn.clearError;
|
||||
|
||||
return result;
|
||||
}
|
||||
})();
|
||||
|
|
@ -1,219 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Options & styles for lines • apexcharter</title>
|
||||
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous">
|
||||
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- sticky kit --><script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script><meta property="og:title" content="Options & styles for lines">
|
||||
<meta property="og:description" content="">
|
||||
<meta name="twitter:card" content="summary">
|
||||
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div class="container template-article">
|
||||
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!--/.nav-collapse -->
|
||||
</div>
|
||||
<!--/.container -->
|
||||
</div>
|
||||
<!--/.navbar -->
|
||||
|
||||
|
||||
</header><script src="lines_files/htmlwidgets-1.3/htmlwidgets.js"></script><script src="lines_files/apexcharts-3.8.4/apexcharts.min.js"></script><script src="lines_files/apexcharter-binding-0.1.1.900/apexcharter.js"></script><div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header toc-ignore">
|
||||
<h1>Options & styles for lines</h1>
|
||||
|
||||
|
||||
<small class="dont-index">Source: <a href="https://github.com/dreamRs/apexcharter/blob/master/vignettes/lines.Rmd"><code>vignettes/lines.Rmd</code></a></small>
|
||||
<div class="hidden name"><code>lines.Rmd</code></div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" title="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(apexcharter)</a>
|
||||
<a class="sourceLine" id="cb1-2" title="2"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(dplyr)</a>
|
||||
<a class="sourceLine" id="cb1-3" title="3"></a>
|
||||
<a class="sourceLine" id="cb1-4" title="4"><span class="co"># economics dataset from ggplot2</span></a>
|
||||
<a class="sourceLine" id="cb1-5" title="5"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/data">data</a></span>(<span class="st">"economics"</span>, <span class="dt">package =</span> <span class="st">"ggplot2"</span>)</a>
|
||||
<a class="sourceLine" id="cb1-6" title="6">economics <-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/head">tail</a></span>(economics, <span class="dv">50</span>)</a>
|
||||
<a class="sourceLine" id="cb1-7" title="7"></a>
|
||||
<a class="sourceLine" id="cb1-8" title="8"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/data">data</a></span>(<span class="st">"economics_long"</span>, <span class="dt">package =</span> <span class="st">"ggplot2"</span>)</a>
|
||||
<a class="sourceLine" id="cb1-9" title="9">economics_long <-<span class="st"> </span>economics_long <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb1-10" title="10"><span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/stats/topics/filter">filter</a></span>(variable <span class="op">%in%</span><span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="st">"pce"</span>, <span class="st">"pop"</span>)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb1-11" title="11"><span class="st"> </span><span class="kw">group_by</span>(variable) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb1-12" title="12"><span class="st"> </span><span class="kw">slice</span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/head">tail</a></span>(<span class="kw">row_number</span>(), <span class="dv">20</span>))</a></code></pre></div>
|
||||
<div id="type-of-line" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#type-of-line" class="anchor"></a>Type of line</h2>
|
||||
<p>Classic line:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" title="1"><span class="kw"><a href="../reference/apex.html">apex</a></span>(<span class="dt">data =</span> economics, <span class="dt">type =</span> <span class="st">"line"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="../reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> date, <span class="dt">y =</span> uempmed))</a></code></pre></div>
|
||||
<div id="htmlwidget-f5e1bb64011746d31777" style="width:100%;height:350px;" class="apexcharter html-widget"></div>
|
||||
<script type="application/json" data-for="htmlwidget-f5e1bb64011746d31777">{"x":{"ax_opts":{"chart":{"type":"line"},"series":[{"name":"uempmed","data":[["2011-03-01",21.5],["2011-04-01",20.9],["2011-05-01",21.6],["2011-06-01",22.4],["2011-07-01",22],["2011-08-01",22.4],["2011-09-01",22],["2011-10-01",20.6],["2011-11-01",20.8],["2011-12-01",20.5],["2012-01-01",20.8],["2012-02-01",19.7],["2012-03-01",19.2],["2012-04-01",19.1],["2012-05-01",19.9],["2012-06-01",20.4],["2012-07-01",17.5],["2012-08-01",18.4],["2012-09-01",18.8],["2012-10-01",19.9],["2012-11-01",18.6],["2012-12-01",17.7],["2013-01-01",15.8],["2013-02-01",17.2],["2013-03-01",17.6],["2013-04-01",17.1],["2013-05-01",17.1],["2013-06-01",17],["2013-07-01",16.2],["2013-08-01",16.5],["2013-09-01",16.5],["2013-10-01",16.3],["2013-11-01",17.1],["2013-12-01",17.3],["2014-01-01",15.4],["2014-02-01",15.9],["2014-03-01",15.8],["2014-04-01",15.7],["2014-05-01",14.6],["2014-06-01",13.8],["2014-07-01",13.1],["2014-08-01",12.9],["2014-09-01",13.4],["2014-10-01",13.6],["2014-11-01",13],["2014-12-01",12.9],["2015-01-01",13.2],["2015-02-01",12.9],["2015-03-01",12],["2015-04-01",11.5]]}],"dataLabels":{"enabled":false},"stroke":{"curve":"straight"},"xaxis":{"type":"datetime"}},"auto_update":true},"evals":[],"jsHooks":[]}</script><p>Spline curve:</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" title="1"><span class="kw"><a href="../reference/apex.html">apex</a></span>(<span class="dt">data =</span> economics, <span class="dt">type =</span> <span class="st">"line"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="../reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> date, <span class="dt">y =</span> uempmed)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb3-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/ax_stroke.html">ax_stroke</a></span>(<span class="dt">curve =</span> <span class="st">"smooth"</span>)</a></code></pre></div>
|
||||
<div id="htmlwidget-b6b9bc45a9e0ac210d78" style="width:100%;height:350px;" class="apexcharter html-widget"></div>
|
||||
<script type="application/json" data-for="htmlwidget-b6b9bc45a9e0ac210d78">{"x":{"ax_opts":{"chart":{"type":"line"},"series":[{"name":"uempmed","data":[["2011-03-01",21.5],["2011-04-01",20.9],["2011-05-01",21.6],["2011-06-01",22.4],["2011-07-01",22],["2011-08-01",22.4],["2011-09-01",22],["2011-10-01",20.6],["2011-11-01",20.8],["2011-12-01",20.5],["2012-01-01",20.8],["2012-02-01",19.7],["2012-03-01",19.2],["2012-04-01",19.1],["2012-05-01",19.9],["2012-06-01",20.4],["2012-07-01",17.5],["2012-08-01",18.4],["2012-09-01",18.8],["2012-10-01",19.9],["2012-11-01",18.6],["2012-12-01",17.7],["2013-01-01",15.8],["2013-02-01",17.2],["2013-03-01",17.6],["2013-04-01",17.1],["2013-05-01",17.1],["2013-06-01",17],["2013-07-01",16.2],["2013-08-01",16.5],["2013-09-01",16.5],["2013-10-01",16.3],["2013-11-01",17.1],["2013-12-01",17.3],["2014-01-01",15.4],["2014-02-01",15.9],["2014-03-01",15.8],["2014-04-01",15.7],["2014-05-01",14.6],["2014-06-01",13.8],["2014-07-01",13.1],["2014-08-01",12.9],["2014-09-01",13.4],["2014-10-01",13.6],["2014-11-01",13],["2014-12-01",12.9],["2015-01-01",13.2],["2015-02-01",12.9],["2015-03-01",12],["2015-04-01",11.5]]}],"dataLabels":{"enabled":false},"stroke":{"curve":"smooth"},"xaxis":{"type":"datetime"}},"auto_update":true},"evals":[],"jsHooks":[]}</script><p>Steps chart:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1"><span class="kw"><a href="../reference/apex.html">apex</a></span>(<span class="dt">data =</span> economics, <span class="dt">type =</span> <span class="st">"line"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="../reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> date, <span class="dt">y =</span> uempmed)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb4-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/ax_stroke.html">ax_stroke</a></span>(<span class="dt">curve =</span> <span class="st">"stepline"</span>)</a></code></pre></div>
|
||||
<div id="htmlwidget-afb72dcf27e8651d8ed4" style="width:100%;height:350px;" class="apexcharter html-widget"></div>
|
||||
<script type="application/json" data-for="htmlwidget-afb72dcf27e8651d8ed4">{"x":{"ax_opts":{"chart":{"type":"line"},"series":[{"name":"uempmed","data":[["2011-03-01",21.5],["2011-04-01",20.9],["2011-05-01",21.6],["2011-06-01",22.4],["2011-07-01",22],["2011-08-01",22.4],["2011-09-01",22],["2011-10-01",20.6],["2011-11-01",20.8],["2011-12-01",20.5],["2012-01-01",20.8],["2012-02-01",19.7],["2012-03-01",19.2],["2012-04-01",19.1],["2012-05-01",19.9],["2012-06-01",20.4],["2012-07-01",17.5],["2012-08-01",18.4],["2012-09-01",18.8],["2012-10-01",19.9],["2012-11-01",18.6],["2012-12-01",17.7],["2013-01-01",15.8],["2013-02-01",17.2],["2013-03-01",17.6],["2013-04-01",17.1],["2013-05-01",17.1],["2013-06-01",17],["2013-07-01",16.2],["2013-08-01",16.5],["2013-09-01",16.5],["2013-10-01",16.3],["2013-11-01",17.1],["2013-12-01",17.3],["2014-01-01",15.4],["2014-02-01",15.9],["2014-03-01",15.8],["2014-04-01",15.7],["2014-05-01",14.6],["2014-06-01",13.8],["2014-07-01",13.1],["2014-08-01",12.9],["2014-09-01",13.4],["2014-10-01",13.6],["2014-11-01",13],["2014-12-01",12.9],["2015-01-01",13.2],["2015-02-01",12.9],["2015-03-01",12],["2015-04-01",11.5]]}],"dataLabels":{"enabled":false},"stroke":{"curve":"stepline"},"xaxis":{"type":"datetime"}},"auto_update":true},"evals":[],"jsHooks":[]}</script>
|
||||
</div>
|
||||
<div id="line-appearance" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#line-appearance" class="anchor"></a>Line appearance</h2>
|
||||
<p>Color line with gradient:</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" title="1"><span class="kw"><a href="../reference/apex.html">apex</a></span>(<span class="dt">data =</span> economics, <span class="dt">type =</span> <span class="st">"line"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="../reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> date, <span class="dt">y =</span> uempmed)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb5-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/ax_fill.html">ax_fill</a></span>(</a>
|
||||
<a class="sourceLine" id="cb5-3" title="3"> <span class="dt">type =</span> <span class="st">"gradient"</span>,</a>
|
||||
<a class="sourceLine" id="cb5-4" title="4"> <span class="dt">gradient =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb5-5" title="5"> <span class="dt">shade =</span> <span class="st">"dark"</span>,</a>
|
||||
<a class="sourceLine" id="cb5-6" title="6"> <span class="dt">gradientToColors =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(<span class="st">"#FDD835"</span>),</a>
|
||||
<a class="sourceLine" id="cb5-7" title="7"> <span class="dt">shadeIntensity =</span> <span class="dv">1</span>,</a>
|
||||
<a class="sourceLine" id="cb5-8" title="8"> <span class="dt">type =</span> <span class="st">"horizontal"</span>,</a>
|
||||
<a class="sourceLine" id="cb5-9" title="9"> <span class="dt">opacityFrom =</span> <span class="dv">1</span>,</a>
|
||||
<a class="sourceLine" id="cb5-10" title="10"> <span class="dt">opacityTo =</span> <span class="dv">1</span>,</a>
|
||||
<a class="sourceLine" id="cb5-11" title="11"> <span class="dt">stops =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="dv">0</span>, <span class="dv">100</span>, <span class="dv">100</span>, <span class="dv">100</span>)</a>
|
||||
<a class="sourceLine" id="cb5-12" title="12"> )</a>
|
||||
<a class="sourceLine" id="cb5-13" title="13"> )</a></code></pre></div>
|
||||
<div id="htmlwidget-db4dc84422eb5f4d7f00" style="width:100%;height:350px;" class="apexcharter html-widget"></div>
|
||||
<script type="application/json" data-for="htmlwidget-db4dc84422eb5f4d7f00">{"x":{"ax_opts":{"chart":{"type":"line"},"series":[{"name":"uempmed","data":[["2011-03-01",21.5],["2011-04-01",20.9],["2011-05-01",21.6],["2011-06-01",22.4],["2011-07-01",22],["2011-08-01",22.4],["2011-09-01",22],["2011-10-01",20.6],["2011-11-01",20.8],["2011-12-01",20.5],["2012-01-01",20.8],["2012-02-01",19.7],["2012-03-01",19.2],["2012-04-01",19.1],["2012-05-01",19.9],["2012-06-01",20.4],["2012-07-01",17.5],["2012-08-01",18.4],["2012-09-01",18.8],["2012-10-01",19.9],["2012-11-01",18.6],["2012-12-01",17.7],["2013-01-01",15.8],["2013-02-01",17.2],["2013-03-01",17.6],["2013-04-01",17.1],["2013-05-01",17.1],["2013-06-01",17],["2013-07-01",16.2],["2013-08-01",16.5],["2013-09-01",16.5],["2013-10-01",16.3],["2013-11-01",17.1],["2013-12-01",17.3],["2014-01-01",15.4],["2014-02-01",15.9],["2014-03-01",15.8],["2014-04-01",15.7],["2014-05-01",14.6],["2014-06-01",13.8],["2014-07-01",13.1],["2014-08-01",12.9],["2014-09-01",13.4],["2014-10-01",13.6],["2014-11-01",13],["2014-12-01",12.9],["2015-01-01",13.2],["2015-02-01",12.9],["2015-03-01",12],["2015-04-01",11.5]]}],"dataLabels":{"enabled":false},"stroke":{"curve":"straight"},"xaxis":{"type":"datetime"},"fill":{"type":"gradient","gradient":{"shade":"dark","gradientToColors":["#FDD835"],"shadeIntensity":1,"type":"horizontal","opacityFrom":1,"opacityTo":1,"stops":[0,100,100,100]}}},"auto_update":true},"evals":[],"jsHooks":[]}</script><p>Solid area color:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" title="1"><span class="kw"><a href="../reference/apex.html">apex</a></span>(<span class="dt">data =</span> economics, <span class="dt">type =</span> <span class="st">"area"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="../reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> date, <span class="dt">y =</span> uempmed)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb6-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/ax_fill.html">ax_fill</a></span>(<span class="dt">type =</span> <span class="st">"solid"</span>, <span class="dt">opacity =</span> <span class="dv">1</span>)</a></code></pre></div>
|
||||
<div id="htmlwidget-525290eabb4923a5cfd6" style="width:100%;height:350px;" class="apexcharter html-widget"></div>
|
||||
<script type="application/json" data-for="htmlwidget-525290eabb4923a5cfd6">{"x":{"ax_opts":{"chart":{"type":"area"},"series":[{"name":"uempmed","data":[["2011-03-01",21.5],["2011-04-01",20.9],["2011-05-01",21.6],["2011-06-01",22.4],["2011-07-01",22],["2011-08-01",22.4],["2011-09-01",22],["2011-10-01",20.6],["2011-11-01",20.8],["2011-12-01",20.5],["2012-01-01",20.8],["2012-02-01",19.7],["2012-03-01",19.2],["2012-04-01",19.1],["2012-05-01",19.9],["2012-06-01",20.4],["2012-07-01",17.5],["2012-08-01",18.4],["2012-09-01",18.8],["2012-10-01",19.9],["2012-11-01",18.6],["2012-12-01",17.7],["2013-01-01",15.8],["2013-02-01",17.2],["2013-03-01",17.6],["2013-04-01",17.1],["2013-05-01",17.1],["2013-06-01",17],["2013-07-01",16.2],["2013-08-01",16.5],["2013-09-01",16.5],["2013-10-01",16.3],["2013-11-01",17.1],["2013-12-01",17.3],["2014-01-01",15.4],["2014-02-01",15.9],["2014-03-01",15.8],["2014-04-01",15.7],["2014-05-01",14.6],["2014-06-01",13.8],["2014-07-01",13.1],["2014-08-01",12.9],["2014-09-01",13.4],["2014-10-01",13.6],["2014-11-01",13],["2014-12-01",12.9],["2015-01-01",13.2],["2015-02-01",12.9],["2015-03-01",12],["2015-04-01",11.5]]}],"dataLabels":{"enabled":false},"stroke":{"curve":"straight"},"xaxis":{"type":"datetime"},"fill":{"type":"solid","opacity":1}},"auto_update":true},"evals":[],"jsHooks":[]}</script><p>Line width:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" title="1"><span class="kw"><a href="../reference/apex.html">apex</a></span>(<span class="dt">data =</span> economics, <span class="dt">type =</span> <span class="st">"line"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="../reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> date, <span class="dt">y =</span> uempmed)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb7-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/ax_stroke.html">ax_stroke</a></span>(<span class="dt">width =</span> <span class="dv">1</span>)</a></code></pre></div>
|
||||
<div id="htmlwidget-c14099414a0a3dea1fbc" style="width:100%;height:350px;" class="apexcharter html-widget"></div>
|
||||
<script type="application/json" data-for="htmlwidget-c14099414a0a3dea1fbc">{"x":{"ax_opts":{"chart":{"type":"line"},"series":[{"name":"uempmed","data":[["2011-03-01",21.5],["2011-04-01",20.9],["2011-05-01",21.6],["2011-06-01",22.4],["2011-07-01",22],["2011-08-01",22.4],["2011-09-01",22],["2011-10-01",20.6],["2011-11-01",20.8],["2011-12-01",20.5],["2012-01-01",20.8],["2012-02-01",19.7],["2012-03-01",19.2],["2012-04-01",19.1],["2012-05-01",19.9],["2012-06-01",20.4],["2012-07-01",17.5],["2012-08-01",18.4],["2012-09-01",18.8],["2012-10-01",19.9],["2012-11-01",18.6],["2012-12-01",17.7],["2013-01-01",15.8],["2013-02-01",17.2],["2013-03-01",17.6],["2013-04-01",17.1],["2013-05-01",17.1],["2013-06-01",17],["2013-07-01",16.2],["2013-08-01",16.5],["2013-09-01",16.5],["2013-10-01",16.3],["2013-11-01",17.1],["2013-12-01",17.3],["2014-01-01",15.4],["2014-02-01",15.9],["2014-03-01",15.8],["2014-04-01",15.7],["2014-05-01",14.6],["2014-06-01",13.8],["2014-07-01",13.1],["2014-08-01",12.9],["2014-09-01",13.4],["2014-10-01",13.6],["2014-11-01",13],["2014-12-01",12.9],["2015-01-01",13.2],["2015-02-01",12.9],["2015-03-01",12],["2015-04-01",11.5]]}],"dataLabels":{"enabled":false},"stroke":{"curve":"straight","width":1},"xaxis":{"type":"datetime"}},"auto_update":true},"evals":[],"jsHooks":[]}</script><p>Dotted line</p>
|
||||
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" title="1"><span class="kw"><a href="../reference/apex.html">apex</a></span>(<span class="dt">data =</span> economics, <span class="dt">type =</span> <span class="st">"line"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="../reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> date, <span class="dt">y =</span> uempmed)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb8-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/ax_stroke.html">ax_stroke</a></span>(<span class="dt">dashArray =</span> <span class="dv">6</span>)</a></code></pre></div>
|
||||
<div id="htmlwidget-0ec7143318e604f720a6" style="width:100%;height:350px;" class="apexcharter html-widget"></div>
|
||||
<script type="application/json" data-for="htmlwidget-0ec7143318e604f720a6">{"x":{"ax_opts":{"chart":{"type":"line"},"series":[{"name":"uempmed","data":[["2011-03-01",21.5],["2011-04-01",20.9],["2011-05-01",21.6],["2011-06-01",22.4],["2011-07-01",22],["2011-08-01",22.4],["2011-09-01",22],["2011-10-01",20.6],["2011-11-01",20.8],["2011-12-01",20.5],["2012-01-01",20.8],["2012-02-01",19.7],["2012-03-01",19.2],["2012-04-01",19.1],["2012-05-01",19.9],["2012-06-01",20.4],["2012-07-01",17.5],["2012-08-01",18.4],["2012-09-01",18.8],["2012-10-01",19.9],["2012-11-01",18.6],["2012-12-01",17.7],["2013-01-01",15.8],["2013-02-01",17.2],["2013-03-01",17.6],["2013-04-01",17.1],["2013-05-01",17.1],["2013-06-01",17],["2013-07-01",16.2],["2013-08-01",16.5],["2013-09-01",16.5],["2013-10-01",16.3],["2013-11-01",17.1],["2013-12-01",17.3],["2014-01-01",15.4],["2014-02-01",15.9],["2014-03-01",15.8],["2014-04-01",15.7],["2014-05-01",14.6],["2014-06-01",13.8],["2014-07-01",13.1],["2014-08-01",12.9],["2014-09-01",13.4],["2014-10-01",13.6],["2014-11-01",13],["2014-12-01",12.9],["2015-01-01",13.2],["2015-02-01",12.9],["2015-03-01",12],["2015-04-01",11.5]]}],"dataLabels":{"enabled":false},"stroke":{"curve":"straight","dashArray":6},"xaxis":{"type":"datetime"}},"auto_update":true},"evals":[],"jsHooks":[]}</script>
|
||||
</div>
|
||||
<div id="markers" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#markers" class="anchor"></a>Markers</h2>
|
||||
<p>Add points to line :</p>
|
||||
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb9-1" title="1"><span class="kw"><a href="../reference/apex.html">apex</a></span>(<span class="dt">data =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/head">tail</a></span>(economics, <span class="dv">20</span>), <span class="dt">type =</span> <span class="st">"line"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="../reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> date, <span class="dt">y =</span> uempmed)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb9-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/ax_markers.html">ax_markers</a></span>(<span class="dt">size =</span> <span class="dv">6</span>)</a></code></pre></div>
|
||||
<div id="htmlwidget-77a2f76ff1e8e2a1ea58" style="width:100%;height:350px;" class="apexcharter html-widget"></div>
|
||||
<script type="application/json" data-for="htmlwidget-77a2f76ff1e8e2a1ea58">{"x":{"ax_opts":{"chart":{"type":"line"},"series":[{"name":"uempmed","data":[["2013-09-01",16.5],["2013-10-01",16.3],["2013-11-01",17.1],["2013-12-01",17.3],["2014-01-01",15.4],["2014-02-01",15.9],["2014-03-01",15.8],["2014-04-01",15.7],["2014-05-01",14.6],["2014-06-01",13.8],["2014-07-01",13.1],["2014-08-01",12.9],["2014-09-01",13.4],["2014-10-01",13.6],["2014-11-01",13],["2014-12-01",12.9],["2015-01-01",13.2],["2015-02-01",12.9],["2015-03-01",12],["2015-04-01",11.5]]}],"dataLabels":{"enabled":false},"stroke":{"curve":"straight"},"xaxis":{"type":"datetime"},"markers":{"size":6}},"auto_update":true},"evals":[],"jsHooks":[]}</script><p>Add labels over points</p>
|
||||
<div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb10-1" title="1"><span class="kw"><a href="../reference/apex.html">apex</a></span>(<span class="dt">data =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/head">tail</a></span>(economics, <span class="dv">20</span>), <span class="dt">type =</span> <span class="st">"line"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="../reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> date, <span class="dt">y =</span> uempmed)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb10-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/ax_markers.html">ax_markers</a></span>(<span class="dt">size =</span> <span class="dv">6</span>) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb10-3" title="3"><span class="st"> </span><span class="kw"><a href="../reference/ax_dataLabels.html">ax_dataLabels</a></span>(<span class="dt">enabled =</span> <span class="ot">TRUE</span>)</a></code></pre></div>
|
||||
<div id="htmlwidget-d9acc2c0937fa1da304c" style="width:100%;height:350px;" class="apexcharter html-widget"></div>
|
||||
<script type="application/json" data-for="htmlwidget-d9acc2c0937fa1da304c">{"x":{"ax_opts":{"chart":{"type":"line"},"series":[{"name":"uempmed","data":[["2013-09-01",16.5],["2013-10-01",16.3],["2013-11-01",17.1],["2013-12-01",17.3],["2014-01-01",15.4],["2014-02-01",15.9],["2014-03-01",15.8],["2014-04-01",15.7],["2014-05-01",14.6],["2014-06-01",13.8],["2014-07-01",13.1],["2014-08-01",12.9],["2014-09-01",13.4],["2014-10-01",13.6],["2014-11-01",13],["2014-12-01",12.9],["2015-01-01",13.2],["2015-02-01",12.9],["2015-03-01",12],["2015-04-01",11.5]]}],"dataLabels":{"enabled":true},"stroke":{"curve":"straight"},"xaxis":{"type":"datetime"},"markers":{"size":6}},"auto_update":true},"evals":[],"jsHooks":[]}</script>
|
||||
</div>
|
||||
<div id="multiple-lines" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#multiple-lines" class="anchor"></a>Multiple lines</h2>
|
||||
<p>You can use vectors of parameters to custom series separately:</p>
|
||||
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb11-1" title="1"><span class="kw"><a href="../reference/apex.html">apex</a></span>(<span class="dt">data =</span> economics_long, <span class="dt">type =</span> <span class="st">"line"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="../reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> date, <span class="dt">y =</span> value01, <span class="dt">group =</span> variable)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb11-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/ax_yaxis.html">ax_yaxis</a></span>(<span class="dt">decimalsInFloat =</span> <span class="dv">2</span>) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb11-3" title="3"><span class="st"> </span><span class="kw"><a href="../reference/ax_markers.html">ax_markers</a></span>(<span class="dt">size =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="dv">3</span>, <span class="dv">6</span>)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb11-4" title="4"><span class="st"> </span><span class="kw"><a href="../reference/ax_stroke.html">ax_stroke</a></span>(<span class="dt">width =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="dv">1</span>, <span class="dv">3</span>))</a></code></pre></div>
|
||||
<div id="htmlwidget-0b33ec1bb1b42d667398" style="width:100%;height:350px;" class="apexcharter html-widget"></div>
|
||||
<script type="application/json" data-for="htmlwidget-0b33ec1bb1b42d667398">{"x":{"ax_opts":{"chart":{"type":"line"},"series":[{"name":"pce","data":[["2013-09-01",0.92924677636026],["2013-10-01",0.933773134481608],["2013-11-01",0.939574402546397],["2013-12-01",0.942167004646148],["2014-01-01",0.941704956747183],["2014-02-01",0.946299766409118],["2014-03-01",0.952871114305516],["2014-04-01",0.957970754079284],["2014-05-01",0.961889604777918],["2014-06-01",0.967759324383294],["2014-07-01",0.971481376902739],["2014-08-01",0.978651675779278],["2014-09-01",0.979772569756398],["2014-10-01",0.985385596084572],["2014-11-01",0.987815625775428],["2014-12-01",0.988722608688212],["2015-01-01",0.987353577876462],["2015-02-01",0.990468122973193],["2015-03-01",0.99696246288643],["2015-04-01",1]]},{"name":"pop","data":[["2013-09-01",0.970448177482025],["2013-10-01",0.972224366782906],["2013-11-01",0.97391518362249],["2013-12-01",0.975423315392571],["2014-01-01",0.976921972290395],["2014-02-01",0.97823645673634],["2014-03-01",0.97957855225842],["2014-04-01",0.980992099657577],["2014-05-01",0.982473622896551],["2014-06-01",0.984073150615668],["2014-07-01",0.985702006885595],["2014-08-01",0.987603703319152],["2014-09-01",0.989506155770269],["2014-10-01",0.991383363808922],["2014-11-01",0.993112959418826],["2014-12-01",0.994608132061805],["2015-01-01",0.996107750416745],["2015-02-01",0.997306408041825],["2015-03-01",0.998590610697427],["2015-04-01",1]]}],"dataLabels":{"enabled":false},"stroke":{"curve":"straight","width":[1,3]},"xaxis":{"type":"datetime"},"yaxis":{"decimalsInFloat":2},"markers":{"size":[3,6]}},"auto_update":true},"evals":[],"jsHooks":[]}</script><div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb12-1" title="1"><span class="kw"><a href="../reference/apex.html">apex</a></span>(<span class="dt">data =</span> economics_long, <span class="dt">type =</span> <span class="st">"line"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="../reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> date, <span class="dt">y =</span> value01, <span class="dt">group =</span> variable)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb12-2" title="2"><span class="st"> </span><span class="kw"><a href="../reference/ax_yaxis.html">ax_yaxis</a></span>(<span class="dt">decimalsInFloat =</span> <span class="dv">2</span>) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb12-3" title="3"><span class="st"> </span><span class="kw"><a href="../reference/ax_stroke.html">ax_stroke</a></span>(<span class="dt">dashArray =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="dv">8</span>, <span class="dv">5</span>))</a></code></pre></div>
|
||||
<div id="htmlwidget-ab8dbcaec7feaf5b1665" style="width:100%;height:350px;" class="apexcharter html-widget"></div>
|
||||
<script type="application/json" data-for="htmlwidget-ab8dbcaec7feaf5b1665">{"x":{"ax_opts":{"chart":{"type":"line"},"series":[{"name":"pce","data":[["2013-09-01",0.92924677636026],["2013-10-01",0.933773134481608],["2013-11-01",0.939574402546397],["2013-12-01",0.942167004646148],["2014-01-01",0.941704956747183],["2014-02-01",0.946299766409118],["2014-03-01",0.952871114305516],["2014-04-01",0.957970754079284],["2014-05-01",0.961889604777918],["2014-06-01",0.967759324383294],["2014-07-01",0.971481376902739],["2014-08-01",0.978651675779278],["2014-09-01",0.979772569756398],["2014-10-01",0.985385596084572],["2014-11-01",0.987815625775428],["2014-12-01",0.988722608688212],["2015-01-01",0.987353577876462],["2015-02-01",0.990468122973193],["2015-03-01",0.99696246288643],["2015-04-01",1]]},{"name":"pop","data":[["2013-09-01",0.970448177482025],["2013-10-01",0.972224366782906],["2013-11-01",0.97391518362249],["2013-12-01",0.975423315392571],["2014-01-01",0.976921972290395],["2014-02-01",0.97823645673634],["2014-03-01",0.97957855225842],["2014-04-01",0.980992099657577],["2014-05-01",0.982473622896551],["2014-06-01",0.984073150615668],["2014-07-01",0.985702006885595],["2014-08-01",0.987603703319152],["2014-09-01",0.989506155770269],["2014-10-01",0.991383363808922],["2014-11-01",0.993112959418826],["2014-12-01",0.994608132061805],["2015-01-01",0.996107750416745],["2015-02-01",0.997306408041825],["2015-03-01",0.998590610697427],["2015-04-01",1]]}],"dataLabels":{"enabled":false},"stroke":{"curve":"straight","dashArray":[8,5]},"xaxis":{"type":"datetime"},"yaxis":{"decimalsInFloat":2}},"auto_update":true},"evals":[],"jsHooks":[]}</script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
<div id="tocnav">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#tocnav" class="anchor"></a>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#type-of-line">Type of line</a></li>
|
||||
<li><a href="#line-appearance">Line appearance</a></li>
|
||||
<li><a href="#markers">Markers</a></li>
|
||||
<li><a href="#multiple-lines">Multiple lines</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<footer><div class="copyright">
|
||||
<p>Developed by <a href="https://twitter.com/_pvictorr"><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"> Victor Perrier</a>, <a href="https://twitter.com/_mfaan"><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg"> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,104 +0,0 @@
|
|||
HTMLWidgets.widget({
|
||||
|
||||
name: 'apexcharter',
|
||||
|
||||
type: 'output',
|
||||
|
||||
factory: function(el, width, height) {
|
||||
|
||||
var ax_opts;
|
||||
var apexchart = null;
|
||||
|
||||
return {
|
||||
|
||||
renderValue: function(x) {
|
||||
|
||||
|
||||
// Global options
|
||||
ax_opts = x.ax_opts;
|
||||
|
||||
// Sizing
|
||||
if (typeof ax_opts.chart === 'undefined') {
|
||||
ax_opts.chart = {};
|
||||
}
|
||||
ax_opts.chart.width = width;
|
||||
ax_opts.chart.height = height;
|
||||
|
||||
// Generate or update chart
|
||||
if (apexchart === null) {
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
} else {
|
||||
if (x.auto_update) {
|
||||
apexchart.updateSeries(ax_opts.series);
|
||||
} else {
|
||||
apexchart.destroy();
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
getChart: function(){
|
||||
return apexchart;
|
||||
},
|
||||
|
||||
resize: function(width, height) {
|
||||
apexchart.updateOptions({
|
||||
chart: {
|
||||
width: width,
|
||||
height: height
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// From Friss tuto (https://github.com/FrissAnalytics/shinyJsTutorials/blob/master/tutorials/tutorial_03.Rmd)
|
||||
function get_widget(id){
|
||||
|
||||
// Get the HTMLWidgets object
|
||||
var htmlWidgetsObj = HTMLWidgets.find("#" + id);
|
||||
|
||||
// Use the getChart method we created to get the underlying billboard chart
|
||||
var widgetObj ;
|
||||
|
||||
if (typeof htmlWidgetsObj != 'undefined') {
|
||||
widgetObj = htmlWidgetsObj.getChart();
|
||||
}
|
||||
|
||||
return(widgetObj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (HTMLWidgets.shinyMode) {
|
||||
// update serie
|
||||
Shiny.addCustomMessageHandler('update-apexchart-series',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateSeries([{
|
||||
data: obj.data.newSeries
|
||||
}], obj.data.animate);
|
||||
}
|
||||
});
|
||||
|
||||
// update options
|
||||
Shiny.addCustomMessageHandler('update-apexchart-options',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateOptions(obj.data.options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
HTMLWidgets.widget({
|
||||
|
||||
name: 'apexcharter',
|
||||
|
||||
type: 'output',
|
||||
|
||||
factory: function(el, width, height) {
|
||||
|
||||
var ax_opts;
|
||||
var apexchart = null;
|
||||
|
||||
return {
|
||||
|
||||
renderValue: function(x) {
|
||||
|
||||
|
||||
// Global options
|
||||
ax_opts = x.ax_opts;
|
||||
|
||||
// Sizing
|
||||
if (typeof ax_opts.chart === 'undefined') {
|
||||
ax_opts.chart = {};
|
||||
}
|
||||
ax_opts.chart.width = width;
|
||||
ax_opts.chart.height = height;
|
||||
if (!ax_opts.chart.hasOwnProperty('parentHeightOffset')) {
|
||||
ax_opts.chart.parentHeightOffset = 0;
|
||||
}
|
||||
|
||||
// Generate or update chart
|
||||
if (apexchart === null) {
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
} else {
|
||||
if (x.auto_update) {
|
||||
apexchart.updateSeries(ax_opts.series);
|
||||
} else {
|
||||
apexchart.destroy();
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
getChart: function(){
|
||||
return apexchart;
|
||||
},
|
||||
|
||||
resize: function(width, height) {
|
||||
apexchart.updateOptions({
|
||||
chart: {
|
||||
width: width,
|
||||
height: height
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// From Friss tuto (https://github.com/FrissAnalytics/shinyJsTutorials/blob/master/tutorials/tutorial_03.Rmd)
|
||||
function get_widget(id){
|
||||
|
||||
// Get the HTMLWidgets object
|
||||
var htmlWidgetsObj = HTMLWidgets.find("#" + id);
|
||||
|
||||
// Use the getChart method we created to get the underlying billboard chart
|
||||
var widgetObj ;
|
||||
|
||||
if (typeof htmlWidgetsObj != 'undefined') {
|
||||
widgetObj = htmlWidgetsObj.getChart();
|
||||
}
|
||||
|
||||
return(widgetObj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (HTMLWidgets.shinyMode) {
|
||||
// update serie
|
||||
Shiny.addCustomMessageHandler('update-apexchart-series',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateSeries([{
|
||||
data: obj.data.newSeries
|
||||
}], obj.data.animate);
|
||||
}
|
||||
});
|
||||
|
||||
// update options
|
||||
Shiny.addCustomMessageHandler('update-apexchart-options',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateOptions(obj.data.options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
HTMLWidgets.widget({
|
||||
|
||||
name: 'apexcharter',
|
||||
|
||||
type: 'output',
|
||||
|
||||
factory: function(el, width, height) {
|
||||
|
||||
var ax_opts;
|
||||
var apexchart = null;
|
||||
|
||||
return {
|
||||
|
||||
renderValue: function(x) {
|
||||
|
||||
|
||||
// Global options
|
||||
ax_opts = x.ax_opts;
|
||||
|
||||
// Sizing
|
||||
if (typeof ax_opts.chart === 'undefined') {
|
||||
ax_opts.chart = {};
|
||||
}
|
||||
ax_opts.chart.width = width;
|
||||
ax_opts.chart.height = height;
|
||||
|
||||
// Generate or update chart
|
||||
if (apexchart === null) {
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
} else {
|
||||
if (x.auto_update) {
|
||||
apexchart.updateSeries(ax_opts.series);
|
||||
} else {
|
||||
apexchart.destroy();
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
getChart: function(){
|
||||
return apexchart;
|
||||
},
|
||||
|
||||
resize: function(width, height) {
|
||||
apexchart.updateOptions({
|
||||
chart: {
|
||||
width: width,
|
||||
height: height
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// From Friss tuto (https://github.com/FrissAnalytics/shinyJsTutorials/blob/master/tutorials/tutorial_03.Rmd)
|
||||
function get_widget(id){
|
||||
|
||||
// Get the HTMLWidgets object
|
||||
var htmlWidgetsObj = HTMLWidgets.find("#" + id);
|
||||
|
||||
// Use the getChart method we created to get the underlying billboard chart
|
||||
var widgetObj ;
|
||||
|
||||
if (typeof htmlWidgetsObj != 'undefined') {
|
||||
widgetObj = htmlWidgetsObj.getChart();
|
||||
}
|
||||
|
||||
return(widgetObj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (HTMLWidgets.shinyMode) {
|
||||
// update serie
|
||||
Shiny.addCustomMessageHandler('update-apexchart-series',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateSeries([{
|
||||
data: obj.data.newSeries
|
||||
}], obj.data.animate);
|
||||
}
|
||||
});
|
||||
|
||||
// update options
|
||||
Shiny.addCustomMessageHandler('update-apexchart-options',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateOptions(obj.data.options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,839 +0,0 @@
|
|||
(function() {
|
||||
// If window.HTMLWidgets is already defined, then use it; otherwise create a
|
||||
// new object. This allows preceding code to set options that affect the
|
||||
// initialization process (though none currently exist).
|
||||
window.HTMLWidgets = window.HTMLWidgets || {};
|
||||
|
||||
// See if we're running in a viewer pane. If not, we're in a web browser.
|
||||
var viewerMode = window.HTMLWidgets.viewerMode =
|
||||
/\bviewer_pane=1\b/.test(window.location);
|
||||
|
||||
// See if we're running in Shiny mode. If not, it's a static document.
|
||||
// Note that static widgets can appear in both Shiny and static modes, but
|
||||
// obviously, Shiny widgets can only appear in Shiny apps/documents.
|
||||
var shinyMode = window.HTMLWidgets.shinyMode =
|
||||
typeof(window.Shiny) !== "undefined" && !!window.Shiny.outputBindings;
|
||||
|
||||
// We can't count on jQuery being available, so we implement our own
|
||||
// version if necessary.
|
||||
function querySelectorAll(scope, selector) {
|
||||
if (typeof(jQuery) !== "undefined" && scope instanceof jQuery) {
|
||||
return scope.find(selector);
|
||||
}
|
||||
if (scope.querySelectorAll) {
|
||||
return scope.querySelectorAll(selector);
|
||||
}
|
||||
}
|
||||
|
||||
function asArray(value) {
|
||||
if (value === null)
|
||||
return [];
|
||||
if ($.isArray(value))
|
||||
return value;
|
||||
return [value];
|
||||
}
|
||||
|
||||
// Implement jQuery's extend
|
||||
function extend(target /*, ... */) {
|
||||
if (arguments.length == 1) {
|
||||
return target;
|
||||
}
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
for (var prop in source) {
|
||||
if (source.hasOwnProperty(prop)) {
|
||||
target[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
// IE8 doesn't support Array.forEach.
|
||||
function forEach(values, callback, thisArg) {
|
||||
if (values.forEach) {
|
||||
values.forEach(callback, thisArg);
|
||||
} else {
|
||||
for (var i = 0; i < values.length; i++) {
|
||||
callback.call(thisArg, values[i], i, values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Replaces the specified method with the return value of funcSource.
|
||||
//
|
||||
// Note that funcSource should not BE the new method, it should be a function
|
||||
// that RETURNS the new method. funcSource receives a single argument that is
|
||||
// the overridden method, it can be called from the new method. The overridden
|
||||
// method can be called like a regular function, it has the target permanently
|
||||
// bound to it so "this" will work correctly.
|
||||
function overrideMethod(target, methodName, funcSource) {
|
||||
var superFunc = target[methodName] || function() {};
|
||||
var superFuncBound = function() {
|
||||
return superFunc.apply(target, arguments);
|
||||
};
|
||||
target[methodName] = funcSource(superFuncBound);
|
||||
}
|
||||
|
||||
// Add a method to delegator that, when invoked, calls
|
||||
// delegatee.methodName. If there is no such method on
|
||||
// the delegatee, but there was one on delegator before
|
||||
// delegateMethod was called, then the original version
|
||||
// is invoked instead.
|
||||
// For example:
|
||||
//
|
||||
// var a = {
|
||||
// method1: function() { console.log('a1'); }
|
||||
// method2: function() { console.log('a2'); }
|
||||
// };
|
||||
// var b = {
|
||||
// method1: function() { console.log('b1'); }
|
||||
// };
|
||||
// delegateMethod(a, b, "method1");
|
||||
// delegateMethod(a, b, "method2");
|
||||
// a.method1();
|
||||
// a.method2();
|
||||
//
|
||||
// The output would be "b1", "a2".
|
||||
function delegateMethod(delegator, delegatee, methodName) {
|
||||
var inherited = delegator[methodName];
|
||||
delegator[methodName] = function() {
|
||||
var target = delegatee;
|
||||
var method = delegatee[methodName];
|
||||
|
||||
// The method doesn't exist on the delegatee. Instead,
|
||||
// call the method on the delegator, if it exists.
|
||||
if (!method) {
|
||||
target = delegator;
|
||||
method = inherited;
|
||||
}
|
||||
|
||||
if (method) {
|
||||
return method.apply(target, arguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Implement a vague facsimilie of jQuery's data method
|
||||
function elementData(el, name, value) {
|
||||
if (arguments.length == 2) {
|
||||
return el["htmlwidget_data_" + name];
|
||||
} else if (arguments.length == 3) {
|
||||
el["htmlwidget_data_" + name] = value;
|
||||
return el;
|
||||
} else {
|
||||
throw new Error("Wrong number of arguments for elementData: " +
|
||||
arguments.length);
|
||||
}
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
|
||||
function escapeRegExp(str) {
|
||||
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||
}
|
||||
|
||||
function hasClass(el, className) {
|
||||
var re = new RegExp("\\b" + escapeRegExp(className) + "\\b");
|
||||
return re.test(el.className);
|
||||
}
|
||||
|
||||
// elements - array (or array-like object) of HTML elements
|
||||
// className - class name to test for
|
||||
// include - if true, only return elements with given className;
|
||||
// if false, only return elements *without* given className
|
||||
function filterByClass(elements, className, include) {
|
||||
var results = [];
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
if (hasClass(elements[i], className) == include)
|
||||
results.push(elements[i]);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
function on(obj, eventName, func) {
|
||||
if (obj.addEventListener) {
|
||||
obj.addEventListener(eventName, func, false);
|
||||
} else if (obj.attachEvent) {
|
||||
obj.attachEvent(eventName, func);
|
||||
}
|
||||
}
|
||||
|
||||
function off(obj, eventName, func) {
|
||||
if (obj.removeEventListener)
|
||||
obj.removeEventListener(eventName, func, false);
|
||||
else if (obj.detachEvent) {
|
||||
obj.detachEvent(eventName, func);
|
||||
}
|
||||
}
|
||||
|
||||
// Translate array of values to top/right/bottom/left, as usual with
|
||||
// the "padding" CSS property
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/padding
|
||||
function unpackPadding(value) {
|
||||
if (typeof(value) === "number")
|
||||
value = [value];
|
||||
if (value.length === 1) {
|
||||
return {top: value[0], right: value[0], bottom: value[0], left: value[0]};
|
||||
}
|
||||
if (value.length === 2) {
|
||||
return {top: value[0], right: value[1], bottom: value[0], left: value[1]};
|
||||
}
|
||||
if (value.length === 3) {
|
||||
return {top: value[0], right: value[1], bottom: value[2], left: value[1]};
|
||||
}
|
||||
if (value.length === 4) {
|
||||
return {top: value[0], right: value[1], bottom: value[2], left: value[3]};
|
||||
}
|
||||
}
|
||||
|
||||
// Convert an unpacked padding object to a CSS value
|
||||
function paddingToCss(paddingObj) {
|
||||
return paddingObj.top + "px " + paddingObj.right + "px " + paddingObj.bottom + "px " + paddingObj.left + "px";
|
||||
}
|
||||
|
||||
// Makes a number suitable for CSS
|
||||
function px(x) {
|
||||
if (typeof(x) === "number")
|
||||
return x + "px";
|
||||
else
|
||||
return x;
|
||||
}
|
||||
|
||||
// Retrieves runtime widget sizing information for an element.
|
||||
// The return value is either null, or an object with fill, padding,
|
||||
// defaultWidth, defaultHeight fields.
|
||||
function sizingPolicy(el) {
|
||||
var sizingEl = document.querySelector("script[data-for='" + el.id + "'][type='application/htmlwidget-sizing']");
|
||||
if (!sizingEl)
|
||||
return null;
|
||||
var sp = JSON.parse(sizingEl.textContent || sizingEl.text || "{}");
|
||||
if (viewerMode) {
|
||||
return sp.viewer;
|
||||
} else {
|
||||
return sp.browser;
|
||||
}
|
||||
}
|
||||
|
||||
// @param tasks Array of strings (or falsy value, in which case no-op).
|
||||
// Each element must be a valid JavaScript expression that yields a
|
||||
// function. Or, can be an array of objects with "code" and "data"
|
||||
// properties; in this case, the "code" property should be a string
|
||||
// of JS that's an expr that yields a function, and "data" should be
|
||||
// an object that will be added as an additional argument when that
|
||||
// function is called.
|
||||
// @param target The object that will be "this" for each function
|
||||
// execution.
|
||||
// @param args Array of arguments to be passed to the functions. (The
|
||||
// same arguments will be passed to all functions.)
|
||||
function evalAndRun(tasks, target, args) {
|
||||
if (tasks) {
|
||||
forEach(tasks, function(task) {
|
||||
var theseArgs = args;
|
||||
if (typeof(task) === "object") {
|
||||
theseArgs = theseArgs.concat([task.data]);
|
||||
task = task.code;
|
||||
}
|
||||
var taskFunc = eval("(" + task + ")");
|
||||
if (typeof(taskFunc) !== "function") {
|
||||
throw new Error("Task must be a function! Source:\n" + task);
|
||||
}
|
||||
taskFunc.apply(target, theseArgs);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function initSizing(el) {
|
||||
var sizing = sizingPolicy(el);
|
||||
if (!sizing)
|
||||
return;
|
||||
|
||||
var cel = document.getElementById("htmlwidget_container");
|
||||
if (!cel)
|
||||
return;
|
||||
|
||||
if (typeof(sizing.padding) !== "undefined") {
|
||||
document.body.style.margin = "0";
|
||||
document.body.style.padding = paddingToCss(unpackPadding(sizing.padding));
|
||||
}
|
||||
|
||||
if (sizing.fill) {
|
||||
document.body.style.overflow = "hidden";
|
||||
document.body.style.width = "100%";
|
||||
document.body.style.height = "100%";
|
||||
document.documentElement.style.width = "100%";
|
||||
document.documentElement.style.height = "100%";
|
||||
if (cel) {
|
||||
cel.style.position = "absolute";
|
||||
var pad = unpackPadding(sizing.padding);
|
||||
cel.style.top = pad.top + "px";
|
||||
cel.style.right = pad.right + "px";
|
||||
cel.style.bottom = pad.bottom + "px";
|
||||
cel.style.left = pad.left + "px";
|
||||
el.style.width = "100%";
|
||||
el.style.height = "100%";
|
||||
}
|
||||
|
||||
return {
|
||||
getWidth: function() { return cel.offsetWidth; },
|
||||
getHeight: function() { return cel.offsetHeight; }
|
||||
};
|
||||
|
||||
} else {
|
||||
el.style.width = px(sizing.width);
|
||||
el.style.height = px(sizing.height);
|
||||
|
||||
return {
|
||||
getWidth: function() { return el.offsetWidth; },
|
||||
getHeight: function() { return el.offsetHeight; }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Default implementations for methods
|
||||
var defaults = {
|
||||
find: function(scope) {
|
||||
return querySelectorAll(scope, "." + this.name);
|
||||
},
|
||||
renderError: function(el, err) {
|
||||
var $el = $(el);
|
||||
|
||||
this.clearError(el);
|
||||
|
||||
// Add all these error classes, as Shiny does
|
||||
var errClass = "shiny-output-error";
|
||||
if (err.type !== null) {
|
||||
// use the classes of the error condition as CSS class names
|
||||
errClass = errClass + " " + $.map(asArray(err.type), function(type) {
|
||||
return errClass + "-" + type;
|
||||
}).join(" ");
|
||||
}
|
||||
errClass = errClass + " htmlwidgets-error";
|
||||
|
||||
// Is el inline or block? If inline or inline-block, just display:none it
|
||||
// and add an inline error.
|
||||
var display = $el.css("display");
|
||||
$el.data("restore-display-mode", display);
|
||||
|
||||
if (display === "inline" || display === "inline-block") {
|
||||
$el.hide();
|
||||
if (err.message !== "") {
|
||||
var errorSpan = $("<span>").addClass(errClass);
|
||||
errorSpan.text(err.message);
|
||||
$el.after(errorSpan);
|
||||
}
|
||||
} else if (display === "block") {
|
||||
// If block, add an error just after the el, set visibility:none on the
|
||||
// el, and position the error to be on top of the el.
|
||||
// Mark it with a unique ID and CSS class so we can remove it later.
|
||||
$el.css("visibility", "hidden");
|
||||
if (err.message !== "") {
|
||||
var errorDiv = $("<div>").addClass(errClass).css("position", "absolute")
|
||||
.css("top", el.offsetTop)
|
||||
.css("left", el.offsetLeft)
|
||||
// setting width can push out the page size, forcing otherwise
|
||||
// unnecessary scrollbars to appear and making it impossible for
|
||||
// the element to shrink; so use max-width instead
|
||||
.css("maxWidth", el.offsetWidth)
|
||||
.css("height", el.offsetHeight);
|
||||
errorDiv.text(err.message);
|
||||
$el.after(errorDiv);
|
||||
|
||||
// Really dumb way to keep the size/position of the error in sync with
|
||||
// the parent element as the window is resized or whatever.
|
||||
var intId = setInterval(function() {
|
||||
if (!errorDiv[0].parentElement) {
|
||||
clearInterval(intId);
|
||||
return;
|
||||
}
|
||||
errorDiv
|
||||
.css("top", el.offsetTop)
|
||||
.css("left", el.offsetLeft)
|
||||
.css("maxWidth", el.offsetWidth)
|
||||
.css("height", el.offsetHeight);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
},
|
||||
clearError: function(el) {
|
||||
var $el = $(el);
|
||||
var display = $el.data("restore-display-mode");
|
||||
$el.data("restore-display-mode", null);
|
||||
|
||||
if (display === "inline" || display === "inline-block") {
|
||||
if (display)
|
||||
$el.css("display", display);
|
||||
$(el.nextSibling).filter(".htmlwidgets-error").remove();
|
||||
} else if (display === "block"){
|
||||
$el.css("visibility", "inherit");
|
||||
$(el.nextSibling).filter(".htmlwidgets-error").remove();
|
||||
}
|
||||
},
|
||||
sizing: {}
|
||||
};
|
||||
|
||||
// Called by widget bindings to register a new type of widget. The definition
|
||||
// object can contain the following properties:
|
||||
// - name (required) - A string indicating the binding name, which will be
|
||||
// used by default as the CSS classname to look for.
|
||||
// - initialize (optional) - A function(el) that will be called once per
|
||||
// widget element; if a value is returned, it will be passed as the third
|
||||
// value to renderValue.
|
||||
// - renderValue (required) - A function(el, data, initValue) that will be
|
||||
// called with data. Static contexts will cause this to be called once per
|
||||
// element; Shiny apps will cause this to be called multiple times per
|
||||
// element, as the data changes.
|
||||
window.HTMLWidgets.widget = function(definition) {
|
||||
if (!definition.name) {
|
||||
throw new Error("Widget must have a name");
|
||||
}
|
||||
if (!definition.type) {
|
||||
throw new Error("Widget must have a type");
|
||||
}
|
||||
// Currently we only support output widgets
|
||||
if (definition.type !== "output") {
|
||||
throw new Error("Unrecognized widget type '" + definition.type + "'");
|
||||
}
|
||||
// TODO: Verify that .name is a valid CSS classname
|
||||
|
||||
// Support new-style instance-bound definitions. Old-style class-bound
|
||||
// definitions have one widget "object" per widget per type/class of
|
||||
// widget; the renderValue and resize methods on such widget objects
|
||||
// take el and instance arguments, because the widget object can't
|
||||
// store them. New-style instance-bound definitions have one widget
|
||||
// object per widget instance; the definition that's passed in doesn't
|
||||
// provide renderValue or resize methods at all, just the single method
|
||||
// factory(el, width, height)
|
||||
// which returns an object that has renderValue(x) and resize(w, h).
|
||||
// This enables a far more natural programming style for the widget
|
||||
// author, who can store per-instance state using either OO-style
|
||||
// instance fields or functional-style closure variables (I guess this
|
||||
// is in contrast to what can only be called C-style pseudo-OO which is
|
||||
// what we required before).
|
||||
if (definition.factory) {
|
||||
definition = createLegacyDefinitionAdapter(definition);
|
||||
}
|
||||
|
||||
if (!definition.renderValue) {
|
||||
throw new Error("Widget must have a renderValue function");
|
||||
}
|
||||
|
||||
// For static rendering (non-Shiny), use a simple widget registration
|
||||
// scheme. We also use this scheme for Shiny apps/documents that also
|
||||
// contain static widgets.
|
||||
window.HTMLWidgets.widgets = window.HTMLWidgets.widgets || [];
|
||||
// Merge defaults into the definition; don't mutate the original definition.
|
||||
var staticBinding = extend({}, defaults, definition);
|
||||
overrideMethod(staticBinding, "find", function(superfunc) {
|
||||
return function(scope) {
|
||||
var results = superfunc(scope);
|
||||
// Filter out Shiny outputs, we only want the static kind
|
||||
return filterByClass(results, "html-widget-output", false);
|
||||
};
|
||||
});
|
||||
window.HTMLWidgets.widgets.push(staticBinding);
|
||||
|
||||
if (shinyMode) {
|
||||
// Shiny is running. Register the definition with an output binding.
|
||||
// The definition itself will not be the output binding, instead
|
||||
// we will make an output binding object that delegates to the
|
||||
// definition. This is because we foolishly used the same method
|
||||
// name (renderValue) for htmlwidgets definition and Shiny bindings
|
||||
// but they actually have quite different semantics (the Shiny
|
||||
// bindings receive data that includes lots of metadata that it
|
||||
// strips off before calling htmlwidgets renderValue). We can't
|
||||
// just ignore the difference because in some widgets it's helpful
|
||||
// to call this.renderValue() from inside of resize(), and if
|
||||
// we're not delegating, then that call will go to the Shiny
|
||||
// version instead of the htmlwidgets version.
|
||||
|
||||
// Merge defaults with definition, without mutating either.
|
||||
var bindingDef = extend({}, defaults, definition);
|
||||
|
||||
// This object will be our actual Shiny binding.
|
||||
var shinyBinding = new Shiny.OutputBinding();
|
||||
|
||||
// With a few exceptions, we'll want to simply use the bindingDef's
|
||||
// version of methods if they are available, otherwise fall back to
|
||||
// Shiny's defaults. NOTE: If Shiny's output bindings gain additional
|
||||
// methods in the future, and we want them to be overrideable by
|
||||
// HTMLWidget binding definitions, then we'll need to add them to this
|
||||
// list.
|
||||
delegateMethod(shinyBinding, bindingDef, "getId");
|
||||
delegateMethod(shinyBinding, bindingDef, "onValueChange");
|
||||
delegateMethod(shinyBinding, bindingDef, "onValueError");
|
||||
delegateMethod(shinyBinding, bindingDef, "renderError");
|
||||
delegateMethod(shinyBinding, bindingDef, "clearError");
|
||||
delegateMethod(shinyBinding, bindingDef, "showProgress");
|
||||
|
||||
// The find, renderValue, and resize are handled differently, because we
|
||||
// want to actually decorate the behavior of the bindingDef methods.
|
||||
|
||||
shinyBinding.find = function(scope) {
|
||||
var results = bindingDef.find(scope);
|
||||
|
||||
// Only return elements that are Shiny outputs, not static ones
|
||||
var dynamicResults = results.filter(".html-widget-output");
|
||||
|
||||
// It's possible that whatever caused Shiny to think there might be
|
||||
// new dynamic outputs, also caused there to be new static outputs.
|
||||
// Since there might be lots of different htmlwidgets bindings, we
|
||||
// schedule execution for later--no need to staticRender multiple
|
||||
// times.
|
||||
if (results.length !== dynamicResults.length)
|
||||
scheduleStaticRender();
|
||||
|
||||
return dynamicResults;
|
||||
};
|
||||
|
||||
// Wrap renderValue to handle initialization, which unfortunately isn't
|
||||
// supported natively by Shiny at the time of this writing.
|
||||
|
||||
shinyBinding.renderValue = function(el, data) {
|
||||
Shiny.renderDependencies(data.deps);
|
||||
// Resolve strings marked as javascript literals to objects
|
||||
if (!(data.evals instanceof Array)) data.evals = [data.evals];
|
||||
for (var i = 0; data.evals && i < data.evals.length; i++) {
|
||||
window.HTMLWidgets.evaluateStringMember(data.x, data.evals[i]);
|
||||
}
|
||||
if (!bindingDef.renderOnNullValue) {
|
||||
if (data.x === null) {
|
||||
el.style.visibility = "hidden";
|
||||
return;
|
||||
} else {
|
||||
el.style.visibility = "inherit";
|
||||
}
|
||||
}
|
||||
if (!elementData(el, "initialized")) {
|
||||
initSizing(el);
|
||||
|
||||
elementData(el, "initialized", true);
|
||||
if (bindingDef.initialize) {
|
||||
var result = bindingDef.initialize(el, el.offsetWidth,
|
||||
el.offsetHeight);
|
||||
elementData(el, "init_result", result);
|
||||
}
|
||||
}
|
||||
bindingDef.renderValue(el, data.x, elementData(el, "init_result"));
|
||||
evalAndRun(data.jsHooks.render, elementData(el, "init_result"), [el, data.x]);
|
||||
};
|
||||
|
||||
// Only override resize if bindingDef implements it
|
||||
if (bindingDef.resize) {
|
||||
shinyBinding.resize = function(el, width, height) {
|
||||
// Shiny can call resize before initialize/renderValue have been
|
||||
// called, which doesn't make sense for widgets.
|
||||
if (elementData(el, "initialized")) {
|
||||
bindingDef.resize(el, width, height, elementData(el, "init_result"));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Shiny.outputBindings.register(shinyBinding, bindingDef.name);
|
||||
}
|
||||
};
|
||||
|
||||
var scheduleStaticRenderTimerId = null;
|
||||
function scheduleStaticRender() {
|
||||
if (!scheduleStaticRenderTimerId) {
|
||||
scheduleStaticRenderTimerId = setTimeout(function() {
|
||||
scheduleStaticRenderTimerId = null;
|
||||
window.HTMLWidgets.staticRender();
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Render static widgets after the document finishes loading
|
||||
// Statically render all elements that are of this widget's class
|
||||
window.HTMLWidgets.staticRender = function() {
|
||||
var bindings = window.HTMLWidgets.widgets || [];
|
||||
forEach(bindings, function(binding) {
|
||||
var matches = binding.find(document.documentElement);
|
||||
forEach(matches, function(el) {
|
||||
var sizeObj = initSizing(el, binding);
|
||||
|
||||
if (hasClass(el, "html-widget-static-bound"))
|
||||
return;
|
||||
el.className = el.className + " html-widget-static-bound";
|
||||
|
||||
var initResult;
|
||||
if (binding.initialize) {
|
||||
initResult = binding.initialize(el,
|
||||
sizeObj ? sizeObj.getWidth() : el.offsetWidth,
|
||||
sizeObj ? sizeObj.getHeight() : el.offsetHeight
|
||||
);
|
||||
elementData(el, "init_result", initResult);
|
||||
}
|
||||
|
||||
if (binding.resize) {
|
||||
var lastSize = {
|
||||
w: sizeObj ? sizeObj.getWidth() : el.offsetWidth,
|
||||
h: sizeObj ? sizeObj.getHeight() : el.offsetHeight
|
||||
};
|
||||
var resizeHandler = function(e) {
|
||||
var size = {
|
||||
w: sizeObj ? sizeObj.getWidth() : el.offsetWidth,
|
||||
h: sizeObj ? sizeObj.getHeight() : el.offsetHeight
|
||||
};
|
||||
if (size.w === 0 && size.h === 0)
|
||||
return;
|
||||
if (size.w === lastSize.w && size.h === lastSize.h)
|
||||
return;
|
||||
lastSize = size;
|
||||
binding.resize(el, size.w, size.h, initResult);
|
||||
};
|
||||
|
||||
on(window, "resize", resizeHandler);
|
||||
|
||||
// This is needed for cases where we're running in a Shiny
|
||||
// app, but the widget itself is not a Shiny output, but
|
||||
// rather a simple static widget. One example of this is
|
||||
// an rmarkdown document that has runtime:shiny and widget
|
||||
// that isn't in a render function. Shiny only knows to
|
||||
// call resize handlers for Shiny outputs, not for static
|
||||
// widgets, so we do it ourselves.
|
||||
if (window.jQuery) {
|
||||
window.jQuery(document).on(
|
||||
"shown.htmlwidgets shown.bs.tab.htmlwidgets shown.bs.collapse.htmlwidgets",
|
||||
resizeHandler
|
||||
);
|
||||
window.jQuery(document).on(
|
||||
"hidden.htmlwidgets hidden.bs.tab.htmlwidgets hidden.bs.collapse.htmlwidgets",
|
||||
resizeHandler
|
||||
);
|
||||
}
|
||||
|
||||
// This is needed for the specific case of ioslides, which
|
||||
// flips slides between display:none and display:block.
|
||||
// Ideally we would not have to have ioslide-specific code
|
||||
// here, but rather have ioslides raise a generic event,
|
||||
// but the rmarkdown package just went to CRAN so the
|
||||
// window to getting that fixed may be long.
|
||||
if (window.addEventListener) {
|
||||
// It's OK to limit this to window.addEventListener
|
||||
// browsers because ioslides itself only supports
|
||||
// such browsers.
|
||||
on(document, "slideenter", resizeHandler);
|
||||
on(document, "slideleave", resizeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
var scriptData = document.querySelector("script[data-for='" + el.id + "'][type='application/json']");
|
||||
if (scriptData) {
|
||||
var data = JSON.parse(scriptData.textContent || scriptData.text);
|
||||
// Resolve strings marked as javascript literals to objects
|
||||
if (!(data.evals instanceof Array)) data.evals = [data.evals];
|
||||
for (var k = 0; data.evals && k < data.evals.length; k++) {
|
||||
window.HTMLWidgets.evaluateStringMember(data.x, data.evals[k]);
|
||||
}
|
||||
binding.renderValue(el, data.x, initResult);
|
||||
evalAndRun(data.jsHooks.render, initResult, [el, data.x]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
invokePostRenderHandlers();
|
||||
}
|
||||
|
||||
// Wait until after the document has loaded to render the widgets.
|
||||
if (document.addEventListener) {
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
document.removeEventListener("DOMContentLoaded", arguments.callee, false);
|
||||
window.HTMLWidgets.staticRender();
|
||||
}, false);
|
||||
} else if (document.attachEvent) {
|
||||
document.attachEvent("onreadystatechange", function() {
|
||||
if (document.readyState === "complete") {
|
||||
document.detachEvent("onreadystatechange", arguments.callee);
|
||||
window.HTMLWidgets.staticRender();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
window.HTMLWidgets.getAttachmentUrl = function(depname, key) {
|
||||
// If no key, default to the first item
|
||||
if (typeof(key) === "undefined")
|
||||
key = 1;
|
||||
|
||||
var link = document.getElementById(depname + "-" + key + "-attachment");
|
||||
if (!link) {
|
||||
throw new Error("Attachment " + depname + "/" + key + " not found in document");
|
||||
}
|
||||
return link.getAttribute("href");
|
||||
};
|
||||
|
||||
window.HTMLWidgets.dataframeToD3 = function(df) {
|
||||
var names = [];
|
||||
var length;
|
||||
for (var name in df) {
|
||||
if (df.hasOwnProperty(name))
|
||||
names.push(name);
|
||||
if (typeof(df[name]) !== "object" || typeof(df[name].length) === "undefined") {
|
||||
throw new Error("All fields must be arrays");
|
||||
} else if (typeof(length) !== "undefined" && length !== df[name].length) {
|
||||
throw new Error("All fields must be arrays of the same length");
|
||||
}
|
||||
length = df[name].length;
|
||||
}
|
||||
var results = [];
|
||||
var item;
|
||||
for (var row = 0; row < length; row++) {
|
||||
item = {};
|
||||
for (var col = 0; col < names.length; col++) {
|
||||
item[names[col]] = df[names[col]][row];
|
||||
}
|
||||
results.push(item);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
window.HTMLWidgets.transposeArray2D = function(array) {
|
||||
if (array.length === 0) return array;
|
||||
var newArray = array[0].map(function(col, i) {
|
||||
return array.map(function(row) {
|
||||
return row[i]
|
||||
})
|
||||
});
|
||||
return newArray;
|
||||
};
|
||||
// Split value at splitChar, but allow splitChar to be escaped
|
||||
// using escapeChar. Any other characters escaped by escapeChar
|
||||
// will be included as usual (including escapeChar itself).
|
||||
function splitWithEscape(value, splitChar, escapeChar) {
|
||||
var results = [];
|
||||
var escapeMode = false;
|
||||
var currentResult = "";
|
||||
for (var pos = 0; pos < value.length; pos++) {
|
||||
if (!escapeMode) {
|
||||
if (value[pos] === splitChar) {
|
||||
results.push(currentResult);
|
||||
currentResult = "";
|
||||
} else if (value[pos] === escapeChar) {
|
||||
escapeMode = true;
|
||||
} else {
|
||||
currentResult += value[pos];
|
||||
}
|
||||
} else {
|
||||
currentResult += value[pos];
|
||||
escapeMode = false;
|
||||
}
|
||||
}
|
||||
if (currentResult !== "") {
|
||||
results.push(currentResult);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
// Function authored by Yihui/JJ Allaire
|
||||
window.HTMLWidgets.evaluateStringMember = function(o, member) {
|
||||
var parts = splitWithEscape(member, '.', '\\');
|
||||
for (var i = 0, l = parts.length; i < l; i++) {
|
||||
var part = parts[i];
|
||||
// part may be a character or 'numeric' member name
|
||||
if (o !== null && typeof o === "object" && part in o) {
|
||||
if (i == (l - 1)) { // if we are at the end of the line then evalulate
|
||||
if (typeof o[part] === "string")
|
||||
o[part] = eval("(" + o[part] + ")");
|
||||
} else { // otherwise continue to next embedded object
|
||||
o = o[part];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Retrieve the HTMLWidget instance (i.e. the return value of an
|
||||
// HTMLWidget binding's initialize() or factory() function)
|
||||
// associated with an element, or null if none.
|
||||
window.HTMLWidgets.getInstance = function(el) {
|
||||
return elementData(el, "init_result");
|
||||
};
|
||||
|
||||
// Finds the first element in the scope that matches the selector,
|
||||
// and returns the HTMLWidget instance (i.e. the return value of
|
||||
// an HTMLWidget binding's initialize() or factory() function)
|
||||
// associated with that element, if any. If no element matches the
|
||||
// selector, or the first matching element has no HTMLWidget
|
||||
// instance associated with it, then null is returned.
|
||||
//
|
||||
// The scope argument is optional, and defaults to window.document.
|
||||
window.HTMLWidgets.find = function(scope, selector) {
|
||||
if (arguments.length == 1) {
|
||||
selector = scope;
|
||||
scope = document;
|
||||
}
|
||||
|
||||
var el = scope.querySelector(selector);
|
||||
if (el === null) {
|
||||
return null;
|
||||
} else {
|
||||
return window.HTMLWidgets.getInstance(el);
|
||||
}
|
||||
};
|
||||
|
||||
// Finds all elements in the scope that match the selector, and
|
||||
// returns the HTMLWidget instances (i.e. the return values of
|
||||
// an HTMLWidget binding's initialize() or factory() function)
|
||||
// associated with the elements, in an array. If elements that
|
||||
// match the selector don't have an associated HTMLWidget
|
||||
// instance, the returned array will contain nulls.
|
||||
//
|
||||
// The scope argument is optional, and defaults to window.document.
|
||||
window.HTMLWidgets.findAll = function(scope, selector) {
|
||||
if (arguments.length == 1) {
|
||||
selector = scope;
|
||||
scope = document;
|
||||
}
|
||||
|
||||
var nodes = scope.querySelectorAll(selector);
|
||||
var results = [];
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
results.push(window.HTMLWidgets.getInstance(nodes[i]));
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
var postRenderHandlers = [];
|
||||
function invokePostRenderHandlers() {
|
||||
while (postRenderHandlers.length) {
|
||||
var handler = postRenderHandlers.shift();
|
||||
if (handler) {
|
||||
handler();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register the given callback function to be invoked after the
|
||||
// next time static widgets are rendered.
|
||||
window.HTMLWidgets.addPostRenderHandler = function(callback) {
|
||||
postRenderHandlers.push(callback);
|
||||
};
|
||||
|
||||
// Takes a new-style instance-bound definition, and returns an
|
||||
// old-style class-bound definition. This saves us from having
|
||||
// to rewrite all the logic in this file to accomodate both
|
||||
// types of definitions.
|
||||
function createLegacyDefinitionAdapter(defn) {
|
||||
var result = {
|
||||
name: defn.name,
|
||||
type: defn.type,
|
||||
initialize: function(el, width, height) {
|
||||
return defn.factory(el, width, height);
|
||||
},
|
||||
renderValue: function(el, x, instance) {
|
||||
return instance.renderValue(x);
|
||||
},
|
||||
resize: function(el, width, height, instance) {
|
||||
return instance.resize(width, height);
|
||||
}
|
||||
};
|
||||
|
||||
if (defn.find)
|
||||
result.find = defn.find;
|
||||
if (defn.renderError)
|
||||
result.renderError = defn.renderError;
|
||||
if (defn.clearError)
|
||||
result.clearError = defn.clearError;
|
||||
|
||||
return result;
|
||||
}
|
||||
})();
|
||||
|
File diff suppressed because one or more lines are too long
|
@ -1,104 +0,0 @@
|
|||
HTMLWidgets.widget({
|
||||
|
||||
name: 'apexcharter',
|
||||
|
||||
type: 'output',
|
||||
|
||||
factory: function(el, width, height) {
|
||||
|
||||
var ax_opts;
|
||||
var apexchart = null;
|
||||
|
||||
return {
|
||||
|
||||
renderValue: function(x) {
|
||||
|
||||
|
||||
// Global options
|
||||
ax_opts = x.ax_opts;
|
||||
|
||||
// Sizing
|
||||
if (typeof ax_opts.chart === 'undefined') {
|
||||
ax_opts.chart = {};
|
||||
}
|
||||
ax_opts.chart.width = width;
|
||||
ax_opts.chart.height = height;
|
||||
|
||||
// Generate or update chart
|
||||
if (apexchart === null) {
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
} else {
|
||||
if (x.auto_update) {
|
||||
apexchart.updateSeries(ax_opts.series);
|
||||
} else {
|
||||
apexchart.destroy();
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
getChart: function(){
|
||||
return apexchart;
|
||||
},
|
||||
|
||||
resize: function(width, height) {
|
||||
apexchart.updateOptions({
|
||||
chart: {
|
||||
width: width,
|
||||
height: height
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// From Friss tuto (https://github.com/FrissAnalytics/shinyJsTutorials/blob/master/tutorials/tutorial_03.Rmd)
|
||||
function get_widget(id){
|
||||
|
||||
// Get the HTMLWidgets object
|
||||
var htmlWidgetsObj = HTMLWidgets.find("#" + id);
|
||||
|
||||
// Use the getChart method we created to get the underlying billboard chart
|
||||
var widgetObj ;
|
||||
|
||||
if (typeof htmlWidgetsObj != 'undefined') {
|
||||
widgetObj = htmlWidgetsObj.getChart();
|
||||
}
|
||||
|
||||
return(widgetObj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (HTMLWidgets.shinyMode) {
|
||||
// update serie
|
||||
Shiny.addCustomMessageHandler('update-apexchart-series',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateSeries([{
|
||||
data: obj.data.newSeries
|
||||
}], obj.data.animate);
|
||||
}
|
||||
});
|
||||
|
||||
// update options
|
||||
Shiny.addCustomMessageHandler('update-apexchart-options',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateOptions(obj.data.options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,107 +0,0 @@
|
|||
HTMLWidgets.widget({
|
||||
|
||||
name: 'apexcharter',
|
||||
|
||||
type: 'output',
|
||||
|
||||
factory: function(el, width, height) {
|
||||
|
||||
var ax_opts;
|
||||
var apexchart = null;
|
||||
|
||||
return {
|
||||
|
||||
renderValue: function(x) {
|
||||
|
||||
|
||||
// Global options
|
||||
ax_opts = x.ax_opts;
|
||||
|
||||
// Sizing
|
||||
if (typeof ax_opts.chart === 'undefined') {
|
||||
ax_opts.chart = {};
|
||||
}
|
||||
ax_opts.chart.width = width;
|
||||
ax_opts.chart.height = height;
|
||||
if (!ax_opts.chart.hasOwnProperty('parentHeightOffset')) {
|
||||
ax_opts.chart.parentHeightOffset = 0;
|
||||
}
|
||||
|
||||
// Generate or update chart
|
||||
if (apexchart === null) {
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
} else {
|
||||
if (x.auto_update) {
|
||||
apexchart.updateSeries(ax_opts.series);
|
||||
} else {
|
||||
apexchart.destroy();
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
getChart: function(){
|
||||
return apexchart;
|
||||
},
|
||||
|
||||
resize: function(width, height) {
|
||||
apexchart.updateOptions({
|
||||
chart: {
|
||||
width: width,
|
||||
height: height
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// From Friss tuto (https://github.com/FrissAnalytics/shinyJsTutorials/blob/master/tutorials/tutorial_03.Rmd)
|
||||
function get_widget(id){
|
||||
|
||||
// Get the HTMLWidgets object
|
||||
var htmlWidgetsObj = HTMLWidgets.find("#" + id);
|
||||
|
||||
// Use the getChart method we created to get the underlying billboard chart
|
||||
var widgetObj ;
|
||||
|
||||
if (typeof htmlWidgetsObj != 'undefined') {
|
||||
widgetObj = htmlWidgetsObj.getChart();
|
||||
}
|
||||
|
||||
return(widgetObj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (HTMLWidgets.shinyMode) {
|
||||
// update serie
|
||||
Shiny.addCustomMessageHandler('update-apexchart-series',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateSeries([{
|
||||
data: obj.data.newSeries
|
||||
}], obj.data.animate);
|
||||
}
|
||||
});
|
||||
|
||||
// update options
|
||||
Shiny.addCustomMessageHandler('update-apexchart-options',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateOptions(obj.data.options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
HTMLWidgets.widget({
|
||||
|
||||
name: 'apexcharter',
|
||||
|
||||
type: 'output',
|
||||
|
||||
factory: function(el, width, height) {
|
||||
|
||||
var ax_opts;
|
||||
var apexchart = null;
|
||||
|
||||
return {
|
||||
|
||||
renderValue: function(x) {
|
||||
|
||||
|
||||
// Global options
|
||||
ax_opts = x.ax_opts;
|
||||
|
||||
// Sizing
|
||||
if (typeof ax_opts.chart === 'undefined') {
|
||||
ax_opts.chart = {};
|
||||
}
|
||||
ax_opts.chart.width = width;
|
||||
ax_opts.chart.height = height;
|
||||
|
||||
// Generate or update chart
|
||||
if (apexchart === null) {
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
} else {
|
||||
if (x.auto_update) {
|
||||
apexchart.updateSeries(ax_opts.series);
|
||||
} else {
|
||||
apexchart.destroy();
|
||||
apexchart = new ApexCharts(document.querySelector("#" + el.id), ax_opts);
|
||||
apexchart.render();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
getChart: function(){
|
||||
return apexchart;
|
||||
},
|
||||
|
||||
resize: function(width, height) {
|
||||
apexchart.updateOptions({
|
||||
chart: {
|
||||
width: width,
|
||||
height: height
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// From Friss tuto (https://github.com/FrissAnalytics/shinyJsTutorials/blob/master/tutorials/tutorial_03.Rmd)
|
||||
function get_widget(id){
|
||||
|
||||
// Get the HTMLWidgets object
|
||||
var htmlWidgetsObj = HTMLWidgets.find("#" + id);
|
||||
|
||||
// Use the getChart method we created to get the underlying billboard chart
|
||||
var widgetObj ;
|
||||
|
||||
if (typeof htmlWidgetsObj != 'undefined') {
|
||||
widgetObj = htmlWidgetsObj.getChart();
|
||||
}
|
||||
|
||||
return(widgetObj);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (HTMLWidgets.shinyMode) {
|
||||
// update serie
|
||||
Shiny.addCustomMessageHandler('update-apexchart-series',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateSeries([{
|
||||
data: obj.data.newSeries
|
||||
}], obj.data.animate);
|
||||
}
|
||||
});
|
||||
|
||||
// update options
|
||||
Shiny.addCustomMessageHandler('update-apexchart-options',
|
||||
function(obj) {
|
||||
var chart = get_widget(obj.id);
|
||||
if (typeof chart != 'undefined') {
|
||||
chart.updateOptions(obj.data.options);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,839 +0,0 @@
|
|||
(function() {
|
||||
// If window.HTMLWidgets is already defined, then use it; otherwise create a
|
||||
// new object. This allows preceding code to set options that affect the
|
||||
// initialization process (though none currently exist).
|
||||
window.HTMLWidgets = window.HTMLWidgets || {};
|
||||
|
||||
// See if we're running in a viewer pane. If not, we're in a web browser.
|
||||
var viewerMode = window.HTMLWidgets.viewerMode =
|
||||
/\bviewer_pane=1\b/.test(window.location);
|
||||
|
||||
// See if we're running in Shiny mode. If not, it's a static document.
|
||||
// Note that static widgets can appear in both Shiny and static modes, but
|
||||
// obviously, Shiny widgets can only appear in Shiny apps/documents.
|
||||
var shinyMode = window.HTMLWidgets.shinyMode =
|
||||
typeof(window.Shiny) !== "undefined" && !!window.Shiny.outputBindings;
|
||||
|
||||
// We can't count on jQuery being available, so we implement our own
|
||||
// version if necessary.
|
||||
function querySelectorAll(scope, selector) {
|
||||
if (typeof(jQuery) !== "undefined" && scope instanceof jQuery) {
|
||||
return scope.find(selector);
|
||||
}
|
||||
if (scope.querySelectorAll) {
|
||||
return scope.querySelectorAll(selector);
|
||||
}
|
||||
}
|
||||
|
||||
function asArray(value) {
|
||||
if (value === null)
|
||||
return [];
|
||||
if ($.isArray(value))
|
||||
return value;
|
||||
return [value];
|
||||
}
|
||||
|
||||
// Implement jQuery's extend
|
||||
function extend(target /*, ... */) {
|
||||
if (arguments.length == 1) {
|
||||
return target;
|
||||
}
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
for (var prop in source) {
|
||||
if (source.hasOwnProperty(prop)) {
|
||||
target[prop] = source[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
// IE8 doesn't support Array.forEach.
|
||||
function forEach(values, callback, thisArg) {
|
||||
if (values.forEach) {
|
||||
values.forEach(callback, thisArg);
|
||||
} else {
|
||||
for (var i = 0; i < values.length; i++) {
|
||||
callback.call(thisArg, values[i], i, values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Replaces the specified method with the return value of funcSource.
|
||||
//
|
||||
// Note that funcSource should not BE the new method, it should be a function
|
||||
// that RETURNS the new method. funcSource receives a single argument that is
|
||||
// the overridden method, it can be called from the new method. The overridden
|
||||
// method can be called like a regular function, it has the target permanently
|
||||
// bound to it so "this" will work correctly.
|
||||
function overrideMethod(target, methodName, funcSource) {
|
||||
var superFunc = target[methodName] || function() {};
|
||||
var superFuncBound = function() {
|
||||
return superFunc.apply(target, arguments);
|
||||
};
|
||||
target[methodName] = funcSource(superFuncBound);
|
||||
}
|
||||
|
||||
// Add a method to delegator that, when invoked, calls
|
||||
// delegatee.methodName. If there is no such method on
|
||||
// the delegatee, but there was one on delegator before
|
||||
// delegateMethod was called, then the original version
|
||||
// is invoked instead.
|
||||
// For example:
|
||||
//
|
||||
// var a = {
|
||||
// method1: function() { console.log('a1'); }
|
||||
// method2: function() { console.log('a2'); }
|
||||
// };
|
||||
// var b = {
|
||||
// method1: function() { console.log('b1'); }
|
||||
// };
|
||||
// delegateMethod(a, b, "method1");
|
||||
// delegateMethod(a, b, "method2");
|
||||
// a.method1();
|
||||
// a.method2();
|
||||
//
|
||||
// The output would be "b1", "a2".
|
||||
function delegateMethod(delegator, delegatee, methodName) {
|
||||
var inherited = delegator[methodName];
|
||||
delegator[methodName] = function() {
|
||||
var target = delegatee;
|
||||
var method = delegatee[methodName];
|
||||
|
||||
// The method doesn't exist on the delegatee. Instead,
|
||||
// call the method on the delegator, if it exists.
|
||||
if (!method) {
|
||||
target = delegator;
|
||||
method = inherited;
|
||||
}
|
||||
|
||||
if (method) {
|
||||
return method.apply(target, arguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Implement a vague facsimilie of jQuery's data method
|
||||
function elementData(el, name, value) {
|
||||
if (arguments.length == 2) {
|
||||
return el["htmlwidget_data_" + name];
|
||||
} else if (arguments.length == 3) {
|
||||
el["htmlwidget_data_" + name] = value;
|
||||
return el;
|
||||
} else {
|
||||
throw new Error("Wrong number of arguments for elementData: " +
|
||||
arguments.length);
|
||||
}
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
|
||||
function escapeRegExp(str) {
|
||||
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||
}
|
||||
|
||||
function hasClass(el, className) {
|
||||
var re = new RegExp("\\b" + escapeRegExp(className) + "\\b");
|
||||
return re.test(el.className);
|
||||
}
|
||||
|
||||
// elements - array (or array-like object) of HTML elements
|
||||
// className - class name to test for
|
||||
// include - if true, only return elements with given className;
|
||||
// if false, only return elements *without* given className
|
||||
function filterByClass(elements, className, include) {
|
||||
var results = [];
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
if (hasClass(elements[i], className) == include)
|
||||
results.push(elements[i]);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
function on(obj, eventName, func) {
|
||||
if (obj.addEventListener) {
|
||||
obj.addEventListener(eventName, func, false);
|
||||
} else if (obj.attachEvent) {
|
||||
obj.attachEvent(eventName, func);
|
||||
}
|
||||
}
|
||||
|
||||
function off(obj, eventName, func) {
|
||||
if (obj.removeEventListener)
|
||||
obj.removeEventListener(eventName, func, false);
|
||||
else if (obj.detachEvent) {
|
||||
obj.detachEvent(eventName, func);
|
||||
}
|
||||
}
|
||||
|
||||
// Translate array of values to top/right/bottom/left, as usual with
|
||||
// the "padding" CSS property
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/padding
|
||||
function unpackPadding(value) {
|
||||
if (typeof(value) === "number")
|
||||
value = [value];
|
||||
if (value.length === 1) {
|
||||
return {top: value[0], right: value[0], bottom: value[0], left: value[0]};
|
||||
}
|
||||
if (value.length === 2) {
|
||||
return {top: value[0], right: value[1], bottom: value[0], left: value[1]};
|
||||
}
|
||||
if (value.length === 3) {
|
||||
return {top: value[0], right: value[1], bottom: value[2], left: value[1]};
|
||||
}
|
||||
if (value.length === 4) {
|
||||
return {top: value[0], right: value[1], bottom: value[2], left: value[3]};
|
||||
}
|
||||
}
|
||||
|
||||
// Convert an unpacked padding object to a CSS value
|
||||
function paddingToCss(paddingObj) {
|
||||
return paddingObj.top + "px " + paddingObj.right + "px " + paddingObj.bottom + "px " + paddingObj.left + "px";
|
||||
}
|
||||
|
||||
// Makes a number suitable for CSS
|
||||
function px(x) {
|
||||
if (typeof(x) === "number")
|
||||
return x + "px";
|
||||
else
|
||||
return x;
|
||||
}
|
||||
|
||||
// Retrieves runtime widget sizing information for an element.
|
||||
// The return value is either null, or an object with fill, padding,
|
||||
// defaultWidth, defaultHeight fields.
|
||||
function sizingPolicy(el) {
|
||||
var sizingEl = document.querySelector("script[data-for='" + el.id + "'][type='application/htmlwidget-sizing']");
|
||||
if (!sizingEl)
|
||||
return null;
|
||||
var sp = JSON.parse(sizingEl.textContent || sizingEl.text || "{}");
|
||||
if (viewerMode) {
|
||||
return sp.viewer;
|
||||
} else {
|
||||
return sp.browser;
|
||||
}
|
||||
}
|
||||
|
||||
// @param tasks Array of strings (or falsy value, in which case no-op).
|
||||
// Each element must be a valid JavaScript expression that yields a
|
||||
// function. Or, can be an array of objects with "code" and "data"
|
||||
// properties; in this case, the "code" property should be a string
|
||||
// of JS that's an expr that yields a function, and "data" should be
|
||||
// an object that will be added as an additional argument when that
|
||||
// function is called.
|
||||
// @param target The object that will be "this" for each function
|
||||
// execution.
|
||||
// @param args Array of arguments to be passed to the functions. (The
|
||||
// same arguments will be passed to all functions.)
|
||||
function evalAndRun(tasks, target, args) {
|
||||
if (tasks) {
|
||||
forEach(tasks, function(task) {
|
||||
var theseArgs = args;
|
||||
if (typeof(task) === "object") {
|
||||
theseArgs = theseArgs.concat([task.data]);
|
||||
task = task.code;
|
||||
}
|
||||
var taskFunc = eval("(" + task + ")");
|
||||
if (typeof(taskFunc) !== "function") {
|
||||
throw new Error("Task must be a function! Source:\n" + task);
|
||||
}
|
||||
taskFunc.apply(target, theseArgs);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function initSizing(el) {
|
||||
var sizing = sizingPolicy(el);
|
||||
if (!sizing)
|
||||
return;
|
||||
|
||||
var cel = document.getElementById("htmlwidget_container");
|
||||
if (!cel)
|
||||
return;
|
||||
|
||||
if (typeof(sizing.padding) !== "undefined") {
|
||||
document.body.style.margin = "0";
|
||||
document.body.style.padding = paddingToCss(unpackPadding(sizing.padding));
|
||||
}
|
||||
|
||||
if (sizing.fill) {
|
||||
document.body.style.overflow = "hidden";
|
||||
document.body.style.width = "100%";
|
||||
document.body.style.height = "100%";
|
||||
document.documentElement.style.width = "100%";
|
||||
document.documentElement.style.height = "100%";
|
||||
if (cel) {
|
||||
cel.style.position = "absolute";
|
||||
var pad = unpackPadding(sizing.padding);
|
||||
cel.style.top = pad.top + "px";
|
||||
cel.style.right = pad.right + "px";
|
||||
cel.style.bottom = pad.bottom + "px";
|
||||
cel.style.left = pad.left + "px";
|
||||
el.style.width = "100%";
|
||||
el.style.height = "100%";
|
||||
}
|
||||
|
||||
return {
|
||||
getWidth: function() { return cel.offsetWidth; },
|
||||
getHeight: function() { return cel.offsetHeight; }
|
||||
};
|
||||
|
||||
} else {
|
||||
el.style.width = px(sizing.width);
|
||||
el.style.height = px(sizing.height);
|
||||
|
||||
return {
|
||||
getWidth: function() { return el.offsetWidth; },
|
||||
getHeight: function() { return el.offsetHeight; }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Default implementations for methods
|
||||
var defaults = {
|
||||
find: function(scope) {
|
||||
return querySelectorAll(scope, "." + this.name);
|
||||
},
|
||||
renderError: function(el, err) {
|
||||
var $el = $(el);
|
||||
|
||||
this.clearError(el);
|
||||
|
||||
// Add all these error classes, as Shiny does
|
||||
var errClass = "shiny-output-error";
|
||||
if (err.type !== null) {
|
||||
// use the classes of the error condition as CSS class names
|
||||
errClass = errClass + " " + $.map(asArray(err.type), function(type) {
|
||||
return errClass + "-" + type;
|
||||
}).join(" ");
|
||||
}
|
||||
errClass = errClass + " htmlwidgets-error";
|
||||
|
||||
// Is el inline or block? If inline or inline-block, just display:none it
|
||||
// and add an inline error.
|
||||
var display = $el.css("display");
|
||||
$el.data("restore-display-mode", display);
|
||||
|
||||
if (display === "inline" || display === "inline-block") {
|
||||
$el.hide();
|
||||
if (err.message !== "") {
|
||||
var errorSpan = $("<span>").addClass(errClass);
|
||||
errorSpan.text(err.message);
|
||||
$el.after(errorSpan);
|
||||
}
|
||||
} else if (display === "block") {
|
||||
// If block, add an error just after the el, set visibility:none on the
|
||||
// el, and position the error to be on top of the el.
|
||||
// Mark it with a unique ID and CSS class so we can remove it later.
|
||||
$el.css("visibility", "hidden");
|
||||
if (err.message !== "") {
|
||||
var errorDiv = $("<div>").addClass(errClass).css("position", "absolute")
|
||||
.css("top", el.offsetTop)
|
||||
.css("left", el.offsetLeft)
|
||||
// setting width can push out the page size, forcing otherwise
|
||||
// unnecessary scrollbars to appear and making it impossible for
|
||||
// the element to shrink; so use max-width instead
|
||||
.css("maxWidth", el.offsetWidth)
|
||||
.css("height", el.offsetHeight);
|
||||
errorDiv.text(err.message);
|
||||
$el.after(errorDiv);
|
||||
|
||||
// Really dumb way to keep the size/position of the error in sync with
|
||||
// the parent element as the window is resized or whatever.
|
||||
var intId = setInterval(function() {
|
||||
if (!errorDiv[0].parentElement) {
|
||||
clearInterval(intId);
|
||||
return;
|
||||
}
|
||||
errorDiv
|
||||
.css("top", el.offsetTop)
|
||||
.css("left", el.offsetLeft)
|
||||
.css("maxWidth", el.offsetWidth)
|
||||
.css("height", el.offsetHeight);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
},
|
||||
clearError: function(el) {
|
||||
var $el = $(el);
|
||||
var display = $el.data("restore-display-mode");
|
||||
$el.data("restore-display-mode", null);
|
||||
|
||||
if (display === "inline" || display === "inline-block") {
|
||||
if (display)
|
||||
$el.css("display", display);
|
||||
$(el.nextSibling).filter(".htmlwidgets-error").remove();
|
||||
} else if (display === "block"){
|
||||
$el.css("visibility", "inherit");
|
||||
$(el.nextSibling).filter(".htmlwidgets-error").remove();
|
||||
}
|
||||
},
|
||||
sizing: {}
|
||||
};
|
||||
|
||||
// Called by widget bindings to register a new type of widget. The definition
|
||||
// object can contain the following properties:
|
||||
// - name (required) - A string indicating the binding name, which will be
|
||||
// used by default as the CSS classname to look for.
|
||||
// - initialize (optional) - A function(el) that will be called once per
|
||||
// widget element; if a value is returned, it will be passed as the third
|
||||
// value to renderValue.
|
||||
// - renderValue (required) - A function(el, data, initValue) that will be
|
||||
// called with data. Static contexts will cause this to be called once per
|
||||
// element; Shiny apps will cause this to be called multiple times per
|
||||
// element, as the data changes.
|
||||
window.HTMLWidgets.widget = function(definition) {
|
||||
if (!definition.name) {
|
||||
throw new Error("Widget must have a name");
|
||||
}
|
||||
if (!definition.type) {
|
||||
throw new Error("Widget must have a type");
|
||||
}
|
||||
// Currently we only support output widgets
|
||||
if (definition.type !== "output") {
|
||||
throw new Error("Unrecognized widget type '" + definition.type + "'");
|
||||
}
|
||||
// TODO: Verify that .name is a valid CSS classname
|
||||
|
||||
// Support new-style instance-bound definitions. Old-style class-bound
|
||||
// definitions have one widget "object" per widget per type/class of
|
||||
// widget; the renderValue and resize methods on such widget objects
|
||||
// take el and instance arguments, because the widget object can't
|
||||
// store them. New-style instance-bound definitions have one widget
|
||||
// object per widget instance; the definition that's passed in doesn't
|
||||
// provide renderValue or resize methods at all, just the single method
|
||||
// factory(el, width, height)
|
||||
// which returns an object that has renderValue(x) and resize(w, h).
|
||||
// This enables a far more natural programming style for the widget
|
||||
// author, who can store per-instance state using either OO-style
|
||||
// instance fields or functional-style closure variables (I guess this
|
||||
// is in contrast to what can only be called C-style pseudo-OO which is
|
||||
// what we required before).
|
||||
if (definition.factory) {
|
||||
definition = createLegacyDefinitionAdapter(definition);
|
||||
}
|
||||
|
||||
if (!definition.renderValue) {
|
||||
throw new Error("Widget must have a renderValue function");
|
||||
}
|
||||
|
||||
// For static rendering (non-Shiny), use a simple widget registration
|
||||
// scheme. We also use this scheme for Shiny apps/documents that also
|
||||
// contain static widgets.
|
||||
window.HTMLWidgets.widgets = window.HTMLWidgets.widgets || [];
|
||||
// Merge defaults into the definition; don't mutate the original definition.
|
||||
var staticBinding = extend({}, defaults, definition);
|
||||
overrideMethod(staticBinding, "find", function(superfunc) {
|
||||
return function(scope) {
|
||||
var results = superfunc(scope);
|
||||
// Filter out Shiny outputs, we only want the static kind
|
||||
return filterByClass(results, "html-widget-output", false);
|
||||
};
|
||||
});
|
||||
window.HTMLWidgets.widgets.push(staticBinding);
|
||||
|
||||
if (shinyMode) {
|
||||
// Shiny is running. Register the definition with an output binding.
|
||||
// The definition itself will not be the output binding, instead
|
||||
// we will make an output binding object that delegates to the
|
||||
// definition. This is because we foolishly used the same method
|
||||
// name (renderValue) for htmlwidgets definition and Shiny bindings
|
||||
// but they actually have quite different semantics (the Shiny
|
||||
// bindings receive data that includes lots of metadata that it
|
||||
// strips off before calling htmlwidgets renderValue). We can't
|
||||
// just ignore the difference because in some widgets it's helpful
|
||||
// to call this.renderValue() from inside of resize(), and if
|
||||
// we're not delegating, then that call will go to the Shiny
|
||||
// version instead of the htmlwidgets version.
|
||||
|
||||
// Merge defaults with definition, without mutating either.
|
||||
var bindingDef = extend({}, defaults, definition);
|
||||
|
||||
// This object will be our actual Shiny binding.
|
||||
var shinyBinding = new Shiny.OutputBinding();
|
||||
|
||||
// With a few exceptions, we'll want to simply use the bindingDef's
|
||||
// version of methods if they are available, otherwise fall back to
|
||||
// Shiny's defaults. NOTE: If Shiny's output bindings gain additional
|
||||
// methods in the future, and we want them to be overrideable by
|
||||
// HTMLWidget binding definitions, then we'll need to add them to this
|
||||
// list.
|
||||
delegateMethod(shinyBinding, bindingDef, "getId");
|
||||
delegateMethod(shinyBinding, bindingDef, "onValueChange");
|
||||
delegateMethod(shinyBinding, bindingDef, "onValueError");
|
||||
delegateMethod(shinyBinding, bindingDef, "renderError");
|
||||
delegateMethod(shinyBinding, bindingDef, "clearError");
|
||||
delegateMethod(shinyBinding, bindingDef, "showProgress");
|
||||
|
||||
// The find, renderValue, and resize are handled differently, because we
|
||||
// want to actually decorate the behavior of the bindingDef methods.
|
||||
|
||||
shinyBinding.find = function(scope) {
|
||||
var results = bindingDef.find(scope);
|
||||
|
||||
// Only return elements that are Shiny outputs, not static ones
|
||||
var dynamicResults = results.filter(".html-widget-output");
|
||||
|
||||
// It's possible that whatever caused Shiny to think there might be
|
||||
// new dynamic outputs, also caused there to be new static outputs.
|
||||
// Since there might be lots of different htmlwidgets bindings, we
|
||||
// schedule execution for later--no need to staticRender multiple
|
||||
// times.
|
||||
if (results.length !== dynamicResults.length)
|
||||
scheduleStaticRender();
|
||||
|
||||
return dynamicResults;
|
||||
};
|
||||
|
||||
// Wrap renderValue to handle initialization, which unfortunately isn't
|
||||
// supported natively by Shiny at the time of this writing.
|
||||
|
||||
shinyBinding.renderValue = function(el, data) {
|
||||
Shiny.renderDependencies(data.deps);
|
||||
// Resolve strings marked as javascript literals to objects
|
||||
if (!(data.evals instanceof Array)) data.evals = [data.evals];
|
||||
for (var i = 0; data.evals && i < data.evals.length; i++) {
|
||||
window.HTMLWidgets.evaluateStringMember(data.x, data.evals[i]);
|
||||
}
|
||||
if (!bindingDef.renderOnNullValue) {
|
||||
if (data.x === null) {
|
||||
el.style.visibility = "hidden";
|
||||
return;
|
||||
} else {
|
||||
el.style.visibility = "inherit";
|
||||
}
|
||||
}
|
||||
if (!elementData(el, "initialized")) {
|
||||
initSizing(el);
|
||||
|
||||
elementData(el, "initialized", true);
|
||||
if (bindingDef.initialize) {
|
||||
var result = bindingDef.initialize(el, el.offsetWidth,
|
||||
el.offsetHeight);
|
||||
elementData(el, "init_result", result);
|
||||
}
|
||||
}
|
||||
bindingDef.renderValue(el, data.x, elementData(el, "init_result"));
|
||||
evalAndRun(data.jsHooks.render, elementData(el, "init_result"), [el, data.x]);
|
||||
};
|
||||
|
||||
// Only override resize if bindingDef implements it
|
||||
if (bindingDef.resize) {
|
||||
shinyBinding.resize = function(el, width, height) {
|
||||
// Shiny can call resize before initialize/renderValue have been
|
||||
// called, which doesn't make sense for widgets.
|
||||
if (elementData(el, "initialized")) {
|
||||
bindingDef.resize(el, width, height, elementData(el, "init_result"));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Shiny.outputBindings.register(shinyBinding, bindingDef.name);
|
||||
}
|
||||
};
|
||||
|
||||
var scheduleStaticRenderTimerId = null;
|
||||
function scheduleStaticRender() {
|
||||
if (!scheduleStaticRenderTimerId) {
|
||||
scheduleStaticRenderTimerId = setTimeout(function() {
|
||||
scheduleStaticRenderTimerId = null;
|
||||
window.HTMLWidgets.staticRender();
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Render static widgets after the document finishes loading
|
||||
// Statically render all elements that are of this widget's class
|
||||
window.HTMLWidgets.staticRender = function() {
|
||||
var bindings = window.HTMLWidgets.widgets || [];
|
||||
forEach(bindings, function(binding) {
|
||||
var matches = binding.find(document.documentElement);
|
||||
forEach(matches, function(el) {
|
||||
var sizeObj = initSizing(el, binding);
|
||||
|
||||
if (hasClass(el, "html-widget-static-bound"))
|
||||
return;
|
||||
el.className = el.className + " html-widget-static-bound";
|
||||
|
||||
var initResult;
|
||||
if (binding.initialize) {
|
||||
initResult = binding.initialize(el,
|
||||
sizeObj ? sizeObj.getWidth() : el.offsetWidth,
|
||||
sizeObj ? sizeObj.getHeight() : el.offsetHeight
|
||||
);
|
||||
elementData(el, "init_result", initResult);
|
||||
}
|
||||
|
||||
if (binding.resize) {
|
||||
var lastSize = {
|
||||
w: sizeObj ? sizeObj.getWidth() : el.offsetWidth,
|
||||
h: sizeObj ? sizeObj.getHeight() : el.offsetHeight
|
||||
};
|
||||
var resizeHandler = function(e) {
|
||||
var size = {
|
||||
w: sizeObj ? sizeObj.getWidth() : el.offsetWidth,
|
||||
h: sizeObj ? sizeObj.getHeight() : el.offsetHeight
|
||||
};
|
||||
if (size.w === 0 && size.h === 0)
|
||||
return;
|
||||
if (size.w === lastSize.w && size.h === lastSize.h)
|
||||
return;
|
||||
lastSize = size;
|
||||
binding.resize(el, size.w, size.h, initResult);
|
||||
};
|
||||
|
||||
on(window, "resize", resizeHandler);
|
||||
|
||||
// This is needed for cases where we're running in a Shiny
|
||||
// app, but the widget itself is not a Shiny output, but
|
||||
// rather a simple static widget. One example of this is
|
||||
// an rmarkdown document that has runtime:shiny and widget
|
||||
// that isn't in a render function. Shiny only knows to
|
||||
// call resize handlers for Shiny outputs, not for static
|
||||
// widgets, so we do it ourselves.
|
||||
if (window.jQuery) {
|
||||
window.jQuery(document).on(
|
||||
"shown.htmlwidgets shown.bs.tab.htmlwidgets shown.bs.collapse.htmlwidgets",
|
||||
resizeHandler
|
||||
);
|
||||
window.jQuery(document).on(
|
||||
"hidden.htmlwidgets hidden.bs.tab.htmlwidgets hidden.bs.collapse.htmlwidgets",
|
||||
resizeHandler
|
||||
);
|
||||
}
|
||||
|
||||
// This is needed for the specific case of ioslides, which
|
||||
// flips slides between display:none and display:block.
|
||||
// Ideally we would not have to have ioslide-specific code
|
||||
// here, but rather have ioslides raise a generic event,
|
||||
// but the rmarkdown package just went to CRAN so the
|
||||
// window to getting that fixed may be long.
|
||||
if (window.addEventListener) {
|
||||
// It's OK to limit this to window.addEventListener
|
||||
// browsers because ioslides itself only supports
|
||||
// such browsers.
|
||||
on(document, "slideenter", resizeHandler);
|
||||
on(document, "slideleave", resizeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
var scriptData = document.querySelector("script[data-for='" + el.id + "'][type='application/json']");
|
||||
if (scriptData) {
|
||||
var data = JSON.parse(scriptData.textContent || scriptData.text);
|
||||
// Resolve strings marked as javascript literals to objects
|
||||
if (!(data.evals instanceof Array)) data.evals = [data.evals];
|
||||
for (var k = 0; data.evals && k < data.evals.length; k++) {
|
||||
window.HTMLWidgets.evaluateStringMember(data.x, data.evals[k]);
|
||||
}
|
||||
binding.renderValue(el, data.x, initResult);
|
||||
evalAndRun(data.jsHooks.render, initResult, [el, data.x]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
invokePostRenderHandlers();
|
||||
}
|
||||
|
||||
// Wait until after the document has loaded to render the widgets.
|
||||
if (document.addEventListener) {
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
document.removeEventListener("DOMContentLoaded", arguments.callee, false);
|
||||
window.HTMLWidgets.staticRender();
|
||||
}, false);
|
||||
} else if (document.attachEvent) {
|
||||
document.attachEvent("onreadystatechange", function() {
|
||||
if (document.readyState === "complete") {
|
||||
document.detachEvent("onreadystatechange", arguments.callee);
|
||||
window.HTMLWidgets.staticRender();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
window.HTMLWidgets.getAttachmentUrl = function(depname, key) {
|
||||
// If no key, default to the first item
|
||||
if (typeof(key) === "undefined")
|
||||
key = 1;
|
||||
|
||||
var link = document.getElementById(depname + "-" + key + "-attachment");
|
||||
if (!link) {
|
||||
throw new Error("Attachment " + depname + "/" + key + " not found in document");
|
||||
}
|
||||
return link.getAttribute("href");
|
||||
};
|
||||
|
||||
window.HTMLWidgets.dataframeToD3 = function(df) {
|
||||
var names = [];
|
||||
var length;
|
||||
for (var name in df) {
|
||||
if (df.hasOwnProperty(name))
|
||||
names.push(name);
|
||||
if (typeof(df[name]) !== "object" || typeof(df[name].length) === "undefined") {
|
||||
throw new Error("All fields must be arrays");
|
||||
} else if (typeof(length) !== "undefined" && length !== df[name].length) {
|
||||
throw new Error("All fields must be arrays of the same length");
|
||||
}
|
||||
length = df[name].length;
|
||||
}
|
||||
var results = [];
|
||||
var item;
|
||||
for (var row = 0; row < length; row++) {
|
||||
item = {};
|
||||
for (var col = 0; col < names.length; col++) {
|
||||
item[names[col]] = df[names[col]][row];
|
||||
}
|
||||
results.push(item);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
window.HTMLWidgets.transposeArray2D = function(array) {
|
||||
if (array.length === 0) return array;
|
||||
var newArray = array[0].map(function(col, i) {
|
||||
return array.map(function(row) {
|
||||
return row[i]
|
||||
})
|
||||
});
|
||||
return newArray;
|
||||
};
|
||||
// Split value at splitChar, but allow splitChar to be escaped
|
||||
// using escapeChar. Any other characters escaped by escapeChar
|
||||
// will be included as usual (including escapeChar itself).
|
||||
function splitWithEscape(value, splitChar, escapeChar) {
|
||||
var results = [];
|
||||
var escapeMode = false;
|
||||
var currentResult = "";
|
||||
for (var pos = 0; pos < value.length; pos++) {
|
||||
if (!escapeMode) {
|
||||
if (value[pos] === splitChar) {
|
||||
results.push(currentResult);
|
||||
currentResult = "";
|
||||
} else if (value[pos] === escapeChar) {
|
||||
escapeMode = true;
|
||||
} else {
|
||||
currentResult += value[pos];
|
||||
}
|
||||
} else {
|
||||
currentResult += value[pos];
|
||||
escapeMode = false;
|
||||
}
|
||||
}
|
||||
if (currentResult !== "") {
|
||||
results.push(currentResult);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
// Function authored by Yihui/JJ Allaire
|
||||
window.HTMLWidgets.evaluateStringMember = function(o, member) {
|
||||
var parts = splitWithEscape(member, '.', '\\');
|
||||
for (var i = 0, l = parts.length; i < l; i++) {
|
||||
var part = parts[i];
|
||||
// part may be a character or 'numeric' member name
|
||||
if (o !== null && typeof o === "object" && part in o) {
|
||||
if (i == (l - 1)) { // if we are at the end of the line then evalulate
|
||||
if (typeof o[part] === "string")
|
||||
o[part] = eval("(" + o[part] + ")");
|
||||
} else { // otherwise continue to next embedded object
|
||||
o = o[part];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Retrieve the HTMLWidget instance (i.e. the return value of an
|
||||
// HTMLWidget binding's initialize() or factory() function)
|
||||
// associated with an element, or null if none.
|
||||
window.HTMLWidgets.getInstance = function(el) {
|
||||
return elementData(el, "init_result");
|
||||
};
|
||||
|
||||
// Finds the first element in the scope that matches the selector,
|
||||
// and returns the HTMLWidget instance (i.e. the return value of
|
||||
// an HTMLWidget binding's initialize() or factory() function)
|
||||
// associated with that element, if any. If no element matches the
|
||||
// selector, or the first matching element has no HTMLWidget
|
||||
// instance associated with it, then null is returned.
|
||||
//
|
||||
// The scope argument is optional, and defaults to window.document.
|
||||
window.HTMLWidgets.find = function(scope, selector) {
|
||||
if (arguments.length == 1) {
|
||||
selector = scope;
|
||||
scope = document;
|
||||
}
|
||||
|
||||
var el = scope.querySelector(selector);
|
||||
if (el === null) {
|
||||
return null;
|
||||
} else {
|
||||
return window.HTMLWidgets.getInstance(el);
|
||||
}
|
||||
};
|
||||
|
||||
// Finds all elements in the scope that match the selector, and
|
||||
// returns the HTMLWidget instances (i.e. the return values of
|
||||
// an HTMLWidget binding's initialize() or factory() function)
|
||||
// associated with the elements, in an array. If elements that
|
||||
// match the selector don't have an associated HTMLWidget
|
||||
// instance, the returned array will contain nulls.
|
||||
//
|
||||
// The scope argument is optional, and defaults to window.document.
|
||||
window.HTMLWidgets.findAll = function(scope, selector) {
|
||||
if (arguments.length == 1) {
|
||||
selector = scope;
|
||||
scope = document;
|
||||
}
|
||||
|
||||
var nodes = scope.querySelectorAll(selector);
|
||||
var results = [];
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
results.push(window.HTMLWidgets.getInstance(nodes[i]));
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
var postRenderHandlers = [];
|
||||
function invokePostRenderHandlers() {
|
||||
while (postRenderHandlers.length) {
|
||||
var handler = postRenderHandlers.shift();
|
||||
if (handler) {
|
||||
handler();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register the given callback function to be invoked after the
|
||||
// next time static widgets are rendered.
|
||||
window.HTMLWidgets.addPostRenderHandler = function(callback) {
|
||||
postRenderHandlers.push(callback);
|
||||
};
|
||||
|
||||
// Takes a new-style instance-bound definition, and returns an
|
||||
// old-style class-bound definition. This saves us from having
|
||||
// to rewrite all the logic in this file to accomodate both
|
||||
// types of definitions.
|
||||
function createLegacyDefinitionAdapter(defn) {
|
||||
var result = {
|
||||
name: defn.name,
|
||||
type: defn.type,
|
||||
initialize: function(el, width, height) {
|
||||
return defn.factory(el, width, height);
|
||||
},
|
||||
renderValue: function(el, x, instance) {
|
||||
return instance.renderValue(x);
|
||||
},
|
||||
resize: function(el, width, height, instance) {
|
||||
return instance.resize(width, height);
|
||||
}
|
||||
};
|
||||
|
||||
if (defn.find)
|
||||
result.find = defn.find;
|
||||
if (defn.renderError)
|
||||
result.renderError = defn.renderError;
|
||||
if (defn.clearError)
|
||||
result.clearError = defn.clearError;
|
||||
|
||||
return result;
|
||||
}
|
||||
})();
|
||||
|
|
@ -1,158 +0,0 @@
|
|||
<!-- Generated by pkgdown: do not edit by hand -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Authors • apexcharter</title>
|
||||
|
||||
<!-- jquery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Font Awesome icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
|
||||
|
||||
<!-- clipboard.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- sticky kit -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- pkgdown -->
|
||||
<link href="pkgdown.css" rel="stylesheet">
|
||||
<script src="pkgdown.js"></script>
|
||||
|
||||
|
||||
|
||||
<meta property="og:title" content="Authors" />
|
||||
|
||||
|
||||
|
||||
<!-- mathjax -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container template-authors">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!--/.nav-collapse -->
|
||||
</div><!--/.container -->
|
||||
</div><!--/.navbar -->
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="contents col-md-9">
|
||||
<div class="page-header">
|
||||
<h1>Authors</h1>
|
||||
</div>
|
||||
|
||||
<ul class="list-unstyled">
|
||||
<li>
|
||||
<p><strong><a href='https://twitter.com/_pvictorr'><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"/> Victor Perrier</a></strong>. Author, maintainer.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p><strong><a href='https://twitter.com/_mfaan'><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg" /> Fanny Meyer</a></strong>. Author.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p><strong>Juned Chhipa</strong>. Copyright holder.
|
||||
<br /><small>apexcharts.js library</small></p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://twitter.com/_pvictorr'><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"/> Victor Perrier</a>, <a href='https://twitter.com/_mfaan'><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg" /> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
File diff suppressed because one or more lines are too long
|
@ -1,85 +0,0 @@
|
|||
$(function() {
|
||||
|
||||
// register a handler to move the focus to the search bar
|
||||
// upon pressing shift + "/" (i.e. "?")
|
||||
$(document).on('keydown', function(e) {
|
||||
if (e.shiftKey && e.keyCode == 191) {
|
||||
e.preventDefault();
|
||||
$("#search-input").focus();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
// do keyword highlighting
|
||||
/* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */
|
||||
var mark = function() {
|
||||
|
||||
var referrer = document.URL ;
|
||||
var paramKey = "q" ;
|
||||
|
||||
if (referrer.indexOf("?") !== -1) {
|
||||
var qs = referrer.substr(referrer.indexOf('?') + 1);
|
||||
var qs_noanchor = qs.split('#')[0];
|
||||
var qsa = qs_noanchor.split('&');
|
||||
var keyword = "";
|
||||
|
||||
for (var i = 0; i < qsa.length; i++) {
|
||||
var currentParam = qsa[i].split('=');
|
||||
|
||||
if (currentParam.length !== 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (currentParam[0] == paramKey) {
|
||||
keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20"));
|
||||
}
|
||||
}
|
||||
|
||||
if (keyword !== "") {
|
||||
$(".contents").unmark({
|
||||
done: function() {
|
||||
$(".contents").mark(keyword);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
mark();
|
||||
});
|
||||
});
|
||||
|
||||
/* Search term highlighting ------------------------------*/
|
||||
|
||||
function matchedWords(hit) {
|
||||
var words = [];
|
||||
|
||||
var hierarchy = hit._highlightResult.hierarchy;
|
||||
// loop to fetch from lvl0, lvl1, etc.
|
||||
for (var idx in hierarchy) {
|
||||
words = words.concat(hierarchy[idx].matchedWords);
|
||||
}
|
||||
|
||||
var content = hit._highlightResult.content;
|
||||
if (content) {
|
||||
words = words.concat(content.matchedWords);
|
||||
}
|
||||
|
||||
// return unique words
|
||||
var words_uniq = [...new Set(words)];
|
||||
return words_uniq;
|
||||
}
|
||||
|
||||
function updateHitURL(hit) {
|
||||
|
||||
var words = matchedWords(hit);
|
||||
var url = "";
|
||||
|
||||
if (hit.anchor) {
|
||||
url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor;
|
||||
} else {
|
||||
url = hit.url + '?q=' + escape(words.join(" "));
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
256
docs/index.html
256
docs/index.html
|
@ -1,256 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Create Interactive Chart with the JavaScript 'ApexCharts' Library • apexcharter</title>
|
||||
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script><!-- Bootstrap --><link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous">
|
||||
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- sticky kit --><script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script><!-- pkgdown --><link href="pkgdown.css" rel="stylesheet">
|
||||
<script src="pkgdown.js"></script><meta property="og:title" content="Create Interactive Chart with the JavaScript 'ApexCharts' Library">
|
||||
<meta property="og:description" content="Provides an 'htmlwidgets' interface to 'apexcharts.js'.
|
||||
'Apexcharts' is a modern JavaScript charting library to build interactive charts and visualizations with simple API.
|
||||
'Apexcharts' examples and documentation are available here: <https://apexcharts.com/>.">
|
||||
<meta name="twitter:card" content="summary">
|
||||
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div class="container template-home">
|
||||
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!--/.nav-collapse -->
|
||||
</div>
|
||||
<!--/.container -->
|
||||
</div>
|
||||
<!--/.navbar -->
|
||||
|
||||
|
||||
</header><div class="row">
|
||||
<div class="contents col-md-9">
|
||||
<div id="apexcharter" class="section level1">
|
||||
<div class="page-header"><h1 class="hasAnchor">
|
||||
<a href="#apexcharter" class="anchor"></a>apexcharter</h1></div>
|
||||
<blockquote>
|
||||
<p>Htmlwidget for <a href="https://github.com/apexcharts/apexcharts.js">apexcharts.js</a> : A modern JavaScript charting library to build interactive charts and visualizations with simple API.</p>
|
||||
</blockquote>
|
||||
<p><a href="https://CRAN.R-project.org/package=apexcharter"><img src="http://www.r-pkg.org/badges/version/apexcharter" alt="version"></a> <a href="https://travis-ci.org/dreamRs/apexcharter"><img src="https://travis-ci.org/dreamRs/apexcharter.svg?branch=master" alt="Travis build status"></a> <a href="https://www.tidyverse.org/lifecycle/#maturing"><img src="https://img.shields.io/badge/lifecycle-maturing-blue.svg" alt="Lifecycle: maturing"></a></p>
|
||||
<p><span class="emoji" data-emoji="warning">⚠️</span> Use RStudio >= 1.2 to properly display charts</p>
|
||||
<p>Note: Once again, development is heavily inspired by amazing <a href="http://jkunst.com/highcharter/">highcharter</a>.</p>
|
||||
<div id="installation" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#installation" class="anchor"></a>Installation</h2>
|
||||
<p>Install from CRAN with:</p>
|
||||
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" title="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/install.packages">install.packages</a></span>(<span class="st">"apexcharter"</span>)</a></code></pre></div>
|
||||
<p>Or install the development version from <a href="https://github.com/">GitHub</a> with:</p>
|
||||
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" title="1"><span class="co"># install.packages("devtools")</span></a>
|
||||
<a class="sourceLine" id="cb2-2" title="2">devtools<span class="op">::</span><span class="kw"><a href="https://www.rdocumentation.org/packages/devtools/topics/reexports">install_github</a></span>(<span class="st">"dreamRs/apexcharter"</span>)</a></code></pre></div>
|
||||
</div>
|
||||
<div id="quick-charts" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#quick-charts" class="anchor"></a>Quick Charts</h2>
|
||||
<p>Use <code>apex</code> function to quickly create visualizations :</p>
|
||||
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" title="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(apexcharter)</a>
|
||||
<a class="sourceLine" id="cb3-2" title="2"></a>
|
||||
<a class="sourceLine" id="cb3-3" title="3"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/data">data</a></span>(<span class="st">"mpg"</span>, <span class="dt">package =</span> <span class="st">"ggplot2"</span>)</a>
|
||||
<a class="sourceLine" id="cb3-4" title="4">n_manufac <-<span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/tally.html">count</a></span>(mpg, manufacturer)</a>
|
||||
<a class="sourceLine" id="cb3-5" title="5"></a>
|
||||
<a class="sourceLine" id="cb3-6" title="6"><span class="kw"><a href="reference/apex.html">apex</a></span>(<span class="dt">data =</span> n_manufac, <span class="dt">type =</span> <span class="st">"bar"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> manufacturer, <span class="dt">y =</span> n))</a></code></pre></div>
|
||||
<p><img src="reference/figures/apex-bar.png"></p>
|
||||
<p>With datetime:</p>
|
||||
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" title="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/data">data</a></span>(<span class="st">"economics"</span>, <span class="dt">package =</span> <span class="st">"ggplot2"</span>)</a>
|
||||
<a class="sourceLine" id="cb4-2" title="2"><span class="kw"><a href="reference/apex.html">apex</a></span>(<span class="dt">data =</span> economics, <span class="dt">type =</span> <span class="st">"line"</span>, <span class="dt">mapping =</span> <span class="kw"><a href="reference/apexcharter-exports.html">aes</a></span>(<span class="dt">x =</span> date, <span class="dt">y =</span> uempmed)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb4-3" title="3"><span class="st"> </span><span class="kw"><a href="reference/ax_stroke.html">ax_stroke</a></span>(<span class="dt">width =</span> <span class="dv">1</span>)</a></code></pre></div>
|
||||
<p><img src="reference/figures/apex-line.png"></p>
|
||||
</div>
|
||||
<div id="full-api" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#full-api" class="anchor"></a>Full API</h2>
|
||||
<p>All methods from ApexCharts are available with function like <code>ax_*</code> compatible with pipe from <code>magrittr</code> :</p>
|
||||
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" title="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(apexcharter)</a>
|
||||
<a class="sourceLine" id="cb5-2" title="2"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/data">data</a></span>(mpg, <span class="dt">package =</span> <span class="st">"ggplot2"</span>)</a>
|
||||
<a class="sourceLine" id="cb5-3" title="3">n_manufac <-<span class="st"> </span>dplyr<span class="op">::</span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/tally.html">count</a></span>(mpg, manufacturer)</a>
|
||||
<a class="sourceLine" id="cb5-4" title="4"></a>
|
||||
<a class="sourceLine" id="cb5-5" title="5"><span class="kw"><a href="reference/apexchart.html">apexchart</a></span>() <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb5-6" title="6"><span class="st"> </span><span class="kw"><a href="reference/ax_chart.html">ax_chart</a></span>(<span class="dt">type =</span> <span class="st">"bar"</span>) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb5-7" title="7"><span class="st"> </span><span class="kw"><a href="reference/ax_plotOptions.html">ax_plotOptions</a></span>(<span class="dt">bar =</span> <span class="kw"><a href="reference/bar_opts.html">bar_opts</a></span>(</a>
|
||||
<a class="sourceLine" id="cb5-8" title="8"> <span class="dt">horizontal =</span> <span class="ot">FALSE</span>,</a>
|
||||
<a class="sourceLine" id="cb5-9" title="9"> <span class="dt">endingShape =</span> <span class="st">"flat"</span>,</a>
|
||||
<a class="sourceLine" id="cb5-10" title="10"> <span class="dt">columnWidth =</span> <span class="st">"70%"</span>,</a>
|
||||
<a class="sourceLine" id="cb5-11" title="11"> <span class="dt">dataLabels =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb5-12" title="12"> <span class="dt">position =</span> <span class="st">"top"</span></a>
|
||||
<a class="sourceLine" id="cb5-13" title="13"> ))</a>
|
||||
<a class="sourceLine" id="cb5-14" title="14"> ) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb5-15" title="15"><span class="st"> </span><span class="kw"><a href="reference/ax_grid.html">ax_grid</a></span>(</a>
|
||||
<a class="sourceLine" id="cb5-16" title="16"> <span class="dt">show =</span> <span class="ot">TRUE</span>,</a>
|
||||
<a class="sourceLine" id="cb5-17" title="17"> <span class="dt">position =</span> <span class="st">"front"</span>,</a>
|
||||
<a class="sourceLine" id="cb5-18" title="18"> <span class="dt">borderColor =</span> <span class="st">"#FFF"</span></a>
|
||||
<a class="sourceLine" id="cb5-19" title="19"> ) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb5-20" title="20"><span class="st"> </span><span class="kw"><a href="reference/ax-series.html">ax_series</a></span>(<span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb5-21" title="21"> <span class="dt">name =</span> <span class="st">"Count"</span>,</a>
|
||||
<a class="sourceLine" id="cb5-22" title="22"> <span class="dt">data =</span> n_manufac<span class="op">$</span>n</a>
|
||||
<a class="sourceLine" id="cb5-23" title="23"> )) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb5-24" title="24"><span class="st"> </span><span class="kw"><a href="reference/ax_colors.html">ax_colors</a></span>(<span class="st">"#112446"</span>) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb5-25" title="25"><span class="st"> </span><span class="kw"><a href="reference/ax_xaxis.html">ax_xaxis</a></span>(<span class="dt">categories =</span> n_manufac<span class="op">$</span>manufacturer) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb5-26" title="26"><span class="st"> </span><span class="kw"><a href="reference/ax_title.html">ax_title</a></span>(<span class="dt">text =</span> <span class="st">"Number of models"</span>) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb5-27" title="27"><span class="st"> </span><span class="kw"><a href="reference/ax_subtitle.html">ax_subtitle</a></span>(<span class="dt">text =</span> <span class="st">"Data from ggplot2"</span>)</a></code></pre></div>
|
||||
<p><img src="reference/figures/apexcharter-full-bar.png"></p>
|
||||
</div>
|
||||
<div id="raw-api" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#raw-api" class="anchor"></a>Raw API</h2>
|
||||
<p>Pass a list of parameters to the function:</p>
|
||||
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb6-1" title="1"><span class="kw"><a href="reference/apexchart.html">apexchart</a></span>(<span class="dt">ax_opts =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb6-2" title="2"> <span class="dt">chart =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb6-3" title="3"> <span class="dt">type =</span> <span class="st">"line"</span></a>
|
||||
<a class="sourceLine" id="cb6-4" title="4"> ),</a>
|
||||
<a class="sourceLine" id="cb6-5" title="5"> <span class="dt">stroke =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb6-6" title="6"> <span class="dt">curve =</span> <span class="st">"smooth"</span></a>
|
||||
<a class="sourceLine" id="cb6-7" title="7"> ),</a>
|
||||
<a class="sourceLine" id="cb6-8" title="8"> <span class="dt">grid =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb6-9" title="9"> <span class="dt">borderColor =</span> <span class="st">"#e7e7e7"</span>,</a>
|
||||
<a class="sourceLine" id="cb6-10" title="10"> <span class="dt">row =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb6-11" title="11"> <span class="dt">colors =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="st">"#f3f3f3"</span>, <span class="st">"transparent"</span>),</a>
|
||||
<a class="sourceLine" id="cb6-12" title="12"> <span class="dt">opacity =</span> <span class="fl">0.5</span></a>
|
||||
<a class="sourceLine" id="cb6-13" title="13"> )</a>
|
||||
<a class="sourceLine" id="cb6-14" title="14"> ),</a>
|
||||
<a class="sourceLine" id="cb6-15" title="15"> <span class="dt">dataLabels =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb6-16" title="16"> <span class="dt">enabled =</span> <span class="ot">TRUE</span></a>
|
||||
<a class="sourceLine" id="cb6-17" title="17"> ),</a>
|
||||
<a class="sourceLine" id="cb6-18" title="18"> <span class="dt">markers =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(<span class="dt">style =</span> <span class="st">"inverted"</span>, <span class="dt">size =</span> <span class="dv">6</span>),</a>
|
||||
<a class="sourceLine" id="cb6-19" title="19"> <span class="dt">series =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb6-20" title="20"> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb6-21" title="21"> <span class="dt">name =</span> <span class="st">"High"</span>,</a>
|
||||
<a class="sourceLine" id="cb6-22" title="22"> <span class="dt">data =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="dv">28</span>, <span class="dv">29</span>, <span class="dv">33</span>, <span class="dv">36</span>, <span class="dv">32</span>, <span class="dv">32</span>, <span class="dv">33</span>)</a>
|
||||
<a class="sourceLine" id="cb6-23" title="23"> ),</a>
|
||||
<a class="sourceLine" id="cb6-24" title="24"> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb6-25" title="25"> <span class="dt">name =</span> <span class="st">"Low"</span>,</a>
|
||||
<a class="sourceLine" id="cb6-26" title="26"> <span class="dt">data =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="dv">12</span>, <span class="dv">11</span>, <span class="dv">14</span>, <span class="dv">18</span>, <span class="dv">17</span>, <span class="dv">13</span>, <span class="dv">13</span>)</a>
|
||||
<a class="sourceLine" id="cb6-27" title="27"> )</a>
|
||||
<a class="sourceLine" id="cb6-28" title="28"> ),</a>
|
||||
<a class="sourceLine" id="cb6-29" title="29"> <span class="dt">title =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb6-30" title="30"> <span class="dt">text =</span> <span class="st">"Average High & Low Temperature"</span>,</a>
|
||||
<a class="sourceLine" id="cb6-31" title="31"> <span class="dt">align =</span> <span class="st">"left"</span></a>
|
||||
<a class="sourceLine" id="cb6-32" title="32"> ),</a>
|
||||
<a class="sourceLine" id="cb6-33" title="33"> <span class="dt">xaxis =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb6-34" title="34"> <span class="dt">categories =</span> month.abb[<span class="dv">1</span><span class="op">:</span><span class="dv">7</span>]</a>
|
||||
<a class="sourceLine" id="cb6-35" title="35"> ),</a>
|
||||
<a class="sourceLine" id="cb6-36" title="36"> <span class="dt">yaxis =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb6-37" title="37"> <span class="dt">title =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(<span class="dt">text =</span> <span class="st">"Temperature"</span>),</a>
|
||||
<a class="sourceLine" id="cb6-38" title="38"> <span class="dt">labels =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/list">list</a></span>(</a>
|
||||
<a class="sourceLine" id="cb6-39" title="39"> <span class="dt">formatter =</span> htmlwidgets<span class="op">::</span><span class="kw"><a href="https://www.rdocumentation.org/packages/htmlwidgets/topics/JS">JS</a></span>(<span class="st">"function(value) {return value + '°C';}"</span>)</a>
|
||||
<a class="sourceLine" id="cb6-40" title="40"> )</a>
|
||||
<a class="sourceLine" id="cb6-41" title="41"> )</a>
|
||||
<a class="sourceLine" id="cb6-42" title="42">))</a></code></pre></div>
|
||||
<p><img src="reference/figures/raw-api.png" alt="alt text"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
<div class="links">
|
||||
<h2>Links</h2>
|
||||
<ul class="list-unstyled">
|
||||
<li>Download from CRAN at <br><a href="https://cloud.r-project.org/package=apexcharter">https://cloud.r-project.org/package=apexcharter</a>
|
||||
</li>
|
||||
<li>Browse source code at <br><a href="https://github.com/dreamRs/apexcharter">https://github.com/dreamRs/apexcharter</a>
|
||||
</li>
|
||||
<li>Report a bug at <br><a href="https://github.com/dreamRs/apexcharter/issues">https://github.com/dreamRs/apexcharter/issues</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="license">
|
||||
<h2>License</h2>
|
||||
<ul class="list-unstyled">
|
||||
<li>
|
||||
<a href="https://opensource.org/licenses/mit-license.php">MIT</a> + file <a href="LICENSE-text.html">LICENSE</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="developers">
|
||||
<h2>Developers</h2>
|
||||
<ul class="list-unstyled">
|
||||
<li>
|
||||
<a href="https://twitter.com/_pvictorr"><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"> Victor Perrier</a> <br><small class="roles"> Author, maintainer </small> </li>
|
||||
<li>
|
||||
<a href="https://twitter.com/_mfaan"><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg"> Fanny Meyer</a> <br><small class="roles"> Author </small> </li>
|
||||
<li><a href="authors.html">All authors...</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer><div class="copyright">
|
||||
<p>Developed by <a href="https://twitter.com/_pvictorr"><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"> Victor Perrier</a>, <a href="https://twitter.com/_mfaan"><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg"> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 19.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 20 20" style="enable-background:new 0 0 20 20;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#75AADB;}
|
||||
</style>
|
||||
<path class="st0" d="M4,11.3h1.3v1.3H4c-2,0-4-2.3-4-4.7s2.1-4.7,4-4.7h5.3c1.9,0,4,2.3,4,4.7c0,1.9-1.2,3.6-2.7,4.3v-1.5
|
||||
C11.4,10.2,12,9.1,12,8c0-1.7-1.4-3.3-2.7-3.3H4C2.7,4.7,1.3,6.3,1.3,8S2.7,11.3,4,11.3z M16,7.3h-1.3v1.3H16c1.3,0,2.7,1.6,2.7,3.3
|
||||
s-1.4,3.3-2.7,3.3h-5.3C9.4,15.3,8,13.7,8,12c0-1.1,0.6-2.2,1.3-2.8V7.7C7.9,8.4,6.7,10.1,6.7,12c0,2.4,2.1,4.7,4,4.7H16
|
||||
c1.9,0,4-2.3,4-4.7S18,7.3,16,7.3z"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 810 B |
|
@ -1,170 +0,0 @@
|
|||
<!-- Generated by pkgdown: do not edit by hand -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Changelog • apexcharter</title>
|
||||
|
||||
<!-- jquery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Font Awesome icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
|
||||
|
||||
<!-- clipboard.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- sticky kit -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- pkgdown -->
|
||||
<link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script>
|
||||
|
||||
|
||||
|
||||
<meta property="og:title" content="Changelog" />
|
||||
|
||||
|
||||
|
||||
<!-- mathjax -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container template-news">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!--/.nav-collapse -->
|
||||
</div><!--/.container -->
|
||||
</div><!--/.navbar -->
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>Changelog <small></small></h1>
|
||||
<small>Source: <a href='https://github.com/dreamRs/apexcharter/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
||||
</div>
|
||||
|
||||
<div id="apexcharter-012" class="section level1">
|
||||
<h1 class="page-header">
|
||||
<a href="#apexcharter-012" class="anchor"></a>apexcharter 0.1.2<small> Unreleased </small>
|
||||
</h1>
|
||||
<ul>
|
||||
<li>Update ApexCharts to 3.8.2</li>
|
||||
<li>Set parent container offset to 0 by default (fix <a href="https://github.com/dreamRs/apexcharter/issues/2"><a href='https://github.com/dreamRs/apexcharter/issues/2'>#2</a></a>).</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="apexcharter-011" class="section level1">
|
||||
<h1 class="page-header">
|
||||
<a href="#apexcharter-011" class="anchor"></a>apexcharter 0.1.1<small> 2019-07-28 </small>
|
||||
</h1>
|
||||
<ul>
|
||||
<li>First CRAN release: create interactive chart with the JavaScript ‘ApexCharts’ library. Types of graphics available : bars, columns, splines, lines, scatter, pie, donuts, heatmap, gauge.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
<div id="tocnav">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#apexcharter-012">0.1.2</a></li>
|
||||
<li><a href="#apexcharter-011">0.1.1</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://twitter.com/_pvictorr'><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"/> Victor Perrier</a>, <a href='https://twitter.com/_mfaan'><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg" /> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
236
docs/pkgdown.css
236
docs/pkgdown.css
|
@ -1,236 +0,0 @@
|
|||
/* Sticky footer */
|
||||
|
||||
/**
|
||||
* Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/
|
||||
* Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css
|
||||
*
|
||||
* .Site -> body > .container
|
||||
* .Site-content -> body > .container .row
|
||||
* .footer -> footer
|
||||
*
|
||||
* Key idea seems to be to ensure that .container and __all its parents__
|
||||
* have height set to 100%
|
||||
*
|
||||
*/
|
||||
|
||||
html, body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body > .container {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
flex-direction: column;
|
||||
|
||||
padding-top: 60px;
|
||||
}
|
||||
|
||||
body > .container .row {
|
||||
flex: 1 0 auto;
|
||||
}
|
||||
|
||||
footer {
|
||||
margin-top: 45px;
|
||||
padding: 35px 0 36px;
|
||||
border-top: 1px solid #e5e5e5;
|
||||
color: #666;
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
footer p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
footer div {
|
||||
flex: 1;
|
||||
}
|
||||
footer .pkgdown {
|
||||
text-align: right;
|
||||
}
|
||||
footer p {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
img.icon {
|
||||
float: right;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* Fix bug in bootstrap (only seen in firefox) */
|
||||
summary {
|
||||
display: list-item;
|
||||
}
|
||||
|
||||
/* Typographic tweaking ---------------------------------*/
|
||||
|
||||
.contents .page-header {
|
||||
margin-top: calc(-60px + 1em);
|
||||
}
|
||||
|
||||
/* Section anchors ---------------------------------*/
|
||||
|
||||
a.anchor {
|
||||
margin-left: -30px;
|
||||
display:inline-block;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
visibility: hidden;
|
||||
|
||||
background-image: url(./link.svg);
|
||||
background-repeat: no-repeat;
|
||||
background-size: 20px 20px;
|
||||
background-position: center center;
|
||||
}
|
||||
|
||||
.hasAnchor:hover a.anchor {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.hasAnchor:hover a.anchor {
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Fixes for fixed navbar --------------------------*/
|
||||
|
||||
.contents h1, .contents h2, .contents h3, .contents h4 {
|
||||
padding-top: 60px;
|
||||
margin-top: -40px;
|
||||
}
|
||||
|
||||
/* Static header placement on mobile devices */
|
||||
@media (max-width: 767px) {
|
||||
.navbar-fixed-top {
|
||||
position: absolute;
|
||||
}
|
||||
.navbar {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Sidebar --------------------------*/
|
||||
|
||||
#sidebar {
|
||||
margin-top: 30px;
|
||||
}
|
||||
#sidebar h2 {
|
||||
font-size: 1.5em;
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
#sidebar h2:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
#sidebar .list-unstyled li {
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.orcid {
|
||||
height: 16px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* Reference index & topics ----------------------------------------------- */
|
||||
|
||||
.ref-index th {font-weight: normal;}
|
||||
|
||||
.ref-index td {vertical-align: top;}
|
||||
.ref-index .icon {width: 40px;}
|
||||
.ref-index .alias {width: 40%;}
|
||||
.ref-index-icons .alias {width: calc(40% - 40px);}
|
||||
.ref-index .title {width: 60%;}
|
||||
|
||||
.ref-arguments th {text-align: right; padding-right: 10px;}
|
||||
.ref-arguments th, .ref-arguments td {vertical-align: top;}
|
||||
.ref-arguments .name {width: 20%;}
|
||||
.ref-arguments .desc {width: 80%;}
|
||||
|
||||
/* Nice scrolling for wide elements --------------------------------------- */
|
||||
|
||||
table {
|
||||
display: block;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* Syntax highlighting ---------------------------------------------------- */
|
||||
|
||||
pre {
|
||||
word-wrap: normal;
|
||||
word-break: normal;
|
||||
border: 1px solid #eee;
|
||||
}
|
||||
|
||||
pre, code {
|
||||
background-color: #f8f8f8;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
pre code {
|
||||
overflow: auto;
|
||||
word-wrap: normal;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
pre .img {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
pre .img img {
|
||||
background-color: #fff;
|
||||
display: block;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
code a, pre a {
|
||||
color: #375f84;
|
||||
}
|
||||
|
||||
a.sourceLine:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.fl {color: #1514b5;}
|
||||
.fu {color: #000000;} /* function */
|
||||
.ch,.st {color: #036a07;} /* string */
|
||||
.kw {color: #264D66;} /* keyword */
|
||||
.co {color: #888888;} /* comment */
|
||||
|
||||
.message { color: black; font-weight: bolder;}
|
||||
.error { color: orange; font-weight: bolder;}
|
||||
.warning { color: #6A0366; font-weight: bolder;}
|
||||
|
||||
/* Clipboard --------------------------*/
|
||||
|
||||
.hasCopyButton {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.btn-copy-ex {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.hasCopyButton:hover button.btn-copy-ex {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
/* mark.js ----------------------------*/
|
||||
|
||||
mark {
|
||||
background-color: rgba(255, 255, 51, 0.5);
|
||||
border-bottom: 2px solid rgba(255, 153, 51, 0.3);
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
/* vertical spacing after htmlwidgets */
|
||||
.html-widget {
|
||||
margin-bottom: 10px;
|
||||
}
|
115
docs/pkgdown.js
115
docs/pkgdown.js
|
@ -1,115 +0,0 @@
|
|||
/* http://gregfranko.com/blog/jquery-best-practices/ */
|
||||
(function($) {
|
||||
$(function() {
|
||||
|
||||
$("#sidebar")
|
||||
.stick_in_parent({offset_top: 40})
|
||||
.on('sticky_kit:bottom', function(e) {
|
||||
$(this).parent().css('position', 'static');
|
||||
})
|
||||
.on('sticky_kit:unbottom', function(e) {
|
||||
$(this).parent().css('position', 'relative');
|
||||
});
|
||||
|
||||
$('body').scrollspy({
|
||||
target: '#sidebar',
|
||||
offset: 60
|
||||
});
|
||||
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
|
||||
var cur_path = paths(location.pathname);
|
||||
var links = $("#navbar ul li a");
|
||||
var max_length = -1;
|
||||
var pos = -1;
|
||||
for (var i = 0; i < links.length; i++) {
|
||||
if (links[i].getAttribute("href") === "#")
|
||||
continue;
|
||||
// Ignore external links
|
||||
if (links[i].host !== location.host)
|
||||
continue;
|
||||
|
||||
var nav_path = paths(links[i].pathname);
|
||||
|
||||
var length = prefix_length(nav_path, cur_path);
|
||||
if (length > max_length) {
|
||||
max_length = length;
|
||||
pos = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Add class to parent <li>, and enclosing <li> if in dropdown
|
||||
if (pos >= 0) {
|
||||
var menu_anchor = $(links[pos]);
|
||||
menu_anchor.parent().addClass("active");
|
||||
menu_anchor.closest("li.dropdown").addClass("active");
|
||||
}
|
||||
});
|
||||
|
||||
function paths(pathname) {
|
||||
var pieces = pathname.split("/");
|
||||
pieces.shift(); // always starts with /
|
||||
|
||||
var end = pieces[pieces.length - 1];
|
||||
if (end === "index.html" || end === "")
|
||||
pieces.pop();
|
||||
return(pieces);
|
||||
}
|
||||
|
||||
// Returns -1 if not found
|
||||
function prefix_length(needle, haystack) {
|
||||
if (needle.length > haystack.length)
|
||||
return(-1);
|
||||
|
||||
// Special case for length-0 haystack, since for loop won't run
|
||||
if (haystack.length === 0) {
|
||||
return(needle.length === 0 ? 0 : -1);
|
||||
}
|
||||
|
||||
for (var i = 0; i < haystack.length; i++) {
|
||||
if (needle[i] != haystack[i])
|
||||
return(i);
|
||||
}
|
||||
|
||||
return(haystack.length);
|
||||
}
|
||||
|
||||
/* Clipboard --------------------------*/
|
||||
|
||||
function changeTooltipMessage(element, msg) {
|
||||
var tooltipOriginalTitle=element.getAttribute('data-original-title');
|
||||
element.setAttribute('data-original-title', msg);
|
||||
$(element).tooltip('show');
|
||||
element.setAttribute('data-original-title', tooltipOriginalTitle);
|
||||
}
|
||||
|
||||
if(ClipboardJS.isSupported()) {
|
||||
$(document).ready(function() {
|
||||
var copyButton = "<button type='button' class='btn btn-primary btn-copy-ex' type = 'submit' title='Copy to clipboard' aria-label='Copy to clipboard' data-toggle='tooltip' data-placement='left auto' data-trigger='hover' data-clipboard-copy><i class='fa fa-copy'></i></button>";
|
||||
|
||||
$(".examples, div.sourceCode").addClass("hasCopyButton");
|
||||
|
||||
// Insert copy buttons:
|
||||
$(copyButton).prependTo(".hasCopyButton");
|
||||
|
||||
// Initialize tooltips:
|
||||
$('.btn-copy-ex').tooltip({container: 'body'});
|
||||
|
||||
// Initialize clipboard:
|
||||
var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', {
|
||||
text: function(trigger) {
|
||||
return trigger.parentNode.textContent;
|
||||
}
|
||||
});
|
||||
|
||||
clipboardBtnCopies.on('success', function(e) {
|
||||
changeTooltipMessage(e.trigger, 'Copied!');
|
||||
e.clearSelection();
|
||||
});
|
||||
|
||||
clipboardBtnCopies.on('error', function() {
|
||||
changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy');
|
||||
});
|
||||
});
|
||||
}
|
||||
})(window.jQuery || window.$)
|
|
@ -1,8 +0,0 @@
|
|||
pandoc: 2.7.2
|
||||
pkgdown: 1.3.0
|
||||
pkgdown_sha: ~
|
||||
articles:
|
||||
labs: labs.html
|
||||
lines: lines.html
|
||||
starting-with-apexcharts: starting-with-apexcharts.html
|
||||
|
|
@ -1,252 +0,0 @@
|
|||
<!-- Generated by pkgdown: do not edit by hand -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Quick ApexChart — apex • apexcharter</title>
|
||||
|
||||
<!-- jquery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Font Awesome icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
|
||||
|
||||
<!-- clipboard.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- sticky kit -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- pkgdown -->
|
||||
<link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script>
|
||||
|
||||
|
||||
|
||||
<meta property="og:title" content="Quick ApexChart — apex" />
|
||||
|
||||
<meta property="og:description" content="Initialize a chart with three main parameters : data, mapping and type of chart." />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
|
||||
|
||||
|
||||
<!-- mathjax -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container template-reference-topic">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!--/.nav-collapse -->
|
||||
</div><!--/.container -->
|
||||
</div><!--/.navbar -->
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>Quick ApexChart</h1>
|
||||
<small class="dont-index">Source: <a href='https://github.com/dreamRs/apexcharter/blob/master/R/apex.R'><code>R/apex.R</code></a></small>
|
||||
<div class="hidden name"><code>apex.Rd</code></div>
|
||||
</div>
|
||||
|
||||
<div class="ref-description">
|
||||
|
||||
<p>Initialize a chart with three main parameters : data, mapping and type of chart.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<pre class="usage"><span class='fu'>apex</span>(<span class='no'>data</span>, <span class='no'>mapping</span>, <span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"column"</span>, <span class='no'>...</span>, <span class='kw'>auto_update</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
|
||||
<span class='kw'>width</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>height</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>elementId</span> <span class='kw'>=</span> <span class='kw'>NULL</span>)</pre>
|
||||
|
||||
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
|
||||
<table class="ref-arguments">
|
||||
<colgroup><col class="name" /><col class="desc" /></colgroup>
|
||||
<tr>
|
||||
<th>data</th>
|
||||
<td><p>Default dataset to use for chart. If not already a <code>data.frame</code>, it will be coerced to with <code>as.data.frame</code>.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>mapping</th>
|
||||
<td><p>Default list of aesthetic mappings to use for chart</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>type</th>
|
||||
<td><p>Specify the chart type. Available Options: <code>"column"</code>, <code>"bar"</code>, <code>"line"</code>,
|
||||
<code>"area"</code>, <code>"spline"</code>, <code>"pie"</code>, <code>"donut"</code>, <code>"radialBar"</code>, <code>"radar"</code>, <code>"scatter"</code>, <code>"heatmap"</code>.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>...</th>
|
||||
<td><p>Other arguments passed on to methods. Not currently used.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>auto_update</th>
|
||||
<td><p>In Shiny application, update existing chart rather than generating new one.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>width</th>
|
||||
<td><p>A numeric input in pixels.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>height</th>
|
||||
<td><p>A numeric input in pixels.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>elementId</th>
|
||||
<td><p>Use an explicit element ID for the widget.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
|
||||
|
||||
<p>A <code>apexcharts</code> <code>htmlwidget</code> object.</p>
|
||||
|
||||
|
||||
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
|
||||
<pre class="examples"><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)</div><div class='output co'>#> <span class='message'></span>
|
||||
#> <span class='message'>Attachement du package : 'dplyr'</span></div><div class='output co'>#> <span class='message'>The following object is masked from 'package:testthat':</span>
|
||||
#> <span class='message'></span>
|
||||
#> <span class='message'> matches</span></div><div class='output co'>#> <span class='message'>The following objects are masked from 'package:stats':</span>
|
||||
#> <span class='message'></span>
|
||||
#> <span class='message'> filter, lag</span></div><div class='output co'>#> <span class='message'>The following objects are masked from 'package:base':</span>
|
||||
#> <span class='message'></span>
|
||||
#> <span class='message'> intersect, setdiff, setequal, union</span></div><div class='input'>
|
||||
|
||||
<span class='co'># make a barchart with a frequency table</span>
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/utils/topics/data'>data</a></span>(<span class='st'>"mpg"</span>, <span class='kw'>package</span> <span class='kw'>=</span> <span class='st'>"ggplot2"</span>)
|
||||
<span class='fu'>apex</span>(
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/tally.html'>count</a></span>(<span class='no'>mpg</span>, <span class='no'>manufacturer</span>),
|
||||
<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='fu'><a href='apexcharter-exports.html'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>manufacturer</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>n</span>),
|
||||
<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"bar"</span>
|
||||
)
|
||||
|
||||
<span class='co'># timeseries</span>
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/utils/topics/data'>data</a></span>(<span class='st'>"economics"</span>, <span class='kw'>package</span> <span class='kw'>=</span> <span class='st'>"ggplot2"</span>)
|
||||
<span class='fu'>apex</span>(
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='no'>economics</span>,
|
||||
<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='fu'><a href='apexcharter-exports.html'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>date</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>uempmed</span>),
|
||||
<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"line"</span>
|
||||
)
|
||||
|
||||
<span class='co'># you can add option to apex result :</span>
|
||||
<span class='fu'>apex</span>(
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='no'>economics</span>,
|
||||
<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='fu'><a href='apexcharter-exports.html'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>date</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>uempmed</span>),
|
||||
<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"line"</span>
|
||||
) <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='ax_stroke.html'>ax_stroke</a></span>(<span class='kw'>width</span> <span class='kw'>=</span> <span class='fl'>1</span>)
|
||||
|
||||
|
||||
|
||||
<span class='co'># with group variable</span>
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/utils/topics/data'>data</a></span>(<span class='st'>"economics_long"</span>, <span class='kw'>package</span> <span class='kw'>=</span> <span class='st'>"ggplot2"</span>)
|
||||
<span class='fu'>apex</span>(
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='no'>economics_long</span>,
|
||||
<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='fu'><a href='apexcharter-exports.html'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>date</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>value01</span>, <span class='kw'>group</span> <span class='kw'>=</span> <span class='no'>variable</span>),
|
||||
<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"line"</span>
|
||||
)</div></pre>
|
||||
</div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#arguments">Arguments</a></li>
|
||||
|
||||
<li><a href="#value">Value</a></li>
|
||||
|
||||
<li><a href="#examples">Examples</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://twitter.com/_pvictorr'><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"/> Victor Perrier</a>, <a href='https://twitter.com/_mfaan'><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg" /> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,231 +0,0 @@
|
|||
<!-- Generated by pkgdown: do not edit by hand -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Create a apexcharts.js widget — apexchart • apexcharter</title>
|
||||
|
||||
<!-- jquery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Font Awesome icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
|
||||
|
||||
<!-- clipboard.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- sticky kit -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- pkgdown -->
|
||||
<link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script>
|
||||
|
||||
|
||||
|
||||
<meta property="og:title" content="Create a apexcharts.js widget — apexchart" />
|
||||
|
||||
<meta property="og:description" content="Create a apexcharts.js widget" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
|
||||
|
||||
|
||||
<!-- mathjax -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container template-reference-topic">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!--/.nav-collapse -->
|
||||
</div><!--/.container -->
|
||||
</div><!--/.navbar -->
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>Create a apexcharts.js widget</h1>
|
||||
<small class="dont-index">Source: <a href='https://github.com/dreamRs/apexcharter/blob/master/R/apexcharter.R'><code>R/apexcharter.R</code></a></small>
|
||||
<div class="hidden name"><code>apexchart.Rd</code></div>
|
||||
</div>
|
||||
|
||||
<div class="ref-description">
|
||||
|
||||
<p>Create a apexcharts.js widget</p>
|
||||
|
||||
</div>
|
||||
|
||||
<pre class="usage"><span class='fu'>apexchart</span>(<span class='kw'>ax_opts</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(), <span class='kw'>auto_update</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>width</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
|
||||
<span class='kw'>height</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>elementId</span> <span class='kw'>=</span> <span class='kw'>NULL</span>)</pre>
|
||||
|
||||
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
|
||||
<table class="ref-arguments">
|
||||
<colgroup><col class="name" /><col class="desc" /></colgroup>
|
||||
<tr>
|
||||
<th>ax_opts</th>
|
||||
<td><p>A <code>list</code> in JSON format with chart parameters.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>auto_update</th>
|
||||
<td><p>In Shiny application, update existing chart rather than generating new one.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>width</th>
|
||||
<td><p>A numeric input in pixels.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>height</th>
|
||||
<td><p>A numeric input in pixels.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>elementId</th>
|
||||
<td><p>Use an explicit element ID for the widget.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
|
||||
|
||||
<p>A <code>apexcharts</code> <code>htmlwidget</code> object.</p>
|
||||
|
||||
|
||||
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
|
||||
<pre class="examples"><div class='input'>
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>apexcharter</span>)
|
||||
|
||||
<span class='co'># Use raw API by passing a list of</span>
|
||||
<span class='co'># parameters to the function</span>
|
||||
|
||||
<span class='fu'>apexchart</span>(<span class='kw'>ax_opts</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>chart</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"bar"</span>
|
||||
),
|
||||
<span class='kw'>series</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>name</span> <span class='kw'>=</span> <span class='st'>"Example"</span>,
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/sample'>sample</a></span>(<span class='fl'>1</span>:<span class='fl'>100</span>, <span class='fl'>5</span>)
|
||||
)),
|
||||
<span class='kw'>xaxis</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>categories</span> <span class='kw'>=</span> <span class='no'>LETTERS</span>[<span class='fl'>1</span>:<span class='fl'>5</span>]
|
||||
)
|
||||
))
|
||||
|
||||
|
||||
<span class='co'># Or use apexchart() to initialize the chart</span>
|
||||
<span class='co'># before passing parameters</span>
|
||||
|
||||
<span class='fu'>apexchart</span>() <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='ax_chart.html'>ax_chart</a></span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"bar"</span>) <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='ax-series.html'>ax_series</a></span>(
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>name</span> <span class='kw'>=</span> <span class='st'>"Example"</span>,
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/sample'>sample</a></span>(<span class='fl'>1</span>:<span class='fl'>100</span>, <span class='fl'>5</span>)
|
||||
)
|
||||
) <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='ax_xaxis.html'>ax_xaxis</a></span>(
|
||||
<span class='kw'>categories</span> <span class='kw'>=</span> <span class='no'>LETTERS</span>[<span class='fl'>1</span>:<span class='fl'>5</span>]
|
||||
)</div></pre>
|
||||
</div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#arguments">Arguments</a></li>
|
||||
|
||||
<li><a href="#value">Value</a></li>
|
||||
|
||||
<li><a href="#examples">Examples</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://twitter.com/_pvictorr'><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"/> Victor Perrier</a>, <a href='https://twitter.com/_mfaan'><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg" /> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,178 +0,0 @@
|
|||
<!-- Generated by pkgdown: do not edit by hand -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Proxy for <code>apexchart</code> — apexchartProxy • apexcharter</title>
|
||||
|
||||
<!-- jquery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Font Awesome icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
|
||||
|
||||
<!-- clipboard.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- sticky kit -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- pkgdown -->
|
||||
<link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script>
|
||||
|
||||
|
||||
|
||||
<meta property="og:title" content="Proxy for <code>apexchart</code> — apexchartProxy" />
|
||||
|
||||
<meta property="og:description" content="Allow to update a chart in Shiny application." />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
|
||||
|
||||
|
||||
<!-- mathjax -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container template-reference-topic">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!--/.nav-collapse -->
|
||||
</div><!--/.container -->
|
||||
</div><!--/.navbar -->
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>Proxy for <code>apexchart</code></h1>
|
||||
<small class="dont-index">Source: <a href='https://github.com/dreamRs/apexcharter/blob/master/R/proxy.R'><code>R/proxy.R</code></a></small>
|
||||
<div class="hidden name"><code>apexchartProxy.Rd</code></div>
|
||||
</div>
|
||||
|
||||
<div class="ref-description">
|
||||
|
||||
<p>Allow to update a chart in Shiny application.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<pre class="usage"><span class='fu'>apexchartProxy</span>(<span class='no'>shinyId</span>, <span class='kw'>session</span> <span class='kw'>=</span> <span class='kw pkg'>shiny</span><span class='kw ns'>::</span><span class='fu'><a href='https://www.rdocumentation.org/packages/shiny/topics/domains'>getDefaultReactiveDomain</a></span>())</pre>
|
||||
|
||||
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
|
||||
<table class="ref-arguments">
|
||||
<colgroup><col class="name" /><col class="desc" /></colgroup>
|
||||
<tr>
|
||||
<th>shinyId</th>
|
||||
<td><p>single-element character vector indicating the output ID of the
|
||||
chart to modify (if invoked from a Shiny module, the namespace will be added
|
||||
automatically)</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>session</th>
|
||||
<td><p>the Shiny session object to which the chart belongs; usually the
|
||||
default value will suffice</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#arguments">Arguments</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://twitter.com/_pvictorr'><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"/> Victor Perrier</a>, <a href='https://twitter.com/_mfaan'><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg" /> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,164 +0,0 @@
|
|||
<!-- Generated by pkgdown: do not edit by hand -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>apexcharter exported operators and S3 methods — apexcharter-exports • apexcharter</title>
|
||||
|
||||
<!-- jquery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Font Awesome icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
|
||||
|
||||
<!-- clipboard.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- sticky kit -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- pkgdown -->
|
||||
<link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script>
|
||||
|
||||
|
||||
|
||||
<meta property="og:title" content="apexcharter exported operators and S3 methods — apexcharter-exports" />
|
||||
|
||||
<meta property="og:description" content="The following functions are imported and then re-exported
|
||||
from the apexcharter package to avoid listing the magrittr
|
||||
as Depends of apexcharter" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
|
||||
|
||||
|
||||
<!-- mathjax -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container template-reference-topic">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!--/.nav-collapse -->
|
||||
</div><!--/.container -->
|
||||
</div><!--/.navbar -->
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>apexcharter exported operators and S3 methods</h1>
|
||||
<small class="dont-index">Source: <a href='https://github.com/dreamRs/apexcharter/blob/master/R/apexcharter-package.R'><code>R/apexcharter-package.R</code></a></small>
|
||||
<div class="hidden name"><code>apexcharter-exports.Rd</code></div>
|
||||
</div>
|
||||
|
||||
<div class="ref-description">
|
||||
|
||||
<p>The following functions are imported and then re-exported
|
||||
from the apexcharter package to avoid listing the magrittr
|
||||
as Depends of apexcharter</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://twitter.com/_pvictorr'><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"/> Victor Perrier</a>, <a href='https://twitter.com/_mfaan'><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg" /> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,167 +0,0 @@
|
|||
<!-- Generated by pkgdown: do not edit by hand -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>An <code>htmlwidget</code> interface to the
|
||||
ApexCharts javascript chart library — apexcharter-package • apexcharter</title>
|
||||
|
||||
<!-- jquery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Font Awesome icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
|
||||
|
||||
<!-- clipboard.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- sticky kit -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- pkgdown -->
|
||||
<link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script>
|
||||
|
||||
|
||||
|
||||
<meta property="og:title" content="An <code>htmlwidget</code> interface to the
|
||||
ApexCharts javascript chart library — apexcharter-package" />
|
||||
|
||||
<meta property="og:description" content="This package allow you to use ApexCharts.js (https://apexcharts.com/),
|
||||
to create interactive and modern SVG charts." />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
|
||||
|
||||
|
||||
<!-- mathjax -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container template-reference-topic">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!--/.nav-collapse -->
|
||||
</div><!--/.container -->
|
||||
</div><!--/.navbar -->
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>An <code>htmlwidget</code> interface to the
|
||||
ApexCharts javascript chart library</h1>
|
||||
<small class="dont-index">Source: <a href='https://github.com/dreamRs/apexcharter/blob/master/R/apexcharter-package.R'><code>R/apexcharter-package.R</code></a></small>
|
||||
<div class="hidden name"><code>apexcharter-package.Rd</code></div>
|
||||
</div>
|
||||
|
||||
<div class="ref-description">
|
||||
|
||||
<p>This package allow you to use ApexCharts.js (<a href='https://apexcharts.com/'>https://apexcharts.com/</a>),
|
||||
to create interactive and modern SVG charts.</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
</ul>
|
||||
|
||||
<h2>Author</h2>
|
||||
<p>Victor Perrier (@dreamRs_fr)</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://twitter.com/_pvictorr'><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"/> Victor Perrier</a>, <a href='https://twitter.com/_mfaan'><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg" /> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,239 +0,0 @@
|
|||
<!-- Generated by pkgdown: do not edit by hand -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Shiny bindings for apexcharter — apexcharter-shiny • apexcharter</title>
|
||||
|
||||
<!-- jquery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Font Awesome icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
|
||||
|
||||
<!-- clipboard.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- sticky kit -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- pkgdown -->
|
||||
<link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script>
|
||||
|
||||
|
||||
|
||||
<meta property="og:title" content="Shiny bindings for apexcharter — apexcharter-shiny" />
|
||||
|
||||
<meta property="og:description" content="Output and render functions for using apexcharter within Shiny
|
||||
applications and interactive Rmd documents." />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
|
||||
|
||||
|
||||
<!-- mathjax -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container template-reference-topic">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!--/.nav-collapse -->
|
||||
</div><!--/.container -->
|
||||
</div><!--/.navbar -->
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>Shiny bindings for apexcharter</h1>
|
||||
<small class="dont-index">Source: <a href='https://github.com/dreamRs/apexcharter/blob/master/R/apexcharter.R'><code>R/apexcharter.R</code></a></small>
|
||||
<div class="hidden name"><code>apexcharter-shiny.Rd</code></div>
|
||||
</div>
|
||||
|
||||
<div class="ref-description">
|
||||
|
||||
<p>Output and render functions for using apexcharter within Shiny
|
||||
applications and interactive Rmd documents.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<pre class="usage"><span class='fu'>apexchartOutput</span>(<span class='no'>outputId</span>, <span class='kw'>width</span> <span class='kw'>=</span> <span class='st'>"100%"</span>, <span class='kw'>height</span> <span class='kw'>=</span> <span class='st'>"400px"</span>)
|
||||
|
||||
<span class='fu'>renderApexchart</span>(<span class='no'>expr</span>, <span class='kw'>env</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/sys.parent'>parent.frame</a></span>(), <span class='kw'>quoted</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</pre>
|
||||
|
||||
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
|
||||
<table class="ref-arguments">
|
||||
<colgroup><col class="name" /><col class="desc" /></colgroup>
|
||||
<tr>
|
||||
<th>outputId</th>
|
||||
<td><p>output variable to read from</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>width, height</th>
|
||||
<td><p>Must be a valid CSS unit (like <code>'100%'</code>,
|
||||
<code>'400px'</code>, <code>'auto'</code>) or a number, which will be coerced to a
|
||||
string and have <code>'px'</code> appended.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>expr</th>
|
||||
<td><p>An expression that generates a apexcharter</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>env</th>
|
||||
<td><p>The environment in which to evaluate <code>expr</code>.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>quoted</th>
|
||||
<td><p>Is <code>expr</code> a quoted expression (with <code><a href='https://www.rdocumentation.org/packages/base/topics/substitute'>quote()</a></code>)? This
|
||||
is useful if you want to save an expression in a variable.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
|
||||
|
||||
<p>An Apexchart output that can be included in the application UI.</p>
|
||||
|
||||
|
||||
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
|
||||
<pre class="examples"><div class='input'>
|
||||
<span class='kw'>if</span> (<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/interactive'>interactive</a></span>()) {
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>shiny</span>)
|
||||
|
||||
<span class='no'>ui</span> <span class='kw'><-</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/shiny/topics/fluidPage'>fluidPage</a></span>(
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/shiny/topics/fluidPage'>fluidRow</a></span>(
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/shiny/topics/column'>column</a></span>(
|
||||
<span class='kw'>width</span> <span class='kw'>=</span> <span class='fl'>8</span>, <span class='kw'>offset</span> <span class='kw'>=</span> <span class='fl'>2</span>,
|
||||
<span class='no'>tags</span>$<span class='fu'><a href='https://www.rdocumentation.org/packages/shiny/topics/builder'>h2</a></span>(<span class='st'>"Apexchart in Shiny"</span>),
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/shiny/topics/actionButton'>actionButton</a></span>(<span class='st'>"redraw"</span>, <span class='st'>"Redraw chart"</span>),
|
||||
<span class='fu'>apexchartOutput</span>(<span class='st'>"chart"</span>)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
<span class='no'>server</span> <span class='kw'><-</span> <span class='kw'>function</span>(<span class='no'>input</span>, <span class='no'>output</span>, <span class='no'>session</span>) {
|
||||
|
||||
<span class='no'>output</span>$<span class='no'>chart</span> <span class='kw'><-</span> <span class='fu'>renderApexchart</span>({
|
||||
<span class='no'>input</span>$<span class='no'>redraw</span>
|
||||
<span class='fu'><a href='apexchart.html'>apexchart</a></span>() <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='ax_chart.html'>ax_chart</a></span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"bar"</span>) <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='ax-series.html'>ax_series</a></span>(
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>name</span> <span class='kw'>=</span> <span class='st'>"Example"</span>,
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/sample'>sample</a></span>(<span class='fl'>1</span>:<span class='fl'>100</span>, <span class='fl'>5</span>)
|
||||
)
|
||||
) <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='ax_xaxis.html'>ax_xaxis</a></span>(
|
||||
<span class='kw'>categories</span> <span class='kw'>=</span> <span class='no'>LETTERS</span>[<span class='fl'>1</span>:<span class='fl'>5</span>]
|
||||
)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/shiny/topics/shinyApp'>shinyApp</a></span>(<span class='no'>ui</span>, <span class='no'>server</span>)
|
||||
}</div></pre>
|
||||
</div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#arguments">Arguments</a></li>
|
||||
|
||||
<li><a href="#value">Value</a></li>
|
||||
|
||||
<li><a href="#examples">Examples</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://twitter.com/_pvictorr'><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"/> Victor Perrier</a>, <a href='https://twitter.com/_mfaan'><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg" /> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,210 +0,0 @@
|
|||
<!-- Generated by pkgdown: do not edit by hand -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Add data to a chart — ax-series • apexcharter</title>
|
||||
|
||||
<!-- jquery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Font Awesome icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
|
||||
|
||||
<!-- clipboard.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- sticky kit -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- pkgdown -->
|
||||
<link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script>
|
||||
|
||||
|
||||
|
||||
<meta property="og:title" content="Add data to a chart — ax-series" />
|
||||
|
||||
<meta property="og:description" content="Add data to a chart" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
|
||||
|
||||
|
||||
<!-- mathjax -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container template-reference-topic">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!--/.nav-collapse -->
|
||||
</div><!--/.container -->
|
||||
</div><!--/.navbar -->
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>Add data to a chart</h1>
|
||||
<small class="dont-index">Source: <a href='https://github.com/dreamRs/apexcharter/blob/master/R/apex-utils.R'><code>R/apex-utils.R</code></a></small>
|
||||
<div class="hidden name"><code>ax-series.Rd</code></div>
|
||||
</div>
|
||||
|
||||
<div class="ref-description">
|
||||
|
||||
<p>Add data to a chart</p>
|
||||
|
||||
</div>
|
||||
|
||||
<pre class="usage"><span class='fu'>ax_series</span>(<span class='no'>ax</span>, <span class='no'>...</span>)
|
||||
|
||||
<span class='fu'>ax_series2</span>(<span class='no'>ax</span>, <span class='no'>l</span>)</pre>
|
||||
|
||||
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
|
||||
<table class="ref-arguments">
|
||||
<colgroup><col class="name" /><col class="desc" /></colgroup>
|
||||
<tr>
|
||||
<th>ax</th>
|
||||
<td><p>A <code>apexcharts</code> <code>htmlwidget</code> object.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>...</th>
|
||||
<td><p>Lists containing data to plot, typically list with two items: <code>name</code> and <code>data</code>.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>l</th>
|
||||
<td><p>A list.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
|
||||
|
||||
<p>A <code>apexcharts</code> <code>htmlwidget</code> object.</p>
|
||||
|
||||
|
||||
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
|
||||
<pre class="examples"><div class='input'>
|
||||
<span class='co'># One serie</span>
|
||||
<span class='fu'><a href='apexchart.html'>apexchart</a></span>() <span class='kw'>%>%</span>
|
||||
<span class='fu'>ax_series</span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>name</span> <span class='kw'>=</span> <span class='st'>"rnorm"</span>,
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/stats/topics/Normal'>rnorm</a></span>(<span class='fl'>10</span>)
|
||||
))
|
||||
|
||||
<span class='co'># Two series</span>
|
||||
<span class='fu'><a href='apexchart.html'>apexchart</a></span>() <span class='kw'>%>%</span>
|
||||
<span class='fu'>ax_series</span>(
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>name</span> <span class='kw'>=</span> <span class='st'>"rnorm 1"</span>,
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/stats/topics/Normal'>rnorm</a></span>(<span class='fl'>10</span>)
|
||||
),
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>name</span> <span class='kw'>=</span> <span class='st'>"rnorm 2"</span>,
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/stats/topics/Normal'>rnorm</a></span>(<span class='fl'>10</span>)
|
||||
)
|
||||
)</div></pre>
|
||||
</div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#arguments">Arguments</a></li>
|
||||
|
||||
<li><a href="#value">Value</a></li>
|
||||
|
||||
<li><a href="#examples">Examples</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://twitter.com/_pvictorr'><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"/> Victor Perrier</a>, <a href='https://twitter.com/_mfaan'><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg" /> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,303 +0,0 @@
|
|||
<!-- Generated by pkgdown: do not edit by hand -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Annotations properties — ax_annotations • apexcharter</title>
|
||||
|
||||
<!-- jquery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Font Awesome icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
|
||||
|
||||
<!-- clipboard.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- sticky kit -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- pkgdown -->
|
||||
<link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script>
|
||||
|
||||
|
||||
|
||||
<meta property="og:title" content="Annotations properties — ax_annotations" />
|
||||
|
||||
<meta property="og:description" content="Annotations properties" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
|
||||
|
||||
|
||||
<!-- mathjax -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container template-reference-topic">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!--/.nav-collapse -->
|
||||
</div><!--/.container -->
|
||||
</div><!--/.navbar -->
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>Annotations properties</h1>
|
||||
<small class="dont-index">Source: <a href='https://github.com/dreamRs/apexcharter/blob/master/R/apex-utils.R'><code>R/apex-utils.R</code></a></small>
|
||||
<div class="hidden name"><code>ax_annotations.Rd</code></div>
|
||||
</div>
|
||||
|
||||
<div class="ref-description">
|
||||
|
||||
<p>Annotations properties</p>
|
||||
|
||||
</div>
|
||||
|
||||
<pre class="usage"><span class='fu'>ax_annotations</span>(<span class='no'>ax</span>, <span class='kw'>position</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>yaxis</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>xaxis</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
|
||||
<span class='kw'>points</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='no'>...</span>)</pre>
|
||||
|
||||
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
|
||||
<table class="ref-arguments">
|
||||
<colgroup><col class="name" /><col class="desc" /></colgroup>
|
||||
<tr>
|
||||
<th>ax</th>
|
||||
<td><p>A <code>apexcharts</code> <code>htmlwidget</code> object.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>position</th>
|
||||
<td><p>Whether to put the annotations behind the charts or in front of it. Available Options: <code>"front"</code> or <code>"back"</code>.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>yaxis</th>
|
||||
<td><p>List of lists.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>xaxis</th>
|
||||
<td><p>List of lists.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>points</th>
|
||||
<td><p>List of lists.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>...</th>
|
||||
<td><p>Additional parameters.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
|
||||
|
||||
<p>A <code>apexcharts</code> <code>htmlwidget</code> object.</p>
|
||||
|
||||
<h2 class="hasAnchor" id="note"><a class="anchor" href="#note"></a>Note</h2>
|
||||
|
||||
<p>See <a href='https://apexcharts.com/docs/options/annotations/'>https://apexcharts.com/docs/options/annotations/</a>.</p>
|
||||
|
||||
|
||||
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
|
||||
<pre class="examples"><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/utils/topics/data'>data</a></span>(<span class='st'>"economics"</span>, <span class='kw'>package</span> <span class='kw'>=</span> <span class='st'>"ggplot2"</span>)
|
||||
|
||||
<span class='co'># Horizontal line</span>
|
||||
<span class='fu'><a href='apex.html'>apex</a></span>(
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/utils/topics/head'>tail</a></span>(<span class='no'>economics</span>, <span class='fl'>200</span>),
|
||||
<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='fu'><a href='apexcharter-exports.html'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>date</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>uempmed</span>),
|
||||
<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"line"</span>
|
||||
) <span class='kw'>%>%</span>
|
||||
<span class='fu'>ax_annotations</span>(
|
||||
<span class='kw'>yaxis</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>y</span> <span class='kw'>=</span> <span class='fl'>11.897</span>,
|
||||
<span class='kw'>borderColor</span> <span class='kw'>=</span> <span class='st'>"firebrick"</span>,
|
||||
<span class='kw'>opacity</span> <span class='kw'>=</span> <span class='fl'>1</span>,
|
||||
<span class='kw'>label</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>text</span> <span class='kw'>=</span> <span class='st'>"Mean uempmed"</span>,
|
||||
<span class='kw'>position</span> <span class='kw'>=</span> <span class='st'>"left"</span>,
|
||||
<span class='kw'>textAnchor</span> <span class='kw'>=</span> <span class='st'>"start"</span>
|
||||
)
|
||||
))
|
||||
)
|
||||
|
||||
|
||||
<span class='co'># Vertical line</span>
|
||||
<span class='fu'><a href='apex.html'>apex</a></span>(
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/utils/topics/head'>tail</a></span>(<span class='no'>economics</span>, <span class='fl'>200</span>),
|
||||
<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='fu'><a href='apexcharter-exports.html'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>date</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>uempmed</span>),
|
||||
<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"line"</span>
|
||||
) <span class='kw'>%>%</span>
|
||||
<span class='fu'>ax_annotations</span>(
|
||||
<span class='kw'>xaxis</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>x</span> <span class='kw'>=</span> <span class='kw pkg'>htmlwidgets</span><span class='kw ns'>::</span><span class='fu'><a href='https://www.rdocumentation.org/packages/htmlwidgets/topics/JS'>JS</a></span>(<span class='st'>"new Date('1 Mar 2007').getTime()"</span>),
|
||||
<span class='kw'>strokeDashArray</span> <span class='kw'>=</span> <span class='fl'>0</span>,
|
||||
<span class='kw'>borderColor</span> <span class='kw'>=</span> <span class='st'>"#775DD0"</span>,
|
||||
<span class='kw'>label</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>text</span> <span class='kw'>=</span> <span class='st'>"A label"</span>,
|
||||
<span class='kw'>borderColor</span> <span class='kw'>=</span> <span class='st'>"#775DD0"</span>,
|
||||
<span class='kw'>style</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>color</span> <span class='kw'>=</span> <span class='st'>"#fff"</span>,
|
||||
<span class='kw'>background</span> <span class='kw'>=</span> <span class='st'>"#775DD0"</span>
|
||||
)
|
||||
)
|
||||
))
|
||||
)
|
||||
|
||||
|
||||
<span class='co'># Vertical range</span>
|
||||
<span class='fu'><a href='apex.html'>apex</a></span>(
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/utils/topics/head'>tail</a></span>(<span class='no'>economics</span>, <span class='fl'>200</span>),
|
||||
<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='fu'><a href='apexcharter-exports.html'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>date</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>uempmed</span>),
|
||||
<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"line"</span>
|
||||
) <span class='kw'>%>%</span>
|
||||
<span class='fu'>ax_annotations</span>(
|
||||
<span class='kw'>xaxis</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>x</span> <span class='kw'>=</span> <span class='kw pkg'>htmlwidgets</span><span class='kw ns'>::</span><span class='fu'><a href='https://www.rdocumentation.org/packages/htmlwidgets/topics/JS'>JS</a></span>(<span class='st'>"new Date('1 Jan 2009').getTime()"</span>),
|
||||
<span class='kw'>x2</span> <span class='kw'>=</span> <span class='kw pkg'>htmlwidgets</span><span class='kw ns'>::</span><span class='fu'><a href='https://www.rdocumentation.org/packages/htmlwidgets/topics/JS'>JS</a></span>(<span class='st'>"new Date('1 Feb 2010').getTime()"</span>),
|
||||
<span class='kw'>fillColor</span> <span class='kw'>=</span> <span class='st'>"#B3F7CA"</span>,
|
||||
<span class='kw'>opacity</span> <span class='kw'>=</span> <span class='fl'>0.4</span>,
|
||||
<span class='kw'>label</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>text</span> <span class='kw'>=</span> <span class='st'>"A label"</span>,
|
||||
<span class='kw'>borderColor</span> <span class='kw'>=</span> <span class='st'>"#B3F7CA"</span>,
|
||||
<span class='kw'>style</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>color</span> <span class='kw'>=</span> <span class='st'>"#fff"</span>,
|
||||
<span class='kw'>background</span> <span class='kw'>=</span> <span class='st'>"#B3F7CA"</span>
|
||||
)
|
||||
)
|
||||
))
|
||||
)
|
||||
|
||||
|
||||
<span class='co'># Point annotation</span>
|
||||
<span class='fu'><a href='apex.html'>apex</a></span>(
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/utils/topics/head'>tail</a></span>(<span class='no'>economics</span>, <span class='fl'>200</span>),
|
||||
<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='fu'><a href='apexcharter-exports.html'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>date</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>uempmed</span>),
|
||||
<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"line"</span>
|
||||
) <span class='kw'>%>%</span>
|
||||
<span class='fu'>ax_annotations</span>(
|
||||
<span class='kw'>points</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>x</span> <span class='kw'>=</span> <span class='kw pkg'>htmlwidgets</span><span class='kw ns'>::</span><span class='fu'><a href='https://www.rdocumentation.org/packages/htmlwidgets/topics/JS'>JS</a></span>(<span class='st'>"new Date('1 Jun 2010').getTime()"</span>),
|
||||
<span class='kw'>y</span> <span class='kw'>=</span> <span class='fl'>25.2</span>,
|
||||
<span class='kw'>marker</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>size</span> <span class='kw'>=</span> <span class='fl'>8</span>,
|
||||
<span class='kw'>fillColor</span> <span class='kw'>=</span> <span class='st'>"#fff"</span>,
|
||||
<span class='kw'>strokeColor</span> <span class='kw'>=</span> <span class='st'>"red"</span>,
|
||||
<span class='kw'>radius</span> <span class='kw'>=</span> <span class='fl'>2</span>
|
||||
),
|
||||
<span class='kw'>label</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>text</span> <span class='kw'>=</span> <span class='st'>"Highest"</span>,
|
||||
<span class='kw'>offsetY</span> <span class='kw'>=</span> <span class='fl'>0</span>,
|
||||
<span class='kw'>borderColor</span> <span class='kw'>=</span> <span class='st'>"#FF4560"</span>,
|
||||
<span class='kw'>style</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>color</span> <span class='kw'>=</span> <span class='st'>"#fff"</span>,
|
||||
<span class='kw'>background</span> <span class='kw'>=</span> <span class='st'>"#FF4560"</span>
|
||||
)
|
||||
)
|
||||
))
|
||||
)</div></pre>
|
||||
</div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#arguments">Arguments</a></li>
|
||||
|
||||
<li><a href="#value">Value</a></li>
|
||||
|
||||
<li><a href="#note">Note</a></li>
|
||||
|
||||
<li><a href="#examples">Examples</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://twitter.com/_pvictorr'><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"/> Victor Perrier</a>, <a href='https://twitter.com/_mfaan'><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg" /> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,276 +0,0 @@
|
|||
<!-- Generated by pkgdown: do not edit by hand -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Chart parameters — ax_chart • apexcharter</title>
|
||||
|
||||
<!-- jquery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Font Awesome icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
|
||||
|
||||
<!-- clipboard.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- sticky kit -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- pkgdown -->
|
||||
<link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script>
|
||||
|
||||
|
||||
|
||||
<meta property="og:title" content="Chart parameters — ax_chart" />
|
||||
|
||||
<meta property="og:description" content="Chart parameters" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
|
||||
|
||||
|
||||
<!-- mathjax -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container template-reference-topic">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!--/.nav-collapse -->
|
||||
</div><!--/.container -->
|
||||
</div><!--/.navbar -->
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>Chart parameters</h1>
|
||||
<small class="dont-index">Source: <a href='https://github.com/dreamRs/apexcharter/blob/master/R/apex-utils.R'><code>R/apex-utils.R</code></a></small>
|
||||
<div class="hidden name"><code>ax_chart.Rd</code></div>
|
||||
</div>
|
||||
|
||||
<div class="ref-description">
|
||||
|
||||
<p>Chart parameters</p>
|
||||
|
||||
</div>
|
||||
|
||||
<pre class="usage"><span class='fu'>ax_chart</span>(<span class='no'>ax</span>, <span class='kw'>type</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>stacked</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>stackType</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
|
||||
<span class='kw'>animations</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>background</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>foreColor</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
|
||||
<span class='kw'>dropShadow</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>events</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>offsetX</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>offsetY</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
|
||||
<span class='kw'>selection</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>sparkline</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>toolbar</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>zoom</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
|
||||
<span class='kw'>width</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>height</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='no'>...</span>)</pre>
|
||||
|
||||
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
|
||||
<table class="ref-arguments">
|
||||
<colgroup><col class="name" /><col class="desc" /></colgroup>
|
||||
<tr>
|
||||
<th>ax</th>
|
||||
<td><p>A <code>apexcharts</code> <code>htmlwidget</code> object.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>type</th>
|
||||
<td><p>Specify the chart type. Available Options: <code>"bar"</code>, <code>"column"</code>, <code>"line"</code>,
|
||||
<code>"pie"</code>, <code>"donut"</code>, <code>"radialBar"</code>, <code>"scatter"</code>, <code>"bubble"</code>, <code>"heatmap"</code>.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>stacked</th>
|
||||
<td><p>Logical. Enables stacked option for axis charts.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>stackType</th>
|
||||
<td><p>When stacked, should the stacking be percentage based or normal stacking. Available options: <code>"normal"</code> or <code>"100%"</code></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>animations</th>
|
||||
<td><p>A list of parameters.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>background</th>
|
||||
<td><p>Background color for the chart area. If you want to set background with css, use <code>.apexcharts-canvas</code> to set it.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>foreColor</th>
|
||||
<td><p>Sets the text color for the chart. Defaults to <code>#373d3f</code>.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>dropShadow</th>
|
||||
<td><p>A list of parameters. See <a href='https://apexcharts.com/docs/options/chart/dropshadow/'>https://apexcharts.com/docs/options/chart/dropshadow/</a>.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>events</th>
|
||||
<td><p>See <code><a href='events_opts.html'>events_opts</a></code>.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>offsetX</th>
|
||||
<td><p>Sets the left offset for chart.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>offsetY</th>
|
||||
<td><p>Sets the top offset for chart.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>selection</th>
|
||||
<td><p>A list of parameters.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>sparkline</th>
|
||||
<td><p>List. Sparkline hides all the elements of the charts other than the primary paths. Helps to visualize data in small areas. .</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>toolbar</th>
|
||||
<td><p>A list of parameters. See <a href='https://apexcharts.com/docs/options/chart/toolbar/'>https://apexcharts.com/docs/options/chart/toolbar/</a>.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>zoom</th>
|
||||
<td><p>A list of parameters. See <a href='https://apexcharts.com/docs/options/chart/zoom/'>https://apexcharts.com/docs/options/chart/zoom/</a>.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>width</th>
|
||||
<td><p>Width of the chart.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>height</th>
|
||||
<td><p>Height of the chart.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>...</th>
|
||||
<td><p>Additional parameters.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
|
||||
|
||||
<p>A <code>apexcharts</code> <code>htmlwidget</code> object.</p>
|
||||
|
||||
|
||||
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
|
||||
<pre class="examples"><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/utils/topics/data'>data</a></span>(<span class='st'>"diamonds"</span>, <span class='kw'>package</span> <span class='kw'>=</span> <span class='st'>"ggplot2"</span>)
|
||||
|
||||
<span class='co'># Stack bar type</span>
|
||||
<span class='fu'><a href='apex.html'>apex</a></span>(
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/tally.html'>count</a></span>(<span class='no'>diamonds</span>, <span class='no'>cut</span>, <span class='no'>color</span>),
|
||||
<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='fu'><a href='apexcharter-exports.html'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>cut</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>n</span>, <span class='kw'>fill</span> <span class='kw'>=</span> <span class='no'>color</span>)
|
||||
) <span class='kw'>%>%</span>
|
||||
<span class='fu'>ax_chart</span>(<span class='kw'>stacked</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)
|
||||
|
||||
<span class='fu'><a href='apex.html'>apex</a></span>(
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/tally.html'>count</a></span>(<span class='no'>diamonds</span>, <span class='no'>cut</span>, <span class='no'>color</span>),
|
||||
<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='fu'><a href='apexcharter-exports.html'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>cut</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>n</span>, <span class='kw'>fill</span> <span class='kw'>=</span> <span class='no'>color</span>)
|
||||
) <span class='kw'>%>%</span>
|
||||
<span class='fu'>ax_chart</span>(<span class='kw'>stacked</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>stackType</span> <span class='kw'>=</span> <span class='st'>"100%"</span>)
|
||||
|
||||
|
||||
<span class='co'># Toolbar</span>
|
||||
<span class='fu'><a href='apex.html'>apex</a></span>(
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/tally.html'>count</a></span>(<span class='no'>diamonds</span>, <span class='no'>cut</span>, <span class='no'>color</span>),
|
||||
<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='fu'><a href='apexcharter-exports.html'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>cut</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>n</span>, <span class='kw'>fill</span> <span class='kw'>=</span> <span class='no'>color</span>)
|
||||
) <span class='kw'>%>%</span>
|
||||
<span class='fu'>ax_chart</span>(<span class='kw'>toolbar</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(<span class='kw'>show</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>))</div></pre>
|
||||
</div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#arguments">Arguments</a></li>
|
||||
|
||||
<li><a href="#value">Value</a></li>
|
||||
|
||||
<li><a href="#examples">Examples</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://twitter.com/_pvictorr'><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"/> Victor Perrier</a>, <a href='https://twitter.com/_mfaan'><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg" /> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,207 +0,0 @@
|
|||
<!-- Generated by pkgdown: do not edit by hand -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Colors — ax_colors • apexcharter</title>
|
||||
|
||||
<!-- jquery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Font Awesome icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
|
||||
|
||||
<!-- clipboard.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- sticky kit -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- pkgdown -->
|
||||
<link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script>
|
||||
|
||||
|
||||
|
||||
<meta property="og:title" content="Colors — ax_colors" />
|
||||
|
||||
<meta property="og:description" content="Colors" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
|
||||
|
||||
|
||||
<!-- mathjax -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container template-reference-topic">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!--/.nav-collapse -->
|
||||
</div><!--/.container -->
|
||||
</div><!--/.navbar -->
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>Colors</h1>
|
||||
<small class="dont-index">Source: <a href='https://github.com/dreamRs/apexcharter/blob/master/R/apex-utils.R'><code>R/apex-utils.R</code></a></small>
|
||||
<div class="hidden name"><code>ax_colors.Rd</code></div>
|
||||
</div>
|
||||
|
||||
<div class="ref-description">
|
||||
|
||||
<p>Colors</p>
|
||||
|
||||
</div>
|
||||
|
||||
<pre class="usage"><span class='fu'>ax_colors</span>(<span class='no'>ax</span>, <span class='no'>...</span>)</pre>
|
||||
|
||||
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
|
||||
<table class="ref-arguments">
|
||||
<colgroup><col class="name" /><col class="desc" /></colgroup>
|
||||
<tr>
|
||||
<th>ax</th>
|
||||
<td><p>A <code>apexcharts</code> <code>htmlwidget</code> object.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>...</th>
|
||||
<td><p>Colors for the chart’s series. When all colors are used, it starts from the beginning.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
|
||||
|
||||
<p>A <code>apexcharts</code> <code>htmlwidget</code> object.</p>
|
||||
|
||||
<h2 class="hasAnchor" id="note"><a class="anchor" href="#note"></a>Note</h2>
|
||||
|
||||
<p>See <a href='https://apexcharts.com/docs/options/colors/'>https://apexcharts.com/docs/options/colors/</a></p>
|
||||
|
||||
|
||||
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
|
||||
<pre class="examples"><div class='input'>
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/utils/topics/data'>data</a></span>(<span class='st'>"diamonds"</span>, <span class='kw'>package</span> <span class='kw'>=</span> <span class='st'>"ggplot2"</span>)
|
||||
|
||||
<span class='co'># Change default color(s)</span>
|
||||
<span class='fu'><a href='apex.html'>apex</a></span>(
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/tally.html'>count</a></span>(<span class='no'>diamonds</span>, <span class='no'>cut</span>),
|
||||
<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='fu'><a href='apexcharter-exports.html'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>cut</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>n</span>)
|
||||
) <span class='kw'>%>%</span>
|
||||
<span class='fu'>ax_colors</span>(<span class='st'>"#F7D358"</span>)
|
||||
|
||||
|
||||
<span class='fu'><a href='apex.html'>apex</a></span>(
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/tally.html'>count</a></span>(<span class='no'>diamonds</span>, <span class='no'>cut</span>, <span class='no'>color</span>),
|
||||
<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='fu'><a href='apexcharter-exports.html'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>cut</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>n</span>, <span class='kw'>fill</span> <span class='kw'>=</span> <span class='no'>color</span>)
|
||||
) <span class='kw'>%>%</span>
|
||||
<span class='fu'>ax_colors</span>(<span class='kw pkg'>scales</span><span class='kw ns'>::</span><span class='fu'><a href='https://www.rdocumentation.org/packages/scales/topics/brewer_pal'>brewer_pal</a></span>(<span class='kw'>palette</span> <span class='kw'>=</span> <span class='st'>"Set2"</span>)(<span class='fl'>7</span>))</div></pre>
|
||||
</div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#arguments">Arguments</a></li>
|
||||
|
||||
<li><a href="#value">Value</a></li>
|
||||
|
||||
<li><a href="#note">Note</a></li>
|
||||
|
||||
<li><a href="#examples">Examples</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://twitter.com/_pvictorr'><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"/> Victor Perrier</a>, <a href='https://twitter.com/_mfaan'><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg" /> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,230 +0,0 @@
|
|||
<!-- Generated by pkgdown: do not edit by hand -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Labels on data — ax_dataLabels • apexcharter</title>
|
||||
|
||||
<!-- jquery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Font Awesome icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
|
||||
|
||||
<!-- clipboard.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- sticky kit -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- pkgdown -->
|
||||
<link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script>
|
||||
|
||||
|
||||
|
||||
<meta property="og:title" content="Labels on data — ax_dataLabels" />
|
||||
|
||||
<meta property="og:description" content="Labels on data" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
|
||||
|
||||
|
||||
<!-- mathjax -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container template-reference-topic">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!--/.nav-collapse -->
|
||||
</div><!--/.container -->
|
||||
</div><!--/.navbar -->
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>Labels on data</h1>
|
||||
<small class="dont-index">Source: <a href='https://github.com/dreamRs/apexcharter/blob/master/R/apex-utils.R'><code>R/apex-utils.R</code></a></small>
|
||||
<div class="hidden name"><code>ax_dataLabels.Rd</code></div>
|
||||
</div>
|
||||
|
||||
<div class="ref-description">
|
||||
|
||||
<p>Labels on data</p>
|
||||
|
||||
</div>
|
||||
|
||||
<pre class="usage"><span class='fu'>ax_dataLabels</span>(<span class='no'>ax</span>, <span class='kw'>enabled</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>textAnchor</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>offsetX</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
|
||||
<span class='kw'>offsetY</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>style</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>dropShadow</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
|
||||
<span class='kw'>formatter</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='no'>...</span>)</pre>
|
||||
|
||||
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
|
||||
<table class="ref-arguments">
|
||||
<colgroup><col class="name" /><col class="desc" /></colgroup>
|
||||
<tr>
|
||||
<th>ax</th>
|
||||
<td><p>A <code>apexcharts</code> <code>htmlwidget</code> object.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>enabled</th>
|
||||
<td><p>To determine whether to show dataLabels or not.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>textAnchor</th>
|
||||
<td><p>The alignment of text relative to dataLabel’s drawing position.
|
||||
Accepted values <code>"start"</code>, <code>"middle"</code> or <code>"end"</code>.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>offsetX</th>
|
||||
<td><p>Sets the left offset for dataLabels.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>offsetY</th>
|
||||
<td><p>Sets the top offset for dataLabels.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>style</th>
|
||||
<td><p>A list of parameters.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>dropShadow</th>
|
||||
<td><p>A list of parameters.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>formatter</th>
|
||||
<td><p>The formatter function takes in a single value and allows you to format the value before displaying</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>...</th>
|
||||
<td><p>Additional parameters.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
|
||||
|
||||
<p>A <code>apexcharts</code> <code>htmlwidget</code> object.</p>
|
||||
|
||||
<h2 class="hasAnchor" id="note"><a class="anchor" href="#note"></a>Note</h2>
|
||||
|
||||
<p>See <a href='https://apexcharts.com/docs/options/datalabels/'>https://apexcharts.com/docs/options/datalabels/</a></p>
|
||||
|
||||
|
||||
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
|
||||
<pre class="examples"><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/utils/topics/data'>data</a></span>(<span class='st'>"diamonds"</span>, <span class='kw'>package</span> <span class='kw'>=</span> <span class='st'>"ggplot2"</span>)
|
||||
|
||||
<span class='co'># Add data labels</span>
|
||||
<span class='fu'><a href='apex.html'>apex</a></span>(
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/tally.html'>count</a></span>(<span class='no'>diamonds</span>, <span class='no'>cut</span>),
|
||||
<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='fu'><a href='apexcharter-exports.html'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>cut</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>n</span>)
|
||||
) <span class='kw'>%>%</span>
|
||||
<span class='fu'>ax_dataLabels</span>(<span class='kw'>enabled</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div></pre>
|
||||
</div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#arguments">Arguments</a></li>
|
||||
|
||||
<li><a href="#value">Value</a></li>
|
||||
|
||||
<li><a href="#note">Note</a></li>
|
||||
|
||||
<li><a href="#examples">Examples</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://twitter.com/_pvictorr'><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"/> Victor Perrier</a>, <a href='https://twitter.com/_mfaan'><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg" /> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,249 +0,0 @@
|
|||
<!-- Generated by pkgdown: do not edit by hand -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Fill property — ax_fill • apexcharter</title>
|
||||
|
||||
<!-- jquery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Font Awesome icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
|
||||
|
||||
<!-- clipboard.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- sticky kit -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- pkgdown -->
|
||||
<link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script>
|
||||
|
||||
|
||||
|
||||
<meta property="og:title" content="Fill property — ax_fill" />
|
||||
|
||||
<meta property="og:description" content="Fill property" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
|
||||
|
||||
|
||||
<!-- mathjax -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container template-reference-topic">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">apexcharter</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.1.1.900</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/starting-with-apexcharts.html">Get started</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/index.html">Reference</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
Articles
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/labs.html">Labs: title, subtitle & axis</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/lines.html">Options & styles for lines</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/index.html">News</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/dreamRs/apexcharter">
|
||||
<span class="fa fa-github fa-lg"></span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div><!--/.nav-collapse -->
|
||||
</div><!--/.container -->
|
||||
</div><!--/.navbar -->
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>Fill property</h1>
|
||||
<small class="dont-index">Source: <a href='https://github.com/dreamRs/apexcharter/blob/master/R/apex-utils.R'><code>R/apex-utils.R</code></a></small>
|
||||
<div class="hidden name"><code>ax_fill.Rd</code></div>
|
||||
</div>
|
||||
|
||||
<div class="ref-description">
|
||||
|
||||
<p>Fill property</p>
|
||||
|
||||
</div>
|
||||
|
||||
<pre class="usage"><span class='fu'>ax_fill</span>(<span class='no'>ax</span>, <span class='kw'>type</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>colors</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>opacity</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
|
||||
<span class='kw'>gradient</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>image</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>pattern</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='no'>...</span>)</pre>
|
||||
|
||||
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
|
||||
<table class="ref-arguments">
|
||||
<colgroup><col class="name" /><col class="desc" /></colgroup>
|
||||
<tr>
|
||||
<th>ax</th>
|
||||
<td><p>A <code>apexcharts</code> <code>htmlwidget</code> object.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>type</th>
|
||||
<td><p>Whether to fill the paths with solid colors or gradient.
|
||||
Available options: <code>"solid"</code>, <code>"gradient"</code>, <code>"pattern"</code> or <code>"image"</code>.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>colors</th>
|
||||
<td><p>Colors to fill the svg paths..</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>opacity</th>
|
||||
<td><p>Opacity of the fill attribute.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>gradient</th>
|
||||
<td><p>A list of parameters.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>image</th>
|
||||
<td><p>A list of parameters.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>pattern</th>
|
||||
<td><p>A list of parameters.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>...</th>
|
||||
<td><p>Additional parameters.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
|
||||
|
||||
<p>A <code>apexcharts</code> <code>htmlwidget</code> object.</p>
|
||||
|
||||
<h2 class="hasAnchor" id="note"><a class="anchor" href="#note"></a>Note</h2>
|
||||
|
||||
<p>See <a href='https://apexcharts.com/docs/options/fill/'>https://apexcharts.com/docs/options/fill/</a></p>
|
||||
|
||||
|
||||
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
|
||||
<pre class="examples"><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/utils/topics/data'>data</a></span>(<span class='st'>"diamonds"</span>, <span class='kw'>package</span> <span class='kw'>=</span> <span class='st'>"ggplot2"</span>)
|
||||
|
||||
<span class='co'># Use a pattern to fill bars</span>
|
||||
<span class='fu'><a href='apex.html'>apex</a></span>(
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/tally.html'>count</a></span>(<span class='no'>diamonds</span>, <span class='no'>cut</span>, <span class='no'>color</span>),
|
||||
<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='fu'><a href='apexcharter-exports.html'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>color</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>n</span>, <span class='kw'>fill</span> <span class='kw'>=</span> <span class='no'>cut</span>)
|
||||
) <span class='kw'>%>%</span>
|
||||
<span class='fu'>ax_fill</span>(
|
||||
<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"pattern"</span>,
|
||||
<span class='kw'>opacity</span> <span class='kw'>=</span> <span class='fl'>1</span>,
|
||||
<span class='kw'>pattern</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>style</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"circles"</span>, <span class='st'>"slantedLines"</span>, <span class='st'>"verticalLines"</span>, <span class='st'>"horizontalLines"</span>, <span class='st'>"squares"</span>)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
<span class='fu'><a href='https://www.rdocumentation.org/packages/utils/topics/data'>data</a></span>(<span class='st'>"economics"</span>, <span class='kw'>package</span> <span class='kw'>=</span> <span class='st'>"ggplot2"</span>)
|
||||
|
||||
<span class='co'># Customise gradient</span>
|
||||
<span class='fu'><a href='apex.html'>apex</a></span>(
|
||||
<span class='kw'>data</span> <span class='kw'>=</span> <span class='no'>economics</span>,
|
||||
<span class='kw'>mapping</span> <span class='kw'>=</span> <span class='fu'><a href='apexcharter-exports.html'>aes</a></span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='no'>date</span>, <span class='kw'>y</span> <span class='kw'>=</span> <span class='no'>psavert</span>),
|
||||
<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"area"</span>
|
||||
) <span class='kw'>%>%</span>
|
||||
<span class='fu'>ax_fill</span>(<span class='kw'>gradient</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(
|
||||
<span class='kw'>enabled</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
|
||||
<span class='kw'>shadeIntensity</span> <span class='kw'>=</span> <span class='fl'>1</span>,
|
||||
<span class='kw'>inverseColors</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>,
|
||||
<span class='kw'>opacityFrom</span> <span class='kw'>=</span> <span class='fl'>0</span>,
|
||||
<span class='kw'>opacityTo</span> <span class='kw'>=</span> <span class='fl'>1</span>,
|
||||
<span class='kw'>stops</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='fl'>0</span>, <span class='fl'>2000</span>)
|
||||
))</div></pre>
|
||||
</div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#arguments">Arguments</a></li>
|
||||
|
||||
<li><a href="#value">Value</a></li>
|
||||
|
||||
<li><a href="#note">Note</a></li>
|
||||
|
||||
<li><a href="#examples">Examples</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://twitter.com/_pvictorr'><img src="https://pbs.twimg.com/profile_images/844237339404722177/E1U61aM8_normal.jpg"/> Victor Perrier</a>, <a href='https://twitter.com/_mfaan'><img src="https://pbs.twimg.com/profile_images/912313931326218240/o1-wvA18_normal.jpg" /> Fanny Meyer</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue