Skip to content

Commit 5cd79a3

Browse files
committed
fullscreen + more
1 parent 42c460e commit 5cd79a3

File tree

17 files changed

+885
-690
lines changed

17 files changed

+885
-690
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: echarty
22
Title: Minimal R/Shiny Interface to JavaScript Library 'ECharts'
3-
Date: 2022-10-15
4-
Version: 1.4.7.05
3+
Date: 2022-11-03
4+
Version: 1.4.7.06
55
Authors@R: c(
66
person("Larry", "Helgason", email = "larry@helgasoft.com", role = c("cre", "aut", "cph")),
77
person("John", "Coene", role = c("aut", "cph"), comment = "echarts4r library")

NEWS.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
# history of package _echarty_
22

3-
## v.1.4.7.05 in development
3+
## v.1.4.7.06 in development
44

55
- upgrade ECharts to v.5.4.0
66
- added vignette with introduction
77
- _ecr.ebars_ fix bug, enhance tooltips
8-
- _ec.util_ improvements in sf.series, added support for 3D, morph
8+
- _ec.util_ improvements in sf.series
9+
- _ec.util_ new commands _fullscreen_, _morph_, _rescale_
10+
- _ec.clmn_ new options 'json' and 'log'
11+
- _ec.init_ added visualMap$dimension counting in R
912
- fixes to global options theme & font, group legend
10-
- fixed load='world' with series set
13+
- fixed _load='world'_ with series set
14+
- new _load='lottie'_, lotties's support now built-in
1115
- reorganize crosstalk code
1216

13-
## v.1.4.7
17+
## v.1.4.7 on CRAN
1418

1519
- _ec.util_: add POLYGON/MULTIPOINT, rename param 'type' to 'cmd', new _sf.unzip_
1620
- _ec.util_: new cmd='tabset' to show multiple charts in tabs

R/echarty.R

Lines changed: 666 additions & 597 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ support](https://helgasoft.github.io/echarty/xtalk.html).
2929
## Installation
3030

3131
<!-- [![Github version](https://img.shields.io/github/v/release/helgasoft/echarty?label=github)](https://github.com/helgasoft/echarty/releases) -->
32-
Latest development build <strong>1.4.7<sup>.05</sup></strong>
32+
Latest development build <strong>1.4.7<sup>.06</sup></strong>
3333

3434
``` r
3535
if (!requireNamespace('remotes')) install.packages('remotes')

inst/htmlwidgets/echarty.js

Lines changed: 89 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ HTMLWidgets.widget({
2222
echarts.registerTheme(x.theme, tcode);
2323
}
2424
}
25+
2526
if(x.hasOwnProperty('registerMap')){
2627
for( let map = 0; map < x.registerMap.length; map++){
2728
if (x.registerMap[map].geoJSON)
@@ -33,6 +34,13 @@ HTMLWidgets.widget({
3334
}
3435
}
3536

37+
ecfun.hwid = el.id;
38+
if (window.onresize==undefined)
39+
window.onresize = function() {
40+
chart.resize();
41+
ecfun.fs = ecfun.IsFullScreen(); // handle ESC key
42+
}
43+
3644
let eva2 = eva3 = null;
3745
if (x.hasOwnProperty('jcode')) {
3846
if (x.jcode) {
@@ -69,26 +77,15 @@ HTMLWidgets.widget({
6977
} catch(err) { console.log('eva3: ' + err.message) }
7078
}
7179

72-
load = opts.load;
73-
if (Array.isArray(load)) load = load.join();
74-
if (load && load.includes('lottie-parser')) {
75-
lottieParser.install(echarts);
76-
// lottie without timeline
77-
tmp = chart.getModel().option.graphic;
78-
if (tmp) {
79-
tmp = updLGraphic(tmp);
80+
if (opts.graphic && lottieParser) {
81+
tmp = ecfun.lottieGraphic(opts.graphic);
8082
chart.setOption({graphic: tmp}, { replaceMerge: 'graphic'});
81-
}
8283
}
8384

8485
// TODO: timeline to include graphic, etc. (ECUnitOption, OptionManager ?)
8586
// find how to set timeline 'options'...
86-
// tmp = chart.getModel()._optionManager._timelineOptions;
87-
// if (tmp) {
88-
// tmp = updGraphic(tmp);
89-
// //tmp.forEach((opt) => { if (opt.graphic) opt.graphic = updGraphic(opt.graphic); });
90-
// // chart.setOption({options: tmp}, { replaceMerge: 'graphic'});
91-
// }
87+
// tmp = chart.getModel()._optionManager._timelineOptions;
88+
// if (tmp) { }
9289

9390
if (HTMLWidgets.shinyMode) { // shiny callbacks
9491

@@ -225,15 +222,15 @@ HTMLWidgets.widget({
225222

226223
ct_filter.on('change', function(e) { // external keys to filter
227224
if (e.sender == ct_filter) return;
228-
if (e.value == undefined) return;
225+
if (e.value == undefined) e.value = []; // sent by filter_checkbox ?!
229226
// if (chart.sele.length>0) { // clear selection(s) before new filter
230227
// chart.dispatchAction({type: 'unselect', // works for self only
231228
// seriesIndex: chart.sext, dataIndex: chart.sele });
232229
// chart.sele = [];
233230
// }
234231

235-
rexp = '^('+ e.value.join('|') +')$';
236-
if (e.value.length == chart.akeys.length) rexp <- '^'
232+
rexp = (e.value.length == chart.akeys.length ||
233+
e.value.length == 0) ? '^' : '^('+ e.value.join('|') +')$';
237234
opt = chart.getOption();
238235
dtf = opt.dataset.find(x => x.id === 'Xtalk');
239236
dtf.transform = {type: 'filter', config:
@@ -263,33 +260,6 @@ HTMLWidgets.widget({
263260
}
264261
});
265262

266-
updLGraphic = (tmp) => {
267-
// transform lottie graphic element
268-
if (tmp==undefined) return tmp;
269-
for(i=0; i<tmp.length; i++) {
270-
if (!tmp[i].elements) continue;
271-
grf = tmp[i];
272-
grf.elements.forEach((elem) => {
273-
//if (elem.id && !elem.id.startsWith('lottie')) return;
274-
loty = elem;
275-
data = loty.info; if (!data) return;
276-
delete loty.info;
277-
if (!data.v || data.v.search('\\d\\.\\d\\.\\d')<0) return;
278-
loop= loty.loop; if (loop==undefined) loop = true;
279-
const { elements, width, height } = lottieParser.parse(data, {loop: loop});
280-
scale= loty.scale;
281-
if (scale) {
282-
delete loty.scale;
283-
const sfactor = scale / Math.min(width, height);
284-
loty.scaleX= sfactor; loty.scaleY= sfactor;
285-
}
286-
loty.type= 'group'; loty.children= elements;
287-
elem = loty;
288-
});
289-
};
290-
return tmp;
291-
}
292-
293263
function get_e_charts(id){
294264

295265
let htmlWidgetsObj = HTMLWidgets.find("#" + id);
@@ -321,6 +291,80 @@ function get_e_charts_opts(id){
321291
function distinct(value, index, self) {
322292
return self.indexOf(value) === index;
323293
}
294+
295+
// extra functions
296+
ecfun = {
297+
IsFullScreen: function() {
298+
var full_screen_element = document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement || null;
299+
if (full_screen_element === null)
300+
return false;
301+
else
302+
return true;
303+
},
304+
305+
fs: false, // fullscreen flag Y/N
306+
fscreen: function() {
307+
// see also window.onresize
308+
function GoInFullscreen(element) {
309+
if (element.requestFullscreen)
310+
element.requestFullscreen();
311+
else if (element.mozRequestFullScreen)
312+
element.mozRequestFullScreen();
313+
else if (element.webkitRequestFullscreen)
314+
element.webkitRequestFullscreen();
315+
else if (element.msRequestFullscreen)
316+
element.msRequestFullscreen();
317+
}
318+
function GoOutFullscreen() {
319+
if (document.exitFullscreen)
320+
document.exitFullscreen();
321+
else if (document.mozCancelFullScreen)
322+
document.mozCancelFullScreen();
323+
else if (document.webkitExitFullscreen)
324+
document.webkitExitFullscreen();
325+
else if (document.msExitFullscreen)
326+
document.msExitFullscreen();
327+
}
328+
329+
if (this.fs) {
330+
if (this.IsFullScreen())
331+
GoOutFullscreen();
332+
}
333+
else {
334+
tmp = document.getElementById(ecfun.hwid);
335+
GoInFullscreen(tmp)
336+
}
337+
this.fs = !this.fs;
338+
},
339+
340+
lottieGraphic: function(vv) {
341+
// transform lottie graphic element
342+
if (vv==undefined) return vv;
343+
if (vv.length) return vv;
344+
if (!vv.elements) return vv;
345+
vv.elements.forEach((elem) => {
346+
loty = elem;
347+
data = loty.info;
348+
if (!data) return;
349+
delete loty.info;
350+
if (!data.v || data.v.search('\\d\\.\\d\\.\\d')<0) return; // not a lottie
351+
if (lottieParser==undefined) return;
352+
lottieParser.install(echarts);
353+
loop= loty.loop; if (loop==undefined) loop = true;
354+
const { elements, width, height } = lottieParser.parse(data, {loop: loop});
355+
scale= loty.scale;
356+
if (scale) {
357+
delete loty.scale;
358+
const sfactor = scale / Math.min(width, height);
359+
loty.scaleX= sfactor; loty.scaleY= sfactor;
360+
}
361+
loty.type= 'group'; loty.children= elements;
362+
elem = loty;
363+
});
364+
return vv;
365+
}
366+
367+
};
324368

325369
if (HTMLWidgets.shinyMode) {
326370

inst/js/lottie-parser.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inst/themes/dark-mushroom.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@
114114
fillerColor: 'rgba(200,200,200,0.2)', // Fill the color
115115
handleColor: '#cc0e00' // Handle color
116116
},
117-
117+
visualMap: {
118+
textStyle: {
119+
color: '#bbb'
120+
}
121+
},
122+
118123
timeline: {
119124
itemStyle: {
120125
color: '#aaa' //colorPalette[1]

man/Introduction.Rd

Lines changed: 16 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/ec.clmn.Rd

Lines changed: 15 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/ec.init.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)