Skip to content

Commit

Permalink
simplifying
Browse files Browse the repository at this point in the history
  • Loading branch information
jbkunst committed Feb 1, 2019
1 parent 6d8f3ba commit e12c461
Show file tree
Hide file tree
Showing 688 changed files with 615,644 additions and 33,113 deletions.
7 changes: 0 additions & 7 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,14 @@ export(hc_zAxis)
export(hcaes)
export(hcaes_)
export(hcaes_string)
export(hcbar)
export(hcboxplot)
export(hcdensity)
export(hchart)
export(hchist)
export(hciconarray)
export(hcmap)
export(hcparcords)
export(hcpie)
export(hcspark)
export(hctreemap)
export(hctreemap2)
export(hcts)
export(hex_to_rgba)
export(highchart)
export(highchart2)
Expand Down Expand Up @@ -215,8 +210,6 @@ importFrom(rlang,parse_quosure)
importFrom(rlang,syms)
importFrom(rlist,list.merge)
importFrom(rlist,list.parse)
importFrom(stats,as.ts)
importFrom(stats,density)
importFrom(stats,ecdf)
importFrom(stats,qnorm)
importFrom(stats,setNames)
Expand Down
52 changes: 0 additions & 52 deletions R/hchart-shorcuts.R
Original file line number Diff line number Diff line change
@@ -1,55 +1,3 @@
#' Shortcut to make a bar chart
#' @param x A character or factor vector.
#' @param ... Additional arguments for the data series \url{http://api.highcharts.com/highcharts#series}.
#' @export
hcbar <- function(x, ...) {
stopifnot(is.character(x) | is.factor(x))
hchart(x, ...)
}

#' Shortcut to make a pie chart
#' @param x A character o factor vector.
#' @param ... Additional arguments for the data series \url{http://api.highcharts.com/highcharts#series}.
#' @export
hcpie <- function(x, ...) {
stopifnot(is.character(x) | is.factor(x))
hchart(x, type = "pie", ...)
}

#' Shortcut to make an histogram
#' @param x A numeric vector.
#' @param ... Additional arguments for the data series \url{http://api.highcharts.com/highcharts#series}.
#' @export
hchist <- function(x, ...) {
stopifnot(is.numeric(x))
hchart(x, ...)
}

#' Shortcut to make time series or line charts
#' @param x A numeric vector or a time series object.
#' @param ... Additional arguments for the data series \url{http://api.highcharts.com/highcharts#series}.
#' @importFrom stats as.ts
#' @export
hcts <- function(x, ...) {
hchart(as.ts(x), ...)
}

#' Shortcut to make density charts
#' @param x A numeric vector or a density object.
#' @param ... Additional arguments for the data series \url{http://api.highcharts.com/highcharts#series}.
#' @importFrom stats density
#' @export
hcdensity <- function(x, ...) {

stopifnot(inherits(x, "density") || inherits(x, "numeric"))

if (class(x) == "numeric")
x <- density(x)

hchart(x, ...)

}

