export d3.format as format

This commit is contained in:
pvictor 2021-09-17 11:17:43 +02:00
parent 7b9df92ee7
commit 090f3d2d37
4 changed files with 9 additions and 9 deletions

View File

@ -10,7 +10,7 @@
#'
#' @return a \code{JS} function
#' @export
#'
#'
#' @importFrom htmlwidgets JS
#'
#' @example examples/format.R
@ -21,7 +21,7 @@ format_num <- function(format, prefix = "", suffix = "", locale = "en-US") {
locale <- paste(readLines(con = path, encoding = "UTF-8"), collapse = "")
}
JS(sprintf(
"function(value) {var locale = d3.formatLocale(JSON.parse('%s')); return '%s' + locale.format('%s')(value) + '%s';}",
"function(value) {var locale = formatLocale(JSON.parse('%s')); return '%s' + locale.format('%s')(value) + '%s';}",
locale, prefix, format, suffix
))
}

File diff suppressed because one or more lines are too long

View File

@ -4,12 +4,11 @@ import {format, formatLocale} from "d3-format";
import * as utils from "../modules/utils";
import "../css/apexcharter.css";
/*
window.d3 = {
format: format,
formatLocale: formatLocale
};
*/
//window['d3.format'] = format;
//window['d3.formatLocale'] = formatLocale;
// add in webpackconfig: output.libraryTarget: 'window'
export { format , formatLocale };
HTMLWidgets.widget({
name: "apexcharter",

View File

@ -61,6 +61,7 @@ var options = {
output: {
filename: '[name].js',
path: path.resolve(__dirname, JSON.parse(outputPath)),
libraryTarget: 'window'
},
externals: externals,
module: {