Giter Club home page Giter Club logo

Comments (9)

JiangShuLiang avatar JiangShuLiang commented on May 29, 2024

cgi-bin_mmwebwx-bin_webwxgetmsgimg_ MsgID=7898734967138859978 skey=@crypt_801aab47_6c67a647e7211bcc7e40c2d97907b279 mmweb_appid=wx_webfilehelper

from aachartcore.

AAChartModel avatar AAChartModel commented on May 29, 2024

同样的代码, 在其他版本的系统上也有这个问题吗?

from aachartcore.

AAChartModel avatar AAChartModel commented on May 29, 2024

看你的截图, 似乎不用设置成透明颜色, 直接设置 AAChartModel 对象的背景色和整个大屏同色, 应该也行吧?

public class AAChartModel {
    ...
    public Object backgroundColor; //图表背景色
    ...
    public AAChart backgroundColor(Object prop) {
        backgroundColor = prop;
        return this;
    }
    ...
}

from aachartcore.

JiangShuLiang avatar JiangShuLiang commented on May 29, 2024

看你的截图, 似乎不用设置成透明颜色, 直接设置 AAChartModel 对象的背景色和整个大屏同色, 应该也行吧?

public class AAChartModel {
    ...
    public Object backgroundColor; //图表背景色
    ...
    public AAChart backgroundColor(Object prop) {
        backgroundColor = prop;
        return this;
    }
    ...
}

需要设成透明色的唉,因为整个背景是个地图(只是截图里没显示出来)。这个backgroundColor好像不支持透明色,我设成“#00000000”最终显示出来是白色底的

from aachartcore.

JiangShuLiang avatar JiangShuLiang commented on May 29, 2024

同样的代码, 在其他版本的系统上也有这个问题吗?

不会,在模拟器,手机,电视上都安装过,都正常。唯独这个机顶盒里安装不行

from aachartcore.

AAChartModel avatar AAChartModel commented on May 29, 2024

这个backgroundColor好像不支持透明色,我设成“#00000000”最终显示出来是白色底的

AAChartView 是继承自 WebView 的, 这个 backgroundColor 设置是的绘制图表的 <div> 标签的背景色的.

from aachartcore.

AAChartModel avatar AAChartModel commented on May 29, 2024
    public void setIsClearBackgroundColor(Boolean isClearBackgroundColor) {
        this.isClearBackgroundColor = isClearBackgroundColor;
        if (this.isClearBackgroundColor) {
            this.setBackgroundColor(0);
            this.getBackground().setAlpha(0);
        } else {
            this.setBackgroundColor(1);
            this.getBackground().setAlpha(255);
        }
    }

从上面的代码可以看出, setClearBackgroundColor 才是用来设置 WebView 自身为透明色的.

所以 AAChartView 的内部实现里有这段代码

 private void configureChartOptionsAndDrawChart(AAOptions chartOptions) {
        if (isClearBackgroundColor) {
            chartOptions.chart.backgroundColor("rgba(0,0,0,0)"); //这里就是为了避免开发者忘了设置 `<div>` 的透明度
        }

        Gson gson = new Gson();
        String aaOptionsJsonStr = gson.toJson(chartOptions);
        this.optionsJson = aaOptionsJsonStr;
        String javaScriptStr = "loadTheHighChartView('"
                + aaOptionsJsonStr + "','"
                + this.contentWidth + "','"
                + this.contentHeight + "')";
        this.safeEvaluateJavaScriptString(javaScriptStr);
    }

其中

        if (isClearBackgroundColor) {
            chartOptions.chart.backgroundColor("rgba(0,0,0,0)"); //这里就是为了避免开发者忘了设置 `<div>` 的透明度
        }

这段代码, 就是为了避免开发者想要 AAChartView 为透明色, 但是只设置了 setClearBackgroundColor(true) , 而忘了设置 <div> 的透明度.

综上所述, 想要设置 AAChartView 为透明色, 需要同时保证 WebView 自身和绘制图表的 <div> 都是透明色.

from aachartcore.

AAChartModel avatar AAChartModel commented on May 29, 2024

同样的代码, 在其他版本的系统上也有这个问题吗?

不会,在模拟器,手机,电视上都安装过,都正常。唯独这个机顶盒里安装不行

所以这个估计是这个 Android 版本系统自身的 bug, 参考:

这里的解决方案, 在 android 4.4.2 上为 AAChartView 额外补充这段代码:

aaChartView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

这是为了关闭 WebView 的硬件加速功能,因为在某些情况下硬件加速会导致背景不透明.

⚠️注意:关闭硬件加速可能会影响性能,因此仅在必须时才禁用它(你这里应该只要确保系统版本为android 4.4.2时, 添加了这段代码即可).

from aachartcore.

JiangShuLiang avatar JiangShuLiang commented on May 29, 2024

感谢作者!这么详细的解答是我在gayhub上头一次遇到了,真心大写加粗的感谢!!!我这就去试试看!

from aachartcore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.