123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- var aaGlobalChart;
- function loadTheHighChartView (sender,receivedWidth, receivedHeight) {
- var aaOptions = JSON.parse(sender);;
- aaOptions.credits = {enabled:false};//去掉表格右下角版权信息
- if (aaOptions.plotOptions) {
- configurePlotOptions(aaOptions);
- }
- if (aaOptions.tooltip) {
- if (aaOptions.tooltip.formatter) {
- aaOptions.tooltip.formatter = eval(aaOptions.tooltip.formatter);
- }
- }
- aaGlobalChart = Highcharts.chart('container', aaOptions);
- //全局配置(可通过全局配置设置主题)https://api.hcharts.cn/highcharts#Highcharts.setOptions
- };
- function configurePlotOptions(aaOptions) {
- var aaPlotOptions = aaOptions.plotOptions;
- var animation = aaPlotOptions.series.animation;
- if (animation) {//懒调用(只有在 AAChartModel 实例对象设置了 animationType 属性值的时候才会调用设置动画类型的函数,否则不调用)
- var animationEasingType = animation.easing;
- animation.easing = configureTheChartAnimationEasingType(animationEasingType);
- }
- // 添加鼠标事件
- if (aaOptions.touchEventEnabled == true && aaPlotOptions.series) {
- configureChartTouchEvent(aaOptions);
- }
- }
- function configureChartTouchEvent(aaOptions) {
- var mouseOverFunc = function(){
- //console.log(this)
- var message = {
- name: this.series.name,
- y :this.y,
- x: this.x,
- category:this.category,
- offset:{plotX:this.plotX,plotY:this.plotY},
- index: this.index,
- };
- var messageStr = JSON.stringify(message);
- // alert("AAChartViewBridge://?"+ messageStr);
- window.androidObject.androidMethod(messageStr);
- // overrideUrlLoading("AAChartViewBridge://?"+ messageStr);
- };
- var seriesPoint = {
- events:{
- mouseOver: mouseOverFunc,
- // click: mouseOverFunc,
- }
- };
- aaOptions.plotOptions.series.point = seriesPoint;
- }
- function overrideUrlLoading(testOverrideUrlStr) {
- alert(testOverrideUrlStr);
- uiWebViewLoadURL(testOverrideUrlStr);
- }
- function uiWebViewLoadURL(url) {
- var iFrame;
- iFrame = document.createElement("iframe");
- iFrame.setAttribute("src", url);
- iFrame.setAttribute("style", "display:none;");
- iFrame.setAttribute("height", "0px");
- iFrame.setAttribute("width", "0px");
- iFrame.setAttribute("frameborder", "0");
- document.body.appendChild(iFrame);
- iFrame.parentNode.removeChild(iFrame);
- iFrame = null;
- }
- function onlyRefreshTheChartDataWithSeries (receivedSeries) {
- var receivedSeriesElementArr = JSON.parse(receivedSeries);
- for (var i = 0; i < receivedSeriesElementArr.length; i++) {
- var receivedSeriesData = receivedSeriesElementArr[i].data;
- // 获取series
- var chartSeries = aaGlobalChart.series[i];
- // 执行只刷新数据的函数
- chartSeries.setData(receivedSeriesData);
- }
- }
- //pragma mark -- setter method 适应内容https://code.hcharts.cn/highcharts/4YM0a8
- function setTheChartViewContentWidth (receivedWidth) {
- var container = document.getElementById('container');//获得元素
- container.style.width = receivedWidth;//设置宽度
- aaGlobalChart.reflow();
- }
- function setTheChartViewContentHeight (receivedHeight) {
- var container = document.getElementById('container');//获得元素
- container.style.height = receivedHeight;//设置高度
- aaGlobalChart.reflow();
- }
- function setChartSeriesHidden(hidden) {
- for (var i = 0; i < aaGlobalChart.series.length; i++) {
- var series = aaGlobalChart.series[i];
- if (hidden == true) {
- series.hide();
- } else {
- series.show();
- }
- }
- }
- function showTheSeriesElementContentWithIndex (elementIndex) {
- var series = aaGlobalChart.series[elementIndex];
- series.show();
- }
- function hideTheSeriesElementContentWithIndex(elementIndex) {
- var series = aaGlobalChart.series[elementIndex];
- series.hide();
- }
|