#' Shortcut to make spkarlines
#' @param x A numeric vector.
#' @param type Type sparkline: line, bar, etc.
Expand Down
2 changes: 1 addition & 1 deletion R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ color_classes <- function(breaks = NULL,
#'
#' @examples
#'
#' get_hc_series_from_df(iris, type = "point", x = Sepal.Width)
#' highcharter:::get_hc_series_from_df(iris, type = "point", x = Sepal.Width)
#'
#' @importFrom tibble has_name
get_hc_series_from_df <- function(data, type = NULL, ...) {
Expand Down
4 changes: 3 additions & 1 deletion R/highcharts-api-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ hc_elementId <- function(hc, id = NULL) {
#'
#' @examples
#'
#' hc_size(hcts(rnorm(100)), 400, 200)
#' hc <- hchart(ts(rnorm(100)), showInLegend = FALSE)
#'
#' hc_size(hc, 200, 200)
#'
#' @export
hc_size <- function(hc, width = NULL, height = NULL) {
Expand Down
66 changes: 66 additions & 0 deletions dev/deprecated-hchart-shorcuts.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#' Shortcut to make a bar chart
#' @param x A character or factor vector.
#' @param ... Additional arguments for the data series \url{http://api.highcharts.com/highcharts#series}.
hcbar <- function(x, ...) {

.Deprecated()

stopifnot(is.character(x) | is.factor(x))

hchart(x, ...)

}

#' Shortcut to make a pie chart
#' @param x A character o factor vector.
#' @param ... Additional arguments for the data series \url{http://api.highcharts.com/highcharts#series}
hcpie <- function(x, ...) {

.Deprecated()

stopifnot(is.character(x) | is.factor(x))

hchart(x, type = "pie", ...)

}

#' Shortcut to make an histogram
#' @param x A numeric vector.
#' @param ... Additional arguments for the data series \url{http://api.highcharts.com/highcharts#series}.
hchist <- function(x, ...) {

.Deprecated()

stopifnot(is.numeric(x))

hchart(x, ...)
}

#' Shortcut to make time series or line charts
#' @param x A numeric vector or a time series object.
#' @param ... Additional arguments for the data series \url{http://api.highcharts.com/highcharts#series}.
#' @importFrom stats as.ts
hcts <- function(x, ...) {

.Deprecated()

hchart(as.ts(x), ...)

}

#' Shortcut to make density charts
#' @param x A numeric vector or a density object.
#' @param ... Additional arguments for the data series \url{http://api.highcharts.com/highcharts#series}.
#' @importFrom stats density
hcdensity <- function(x, ...) {

.Deprecated()

stopifnot(inherits(x, "density") || inherits(x, "numeric"))

if (class(x) == "numeric")
x <- density(x)

hchart(x, ...)

}
17 changes: 17 additions & 0 deletions dev/pkgdown-reference-template.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
reference:
- title: "Connecting to Spark"
desc: >
Functions for installing Spark components and managing
connections to Spark
contents:
- spark_config
- spark_connect
- spark_disconnect
- spark_install
- spark_log
- title: "Reading and Writing Data"
desc: "Functions for reading and writing Spark DataFrames."
contents:
- starts_with("spark_read")
- starts_with("spark_write")
- matches("saveload")
6 changes: 6 additions & 0 deletions docs/CODE_OF_CONDUCT.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions docs/CONTRIBUTING.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 25 additions & 22 deletions docs/articles/articles/charting-maps.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
HTMLWidgets.widget({

name: 'highchart',

type: 'output',

initialize: function(el, width, height) {

return {
// TODO: add instance fields as required
};

},

renderValue: function(el, x, instance) {

if(x.debug) {
window.xclone = JSON.parse(JSON.stringify(x));
window.elclone = $(el);
console.log(el);
console.log("hc_opts", x.hc_opts);
console.log("theme", x.theme);
console.log("conf_opts", x.conf_opts);
}

if(x.fonts !== undefined) {

x.fonts = ((typeof(x.fonts) == "string") ? [x.fonts] : x.fonts);

x.fonts.forEach(function(s){
/* http://stackoverflow.com/questions/4724606 */
var urlfont = 'https://fonts.googleapis.com/css?family=' + s;
if (!$("link[href='" + urlfont + "']").length) {
$('<link href="' + urlfont + '" rel="stylesheet" type="text/css">').appendTo("head");
}

});

}

ResetHighchartsOptions();

if(x.theme !== null) {

if(x.debug) console.log("adding THEME");

Highcharts.setOptions(x.theme);

}

if((x.theme && x.theme.chart.divBackgroundImage !== undefined) |
(x.hc_opts.chart && x.hc_opts.chart.divBackgroundImage !== undefined)) {

if(x.debug) console.log("adding BackgroundImage");

var bkgrnd = x.theme.chart.divBackgroundImage || x.hc_opts.chart.divBackgroundImage;

Highcharts.wrap(Highcharts.Chart.prototype, "getContainer", function (proceed) {

proceed.call(this);

$("#" + el.id).css("background-image", "url(" + bkgrnd + ")");
$("#" + el.id).css("-webkit-background-size", "cover");
$("#" + el.id).css("-moz-background-size", "cover");
$("#" + el.id).css("-o-background-size", "cover");
$("#" + el.id).css("background-size", "cover");

});

}

Highcharts.setOptions(x.conf_opts);

if(x.type == "chart") {
if(x.debug) console.log("charting CHART");
$("#" + el.id).highcharts(x.hc_opts);
} else if (x.type == "stock") {
if(x.debug) console.log("charting STOCK");
$("#" + el.id).highcharts('StockChart', x.hc_opts);
} else if (x.type == "map"){
if(x.debug) console.log("charting MAP");

x.hc_opts.series = x.hc_opts.series.map(function(e){
if(e.geojson === true) {
if(x.debug) console.log("geojson\n\t", e.type, "\n\t", typeof(e.series));
e.data = Highcharts.geojson(e.data, e.type);
}
return e;
});

$("#" + el.id).highcharts('Map', x.hc_opts);

if(x.hc_opts.mapNavigation !== undefined && x.hc_opts.mapNavigation.enabled === true){
/* if have navigation option and enabled true: http://stackoverflow.com/questions/7600454 */
$("#" + el.id).bind( 'mousewheel DOMMouseScroll', function ( e ) {
var e0 = e.originalEvent,
delta = e0.wheelDelta || -e0.detail;
this.scrollTop += ( delta < 0 ? 1 : -1 ) * 30;
e.preventDefault();

});

}

}

if(x.hc_opts.motion !== undefined) {

$("#" + el.id).css({"position" : "relative" });

if(x.debug) console.log("setting MOTION options");

var pc = $($("#" + el.id).find("#play-controls")[0]);

var ct = x.theme.chart;

if(ct.backgroundColor !== undefined) $(pc.find("#play-pause-button")[0]).css({backgroundColor : x.theme.chart.backgroundColor});
if(ct.style !== undefined) $(pc.find("#play-output")[0]).css(x.theme.chart.style);
if(ct.style !== undefined && ct.style.color !== undefined) $(pc.find("#play-pause-button")[0]).css({color : x.theme.chart.style.color});


}

},

resize: function(el, width, height, instance) {

/* http://stackoverflow.com/questions/18445784/ */
var chart = $("#" +el.id).highcharts();
var w = chart.renderTo.clientWidth;
var h = chart.renderTo.clientHeight;
chart.setSize(w, h);

}

});
Loading

0 comments on commit e12c461

Please sign in to comment.