Javascript amchart CHART CHANGE点击按钮

Javascript amchart CHART CHANGE点击按钮,javascript,jquery,amcharts,Javascript,Jquery,Amcharts,我正在尝试更改我单击的项目符号的图像(在图表中) 而且它不会影响任何人 我正在尝试使用eventlistner,并更改函数中项的属性。但不知何故,它对用户界面没有任何影响 有人知道为什么吗 $(document).ready(function () { Try(); }); function Randomize() { return Math.floor((Math.random() * 10) + 1); } func

我正在尝试更改我单击的项目符号的图像(在图表中) 而且它不会影响任何人

我正在尝试使用eventlistner,并更改函数中项的属性。但不知何故,它对用户界面没有任何影响

有人知道为什么吗

 $(document).ready(function () {

        Try();

    });

    function Randomize() {

        return Math.floor((Math.random() * 10) + 1);
    }

    function Try() {

        var chart = AmCharts.makeChart("chartdiv", {
            "type": "serial",
            "theme": "none",
            "pathToImages": "http://www.amcharts.com/lib/3/images/",
            "dataProvider":

                buildMe()

            ,

            "balloon": {
                "cornerRadius": 6
            },
            "valueAxes": [{
                "duration": "mm",
                "durationUnits": {
                    "hh": "h ",
                    "mm": "min"
                },
                "axisAlpha": 0
            }],
            "graphs": [{
                "bullet": "square",
                "bulletSize": 14,
                "customBullet": "http://www.amcharts.com/lib/3/images/star.png",
                "bulletBorderAlpha": 1,
                "bulletBorderThickness": 1,
                "fillAlphas": 0.3,
                "fillColorsField": "lineColor",
                "legendValueText": "[[value]]",
                "lineColorField": "lineColor",
                "customBulletField": "customBullet",
                "title": "duration",
                "valueField": "duration"
            }],
            "chartScrollbar": {},
            "chartCursor": {
                "categoryBalloonDateFormat": "YYYY MMM DD",
                "cursorAlpha": 0,
                "zoomable": false
            },
            "dataDateFormat": "YYYY-MM-DD",
            "categoryField": "date",
            "categoryAxis": {
                "dateFormats": [{
                    "period": "DD",
                    "format": "DD"
                }, {
                    "period": "WW",
                    "format": "MMM DD"
                }, {
                    "period": "MM",
                    "format": "MMM"
                }, {
                    "period": "YYYY",
                    "format": "YYYY"
                }],
                "parseDates": true,
                "autoGridCount": false,
                "axisColor": "#555555",
                "gridAlpha": 0,
                "gridCount": 50
            }
        });
         var graph = new AmCharts.AmGraph();
        chart.addListener("clickGraphItem", ChangePan,$(this));

    }


    function ChangePan(event) {
        event.item.dataContext.customBullet = "http://www.amcharts.com/lib/3/images/redstar.png";
        event.item.lineColor = "http://www.amcharts.com/lib/3/images/redstar.png";
         console.log(event.item.dataContext.customBullet);
        console.log(event.item);
    }

    function buildMe() {
        console.log('im in ?')
        var mystring = "";
        var year = 0;
        var month = 0;
        var session = 6;
        var training = 7;

        mystring += "[";
        for (var j = 0; j < training + 1; j++) {

            mystring += '{';


            if (Randomize() < 7) {
                mystring += '"lineColor": "#2498d2",';
            }
            else {
                mystring += '"lineColor": "#1153e6",';
            }
            mystring += ' "date": "2015-07-'+ j +'", "duration": ';

            mystring += Randomize();

           // mystring += ',"customBullet": "http://www.amcharts.com/lib/3/images/redstar.png"';

            if (training == j) {
                mystring += "}";
            }
            else {
                mystring += "},";
            }


        }
        mystring += "]";
        console.log(mystring)
        console.log(JSON.parse(mystring))
        return JSON.parse(mystring);
    }
$(文档).ready(函数(){
Try();
});
函数随机化(){
返回Math.floor((Math.random()*10)+1);
}
函数Try(){
var chart=AmCharts.makeChart(“chartdiv”{
“类型”:“串行”,
“主题”:“无”,
“路径图像”:http://www.amcharts.com/lib/3/images/",
“数据提供者”:
buildMe()
,
“气球”:{
“转弯半径”:6
},
“价值轴”:[{
“持续时间”:“毫米”,
“持续时间单位”:{
“hh”:“h”,
“mm”:“min”
},
“axisAlpha”:0
}],
“图表”:[{
“子弹”:“方形”,
“bulletSize”:14,
“自定义项目符号”:http://www.amcharts.com/lib/3/images/star.png",
“Bullet BorderAlpha”:1,
“厚度”:1,
“填充字母”:0.3,
“fillColorsField”:“lineColor”,
“legendValueText”:“[[value]]”,
“lineColorField”:“lineColor”,
“customBulletField”:“customBullet”,
“标题”:“期限”,
“valueField”:“持续时间”
}],
“图表滚动条”:{},
“图表光标”:{
“categoryBalloonDateFormat”:“YYYY MMM DD”,
“cursorAlpha”:0,
“可缩放”:错误
},
“数据日期格式”:“YYYY-MM-DD”,
“类别字段”:“日期”,
“分类法”:{
“日期格式”:[{
“期间”:“DD”,
“格式”:“DD”
}, {
“期间”:“WW”,
“格式”:“MMM DD”
}, {
“期间”:“MM”,
“格式”:“嗯”
}, {
“期间”:“YYYY”,
“格式”:“YYYY”
}],
“parseDates”:正确,
“自动签名计数”:错误,
“axisColor”:“#555555”,
“gridAlpha”:0,
“网格计数”:50
}
});
var-graph=新的AmCharts.AmGraph();
addListener(“单击Graphitem”,ChangePan,$(此));
}
功能更改(事件){
event.item.dataContext.customBullet=”http://www.amcharts.com/lib/3/images/redstar.png";
event.item.lineColor=”http://www.amcharts.com/lib/3/images/redstar.png";
log(event.item.dataContext.customBullet);
console.log(event.item);
}
函数buildMe(){
console.log('im-in?'))
var mystring=“”;
var年=0;
var月=0;
var会话=6;
var训练=7;
mystring+=“[”;
对于(var j=0;j

这是我的。

AmCharts不会侦听dataContext更改,因此您必须使用
validateData()
自己执行此操作。 但是,当图表完全重新绘制时,该点将失去悬停状态。