javascript - 在 amchart 中用折线图显示条形线上的背景阴影

标签 javascript amcharts

目前,我有一个由条形图和折线图组合而成的图表,我想在折线图上显示阴影,有什么方法可以在背景上显示阴影 这是创建折线图的示例代码 enter image description here

                objGraph.fillAlphas = 0;
                objGraph.lineAlpha = 0.7;
                objGraph.type = "line";
                objGraph.title = "îàæï";
                objGraph.lineThickness = 4;
                //objGraph.lineColor = "#" + 
                objChartData.lstSerieses[j].Color;
                objGraph.lineColor = "#fff";
                //objGraph.customBullet = "images/star.png"; // bullet for all data points
                objGraph.bullet = "round";
                objGraph.bulletSize = 11;
                objGraph.bulletColor = "#fff";
                objGraph.bulletBorderColor = "#000";
                objGraph.bulletBorderThickness = 2;
                objGraph.bulletBorderAlpha = 1;
                //objGraph.bulletSize = 14; // bullet image should be a 
               rectangle (width = height)
                objGraph.customBulletField = "bullet"; // this will make the graph to display custom bullet (red star)
                objGraph.bulletSizeField = "bulletSize";
                objGraphdescriptionField = "description";

最佳答案

我找到了在折线图中的线上制作阴影的解决方案。首先,您必须创建一个 JSON 对象,用于创建阴影,例如

     var defs = {
        "filter" : {
            "id": "dropshadow",  // id for the line shadow
            "x": "-10%",   // position from x axis
            "y": "-10%",   // position from y axis
            "width": "120%", // width of shadow
            "height": "120%",  //height of shadow
            "feOffset": {
              "result": "offOut",
              "in": "SourceAlpha",
              "dx": "0",  //position from adjecent line along x axis
              "dy": "12"  //position from adjecent line along y axis
            },
            "feGaussianBlur": {
              "result": "blurOut",
              "in": "offOut",
              "stdDeviation": "5"
            },
            "feBlend": {
              "in": "SourceGraphic",
              "in2": "blurOut",
              "mode": "normal"
            }
        }
    };

然后,当您绑定(bind)图表数据时,只需将该 JSON 对象添加到图表即可

chart.defs = defs;  //def object
var chart = AmCharts.makeChart("amchartdiv", chart, theme); 

关于javascript - 在 amchart 中用折线图显示条形线上的背景阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47130668/

相关文章:

javascript - Angularjs ng-style 触发太快

javascript - 如何将 HTML 添加到 amcharts 中的面板标题

c# - amCharts:帮助 WPF MVVM 数据绑定(bind)?

javascript - 如何使用 JS/Jquery 过滤日期和 JSON 数据

javascript - 根据子元素正确居中div

jquery - 如何在amcharts的 donut chart 中使用多种颜色?

javascript - 如何在此 amchart 示例代码中显示 y 轴值?

javascript - 单击 AmCharts 的自定义标记时触发 Javascript 函数

javascript - lodash 在深层嵌套数组和对象上使用 map

javascript - XMLHttpRequest.readyState