From 2513bc5fdfc4659193e31d532c44f3c397eee569 Mon Sep 17 00:00:00 2001 From: pvictor Date: Tue, 26 Nov 2019 14:44:59 +0100 Subject: [PATCH] locales files for apexcharts --- DESCRIPTION | 5 +- NEWS.md | 3 +- R/apex-utils.R | 35 ++++--------- R/apexcharter.R | 20 +++++++- examples/ax_chart.R | 26 ++++++++++ examples/localization.R | 30 +++++++++++ .../lib/apexcharts-locales/de.json | 20 ++++++++ .../lib/apexcharts-locales/el.json | 20 ++++++++ .../lib/apexcharts-locales/en.json | 20 ++++++++ .../lib/apexcharts-locales/es.json | 20 ++++++++ .../lib/apexcharts-locales/fr.json | 20 ++++++++ .../lib/apexcharts-locales/hi.json | 20 ++++++++ .../lib/apexcharts-locales/hr.json | 20 ++++++++ .../lib/apexcharts-locales/hy.json | 20 ++++++++ .../lib/apexcharts-locales/id.json | 20 ++++++++ .../lib/apexcharts-locales/it.json | 20 ++++++++ .../lib/apexcharts-locales/ko.json | 20 ++++++++ .../lib/apexcharts-locales/pt-br.json | 20 ++++++++ .../lib/apexcharts-locales/ru.json | 20 ++++++++ .../lib/apexcharts-locales/tr.json | 20 ++++++++ .../lib/apexcharts-locales/ua.json | 20 ++++++++ man/ax_chart.Rd | 50 +++++++++++++++++-- 22 files changed, 436 insertions(+), 33 deletions(-) create mode 100644 examples/ax_chart.R create mode 100644 examples/localization.R create mode 100644 inst/htmlwidgets/lib/apexcharts-locales/de.json create mode 100644 inst/htmlwidgets/lib/apexcharts-locales/el.json create mode 100644 inst/htmlwidgets/lib/apexcharts-locales/en.json create mode 100644 inst/htmlwidgets/lib/apexcharts-locales/es.json create mode 100644 inst/htmlwidgets/lib/apexcharts-locales/fr.json create mode 100644 inst/htmlwidgets/lib/apexcharts-locales/hi.json create mode 100644 inst/htmlwidgets/lib/apexcharts-locales/hr.json create mode 100644 inst/htmlwidgets/lib/apexcharts-locales/hy.json create mode 100644 inst/htmlwidgets/lib/apexcharts-locales/id.json create mode 100644 inst/htmlwidgets/lib/apexcharts-locales/it.json create mode 100644 inst/htmlwidgets/lib/apexcharts-locales/ko.json create mode 100644 inst/htmlwidgets/lib/apexcharts-locales/pt-br.json create mode 100644 inst/htmlwidgets/lib/apexcharts-locales/ru.json create mode 100644 inst/htmlwidgets/lib/apexcharts-locales/tr.json create mode 100644 inst/htmlwidgets/lib/apexcharts-locales/ua.json diff --git a/DESCRIPTION b/DESCRIPTION index c6f7595..1c4ca16 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: apexcharter -Version: 0.1.2.920 +Version: 0.1.2.930 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. @@ -18,7 +18,8 @@ Imports: magrittr, rlang, ggplot2, - scales + scales, + jsonlite Suggests: testthat, dplyr, diff --git a/NEWS.md b/NEWS.md index 87435c2..9ccf11f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,7 +2,8 @@ apexcharter 0.1.3 ================== * Upgraded ApexCharts.js to 3.10.1 -* New function `format_num()` to format labels on y-axis for example. +* New function `format_num()` to format labels on y-axis or tooltip for example. +* Added localization configs file, see `?ax_chart` for examples. diff --git a/R/apex-utils.R b/R/apex-utils.R index 4a4c8bd..6a4d903 100644 --- a/R/apex-utils.R +++ b/R/apex-utils.R @@ -134,7 +134,12 @@ ax_annotations <- function(ax, #' @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{"de"}, \code{"el"}, \code{"en"}, \code{"es"}, \code{"fr"}, +#' \code{"hi"}, \code{"hr"}, \code{"hy"}, \code{"id"}, \code{"it"}, \code{"ko"}, \code{"pt-br"}, +#' \code{"ru"}, \code{"tr"}, \code{"ua"}. +#' @param locales Array of custom localizations paremeters. #' @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}. @@ -153,34 +158,14 @@ ax_annotations <- function(ax, #' @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, diff --git a/R/apexcharter.R b/R/apexcharter.R index baad6e5..ca130b3 100644 --- a/R/apexcharter.R +++ b/R/apexcharter.R @@ -14,7 +14,7 @@ #' #' @example examples/apexchart.R apexchart <- function(ax_opts = list(), auto_update = TRUE, width = NULL, height = NULL, elementId = NULL) { - + # forward options using x x <- list( ax_opts = ax_opts, @@ -29,6 +29,24 @@ apexchart <- function(ax_opts = list(), auto_update = TRUE, width = NULL, height height = height, package = 'apexcharter', elementId = elementId, + preRenderHook = 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("de", "el", "en", "es", "fr", "hi", "hr", "hy", "id", "it", + "ko.js", "pt-br", "ru", "tr", "ua") + ) + 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("htmlwidgets/lib/apexcharts-locales", paste0(defaultLocale, ".json")), package = "apexcharter") + locale <- jsonlite::fromJSON(txt = path) + widget$x$ax_opts$chart$locales <- list(locale) + } + } + widget + }, sizingPolicy = htmlwidgets::sizingPolicy( defaultWidth = "100%", defaultHeight = "100%", diff --git a/examples/ax_chart.R b/examples/ax_chart.R new file mode 100644 index 0000000..6e70ccb --- /dev/null +++ b/examples/ax_chart.R @@ -0,0 +1,26 @@ +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)) + + + \ No newline at end of file diff --git a/examples/localization.R b/examples/localization.R new file mode 100644 index 0000000..a563504 --- /dev/null +++ b/examples/localization.R @@ -0,0 +1,30 @@ +# Use included localization config +dat <- data.frame( + x = Sys.Date() + 1:20, + y = sample.int(20, 20) +) + +# French +apex(dat, aes(x, y), "line") %>% + ax_chart(defaultLocale = "fr") + +# Italian +apex(dat, aes(x, y), "line") %>% + ax_chart(defaultLocale = "it") + + + +# Custom config +apex(dat, aes(x, y), "line") %>% + ax_chart(locales = list( + list( + name = "en", # override en locale + options = list( + toolbar = list( + exportToSVG = "GET SVG", + exportToPNG = "GET PNG" + ) + ) + ) + )) + diff --git a/inst/htmlwidgets/lib/apexcharts-locales/de.json b/inst/htmlwidgets/lib/apexcharts-locales/de.json new file mode 100644 index 0000000..3fc938f --- /dev/null +++ b/inst/htmlwidgets/lib/apexcharts-locales/de.json @@ -0,0 +1,20 @@ +{ + "name": "de", + "options": { + "months": ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"], + "shortMonths": ["Jan", "Feb", "Mär", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"], + "days": ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"], + "shortDays": ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"], + "toolbar": { + "exportToSVG": "SVG speichern", + "exportToPNG": "PNG speichern", + "menu": "Menü", + "selection": "Auswahl", + "selectionZoom": "Auswahl vergrößern", + "zoomIn": "Vergrößern", + "zoomOut": "Verkleinern", + "pan": "Verschieben", + "reset": "Zoom zurücksetzen" + } + } +} diff --git a/inst/htmlwidgets/lib/apexcharts-locales/el.json b/inst/htmlwidgets/lib/apexcharts-locales/el.json new file mode 100644 index 0000000..65ad3b2 --- /dev/null +++ b/inst/htmlwidgets/lib/apexcharts-locales/el.json @@ -0,0 +1,20 @@ +{ + "name": "el", + "options": { + "months": ["Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος"], + "shortMonths": ["Ιαν", "Φευ", "Μαρ", "Απρ", "Μάι", "Ιουν", "Ιουλ", "Αυγ", "Σεπ", "Οκτ", "Νοε", "Δεκ"], + "days": ["Κυριακή", "Δευτέρα", "Τρίτη", "Τετάρτη", "Πέμπτη", "Παρασκευή", "Σάββατο"], + "shortDays": ["Κυρ", "Δευ", "Τρι", "Τετ", "Πεμ", "Παρ", "Σαβ"], + "toolbar": { + "exportToSVG": "Λήψη SVG", + "exportToPNG": "Λήψη PNG", + "menu": "Menu", + "selection": "Επιλογή", + "selectionZoom": "Μεγένθυση βάση επιλογής", + "zoomIn": "Μεγένθυνση", + "zoomOut": "Σμίκρυνση", + "pan": "Μετατόπιση", + "reset": "Επαναφορά μεγένθυνσης" + } + } +} diff --git a/inst/htmlwidgets/lib/apexcharts-locales/en.json b/inst/htmlwidgets/lib/apexcharts-locales/en.json new file mode 100644 index 0000000..f5453ae --- /dev/null +++ b/inst/htmlwidgets/lib/apexcharts-locales/en.json @@ -0,0 +1,20 @@ +{ + "name": "en", + "options": { + "months": ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], + "shortMonths": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], + "days": ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], + "shortDays": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], + "toolbar": { + "exportToSVG": "Download SVG", + "exportToPNG": "Download PNG", + "menu": "Menu", + "selection": "Selection", + "selectionZoom": "Selection Zoom", + "zoomIn": "Zoom In", + "zoomOut": "Zoom Out", + "pan": "Panning", + "reset": "Reset Zoom" + } + } +} \ No newline at end of file diff --git a/inst/htmlwidgets/lib/apexcharts-locales/es.json b/inst/htmlwidgets/lib/apexcharts-locales/es.json new file mode 100644 index 0000000..3225361 --- /dev/null +++ b/inst/htmlwidgets/lib/apexcharts-locales/es.json @@ -0,0 +1,20 @@ +{ + "name": "es", + "options": { + "months": ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"], + "shortMonths": ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"], + "days": ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"], + "shortDays": ["Dom", "Lun", "Mar", "Mie", "Jue", "Vie", "Sab"], + "toolbar": { + "exportToSVG": "Descargar SVG", + "exportToPNG": "Descargar PNG", + "menu": "Menu", + "selection": "Seleccionar", + "selectionZoom": "Seleccionar Zoom", + "zoomIn": "Aumentar", + "zoomOut": "Disminuir", + "pan": "Navegación", + "reset": "Reiniciar Zoom" + } + } +} \ No newline at end of file diff --git a/inst/htmlwidgets/lib/apexcharts-locales/fr.json b/inst/htmlwidgets/lib/apexcharts-locales/fr.json new file mode 100644 index 0000000..64b2bc2 --- /dev/null +++ b/inst/htmlwidgets/lib/apexcharts-locales/fr.json @@ -0,0 +1,20 @@ +{ + "name": "fr", + "options": { + "months": ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"], + "shortMonths": ["janv.", "févr.", "mars", "avr.", "mai", "juin", "juill.", "août", "sept.", "oct.", "nov.", "déc."], + "days": ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"], + "shortDays": ["dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."], + "toolbar": { + "exportToSVG": "Télécharger au format SVG", + "exportToPNG": "Télécharger au format PNG", + "menu": "Menu", + "selection": "Sélection", + "selectionZoom": "Sélection et zoom", + "zoomIn": "Zoomer", + "zoomOut": "Dézoomer", + "pan": "Navigation", + "reset": "Réinitialiser le zoom" + } + } +} \ No newline at end of file diff --git a/inst/htmlwidgets/lib/apexcharts-locales/hi.json b/inst/htmlwidgets/lib/apexcharts-locales/hi.json new file mode 100644 index 0000000..facb8bc --- /dev/null +++ b/inst/htmlwidgets/lib/apexcharts-locales/hi.json @@ -0,0 +1,20 @@ +{ + "name": "hi", + "options": { + "months": ["जनवरी", "फ़रवरी", "मार्च", "अप्रैल", "मई", "जून", "जुलाई", "अगस्त", "सितंबर", "अक्टूबर", "नवंबर", "दिसंबर"], + "shortMonths": ["जनवरी", "फ़रवरी", "मार्च", "अप्रैल", "मई", "जून", "जुलाई", "अगस्त", "सितंबर", "अक्टूबर", "नवंबर", "दिसंबर"], + "days": ["रविवार", "सोमवार", "मंगलवार", "बुधवार", "गुरुवार", "शुक्रवार", "शनिवार"], + "shortDays": ["रवि", "सोम", "मंगल", "बुध", "गुरु", "शुक्र", "शनि"], + "toolbar": { + "exportToSVG": "निर्यात SVG", + "exportToPNG": "निर्यात PNG", + "menu": "सूची", + "selection": "चयन", + "selectionZoom": "ज़ूम करना", + "zoomIn": "ज़ूम इन", + "zoomOut": "ज़ूम आउट", + "pan": "पैनिंग", + "reset": "फिर से कायम करना" + } + } +} \ No newline at end of file diff --git a/inst/htmlwidgets/lib/apexcharts-locales/hr.json b/inst/htmlwidgets/lib/apexcharts-locales/hr.json new file mode 100644 index 0000000..29c7085 --- /dev/null +++ b/inst/htmlwidgets/lib/apexcharts-locales/hr.json @@ -0,0 +1,20 @@ +{ + "name": "hr", + "options": { + "months": ["Siječanj", "Veljača", "Ožujak", "Travanj", "Svibanj", "Lipanj", "Srpanj", "Kolovoz", "Rujan", "Listopad", "Studeni", "Prosinac"], + "shortMonths": ["Sij", "Velj", "Ožu", "Tra", "Svi", "Lip", "Srp", "Kol", "Ruj", "Lis", "Stu", "Pro"], + "days": ["Nedjelja", "Ponedjeljak", "Utorak", "Srijeda", "Četvrtak", "Petak", "Subota"], + "shortDays": ["Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub"], + "toolbar": { + "exportToSVG": "Preuzmi SVG", + "exportToPNG": "Preuzmi PNG", + "menu": "Izbornik", + "selection": "Odabir", + "selectionZoom": "Odabirno povećanje", + "zoomIn": "Uvećajte prikaz", + "zoomOut": "Umanjite prikaz", + "pan": "Pomicanje", + "reset": "Povratak na zadani prikaz" + } + } +} diff --git a/inst/htmlwidgets/lib/apexcharts-locales/hy.json b/inst/htmlwidgets/lib/apexcharts-locales/hy.json new file mode 100644 index 0000000..31dcbf3 --- /dev/null +++ b/inst/htmlwidgets/lib/apexcharts-locales/hy.json @@ -0,0 +1,20 @@ +{ + "name": "hy", + "options": { + "months": ["Հունվար", "Փետրվար", "Մարտ", "Ապրիլ", "Մայիս", "Հունիս", "Հուլիս", "Օգոստոս", "Սեպտեմբեր", "Հոկտեմբեր", "Նոյեմբեր", "Դեկտեմբեր"], + "shortMonths": ["Հնվ", "Փտվ", "Մրտ", "Ապր", "Մյս", "Հնս", "Հլիս", "Օգս", "Սեպ", "Հոկ", "Նոյ", "Դեկ"], + "days": ["Կիրակի", "Երկուշաբթի", "Երեքշաբթի", "Չորեքշաբթի", "Հինգշաբթի", "Ուրբաթ", "Շաբաթ"], + "shortDays": ["Կիր", "Երկ", "Երք", "Չրք", "Հնգ", "Ուրբ", "Շբթ"], + "toolbar": { + "exportToSVG": "Բեռնել SVG", + "exportToPNG": "Բեռնել PNG", + "menu": "Մենյու", + "selection": "Ընտրված", + "selectionZoom": "Ընտրված հատվածի խոշորացում", + "zoomIn": "Խոշորացնել", + "zoomOut": "Մանրացնել", + "pan": "Տեղափոխում", + "reset": "Բերել սկզբնական վիճակի" + } + } +} diff --git a/inst/htmlwidgets/lib/apexcharts-locales/id.json b/inst/htmlwidgets/lib/apexcharts-locales/id.json new file mode 100644 index 0000000..a4d01c3 --- /dev/null +++ b/inst/htmlwidgets/lib/apexcharts-locales/id.json @@ -0,0 +1,20 @@ +{ + "name": "id", + "options": { + "months": ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"], + "shortMonths": ["Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agu", "Sep", "Okt", "Nov", "Des"], + "days": ["Minggu", "Senin", "Selasa", "Rabu", "kamis", "Jumat", "Sabtu"], + "shortDays": ["Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"], + "toolbar": { + "exportToSVG": "Unduh SVG", + "exportToPNG": "Unduh PNG", + "menu": "Menu", + "selection": "Pilihan", + "selectionZoom": "Perbesar Pilihan", + "zoomIn": "Perbesar", + "zoomOut": "Perkecil", + "pan": "Geser", + "reset": "Atur Ulang Zoom" + } + } +} diff --git a/inst/htmlwidgets/lib/apexcharts-locales/it.json b/inst/htmlwidgets/lib/apexcharts-locales/it.json new file mode 100644 index 0000000..635e34c --- /dev/null +++ b/inst/htmlwidgets/lib/apexcharts-locales/it.json @@ -0,0 +1,20 @@ +{ + "name": "it", + "options": { + "months": ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"], + "shortMonths": ["Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic"], + "days": ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"], + "shortDays": ["Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"], + "toolbar": { + "exportToSVG": "Scarica SVG", + "exportToPNG": "Scarica PNG", + "menu": "Menu", + "selection": "Selezione", + "selectionZoom": "Seleziona Zoom", + "zoomIn": "Zoom In", + "zoomOut": "Zoom Out", + "pan": "Sposta", + "reset": "Reimposta Zoom" + } + } +} \ No newline at end of file diff --git a/inst/htmlwidgets/lib/apexcharts-locales/ko.json b/inst/htmlwidgets/lib/apexcharts-locales/ko.json new file mode 100644 index 0000000..3bc2d17 --- /dev/null +++ b/inst/htmlwidgets/lib/apexcharts-locales/ko.json @@ -0,0 +1,20 @@ +{ + "name": "ko", + "options": { + "months": ["1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"], + "shortMonths": ["1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"], + "days": ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"], + "shortDays": ["일", "월", "화", "수", "목", "금", "토"], + "toolbar": { + "exportToSVG": "SVG 다운로드", + "exportToPNG": "PNG 다운로드", + "menu": "메뉴", + "selection": "선택", + "selectionZoom": "선택영역 확대", + "zoomIn": "확대", + "zoomOut": "축소", + "pan": "패닝", + "reset": "원래대로" + } + } +} diff --git a/inst/htmlwidgets/lib/apexcharts-locales/pt-br.json b/inst/htmlwidgets/lib/apexcharts-locales/pt-br.json new file mode 100644 index 0000000..4843e98 --- /dev/null +++ b/inst/htmlwidgets/lib/apexcharts-locales/pt-br.json @@ -0,0 +1,20 @@ +{ + "name": "pt-br", + "options": { + "months": ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"], + "shortMonths": ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"], + "days": ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"], + "shortDays": ["Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"], + "toolbar": { + "exportToSVG": "Baixar SVG", + "exportToPNG": "Baixar PNG", + "menu": "Menu", + "selection": "Selecionar", + "selectionZoom": "Selecionar Zoom", + "zoomIn": "Aumentar", + "zoomOut": "Diminuir", + "pan": "Navegação", + "reset": "Reiniciar Zoom" + } + } +} diff --git a/inst/htmlwidgets/lib/apexcharts-locales/ru.json b/inst/htmlwidgets/lib/apexcharts-locales/ru.json new file mode 100644 index 0000000..a7f80f2 --- /dev/null +++ b/inst/htmlwidgets/lib/apexcharts-locales/ru.json @@ -0,0 +1,20 @@ +{ + "name": "ru", + "options": { + "months": ["Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"], + "shortMonths": ["Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек"], + "days": ["Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота"], + "shortDays": ["Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"], + "toolbar": { + "exportToSVG": "Сохранить SVG", + "exportToPNG": "Сохранить PNG", + "menu": "Меню", + "selection": "Выбор", + "selectionZoom": "Выбор с увеличением", + "zoomIn": "Увеличить", + "zoomOut": "Уменьшить", + "pan": "Перемещение", + "reset": "Сбросить увеличение" + } + } +} diff --git a/inst/htmlwidgets/lib/apexcharts-locales/tr.json b/inst/htmlwidgets/lib/apexcharts-locales/tr.json new file mode 100644 index 0000000..3789605 --- /dev/null +++ b/inst/htmlwidgets/lib/apexcharts-locales/tr.json @@ -0,0 +1,20 @@ +{ + "name": "tr", + "options": { + "months": ["Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"], + "shortMonths": ["Oca", "Şub", "Mar", "Nis", "May", "Haz", "Tem", "Ağu", "Eyl", "Eki", "Kas", "Ara"], + "days": ["Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi"], + "shortDays": ["Paz", "Pzt", "Sal", "Çar", "Per", "Cum", "Cmt"], + "toolbar": { + "exportToSVG": "SVG İndir", + "exportToPNG": "PNG İndir", + "menu": "Menü", + "selection": "Seçim", + "selectionZoom": "Seçim Yakınlaştır", + "zoomIn": "Yakınlaştır", + "zoomOut": "Uzaklaştır", + "pan": "Kaydır", + "reset": "Yakınlaştırmayı Sıfırla" + } + } +} diff --git a/inst/htmlwidgets/lib/apexcharts-locales/ua.json b/inst/htmlwidgets/lib/apexcharts-locales/ua.json new file mode 100644 index 0000000..f96a48e --- /dev/null +++ b/inst/htmlwidgets/lib/apexcharts-locales/ua.json @@ -0,0 +1,20 @@ +{ + "name": "ua", + "options": { + "months": ["Січень", "Лютий", "Березень", "Квітень", "Травень", "Червень", "Липень", "Серпень", "Вересень", "Жовтень", "Листопад", "Грудень"], + "shortMonths": ["Січ", "Лют", "Бер", "Кві", "Тра", "Чер", "Лип", "Сер", "Вер", "Жов", "Лис", "Гру"], + "days": ["Неділя", "Понеділок", "Вівторок", "Середа", "Четвер", "П'ятниця", "Субота"], + "shortDays": ["Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"], + "toolbar": { + "exportToSVG": "Зберегти SVG", + "exportToPNG": "Зберегти PNG", + "menu": "Меню", + "selection": "Вибір", + "selectionZoom": "Вибір із збільшенням", + "zoomIn": "Збільшити", + "zoomOut": "Зменшити", + "pan": "Переміщення", + "reset": "Скинути збільшення" + } + } +} diff --git a/man/ax_chart.Rd b/man/ax_chart.Rd index 1151ec8..59f3834 100644 --- a/man/ax_chart.Rd +++ b/man/ax_chart.Rd @@ -9,6 +9,8 @@ ax_chart( type = NULL, stacked = NULL, stackType = NULL, + defaultLocale = NULL, + locales = NULL, animations = NULL, background = NULL, foreColor = NULL, @@ -33,7 +35,14 @@ ax_chart( \item{stacked}{Logical. Enables stacked option for axis charts.} -\item{stackType}{When stacked, should the stacking be percentage based or normal stacking. Available options: \code{"normal"} or \code{"100\%"}} +\item{stackType}{When stacked, should the stacking be percentage based or normal stacking. +Available options: \code{"normal"} or \code{"100\%"}.} + +\item{defaultLocale}{Locale to use : \code{"de"}, \code{"el"}, \code{"en"}, \code{"es"}, \code{"fr"}, +\code{"hi"}, \code{"hr"}, \code{"hy"}, \code{"id"}, \code{"it"}, \code{"ko"}, \code{"pt-br"}, +\code{"ru"}, \code{"tr"}, \code{"ua"}.} + +\item{locales}{Array of custom localizations paremeters.} \item{animations}{A list of parameters.} @@ -77,13 +86,13 @@ data("diamonds", package = "ggplot2") 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\%") @@ -91,6 +100,39 @@ apex( apex( data = count(diamonds, cut, color), mapping = aes(x = cut, y = n, fill = color) -) \%>\% +) \%>\% ax_chart(toolbar = list(show = FALSE)) + + + +# Use included localization config +dat <- data.frame( + x = Sys.Date() + 1:20, + y = sample.int(20, 20) +) + +# French +apex(dat, aes(x, y), "line") \%>\% + ax_chart(defaultLocale = "fr") + +# Italian +apex(dat, aes(x, y), "line") \%>\% + ax_chart(defaultLocale = "it") + + + +# Custom config +apex(dat, aes(x, y), "line") \%>\% + ax_chart(locales = list( + list( + name = "en", # override en locale + options = list( + toolbar = list( + exportToSVG = "GET SVG", + exportToPNG = "GET PNG" + ) + ) + ) + )) + }