Javascript Chart.js气泡图点样式不工作

Javascript Chart.js气泡图点样式不工作,javascript,charts,chart.js,bubble-chart,Javascript,Charts,Chart.js,Bubble Chart,我正在使用chart.js气泡图。我正在尝试将圆点样式更改为其他样式。我已经尝试了所有基于文档的方法,但仍然无法使其正常工作。有人能帮我理解我做错了什么吗 Chart.defaults.global.elements.point.pointStyle = 'star'; Chart.defaults.global.elements.point.backgroundColor = 'rgba(255,255,255,1)'; Chart.defaults.global.elements.poin

我正在使用chart.js气泡图。我正在尝试将圆点样式更改为其他样式。我已经尝试了所有基于文档的方法,但仍然无法使其正常工作。有人能帮我理解我做错了什么吗

Chart.defaults.global.elements.point.pointStyle = 'star';
Chart.defaults.global.elements.point.backgroundColor = 'rgba(255,255,255,1)';

Chart.defaults.global.elements.point.radius = 20;

var data = {
datasets:[{
        pointStyle:      'triangle',
        //pointRadius:     8,
//          data:[ 27, 33, 49 ],
        data:[{ x:0, y: 0}]
    }]
};
var options = {
                responsive: true,
                title:{
                    display:true,
                    text:'Chart.js Bubble Chart'
                },
                tooltips: {
                    mode: 'point'
                }
            };
var canvas = document.getElementById('myChart');

var myBubbleChart = new Chart(canvas,{
type: 'bubble',
data: data,
options: options
});0
我可以更改折线图,但似乎不可能让气泡图更改点样式


很明显,这是行不通的,因为点样式只适用于折线图(有点悬停)。不幸的是,也没有任何本机选项来实现这一点

然而,这种云可能是通过某种黑客的方式实现的,即覆盖气泡图的实际
draw
功能

ᴏᴠᴇʀʀɪᴅᴇ ᴛʜᴇ ᴅʀᴀᴡ ꜰᴜɴᴄᴛɪᴏɴ ᴏꜰ ʙᴜʙʙʟᴇ ᴄʜᴀʀᴛ

Chart.controllers.bubble.prototype.draw = function() {
   let c = this.chart; // chart instance
   let datasets = c.data.datasets; // datasets array
   datasets.forEach(function(e, i) { // loop through the datasets array
      let isHidden = e._meta[0].hidden; // dataset's hidden property
      if (!isHidden) { // if dataset is not hidden
         let data = c.getDatasetMeta(i).data; // coords array of bubble
         data.forEach(function(e) { // loop through the coords array
            let ctx = c.chart.ctx; // canvas context
            let x = e._model.x; // x coord of bubble
            let y = e._model.y; // y coord of bubble
            let r = e._model.radius; // radius of bubble
            let bgColor = e._model.backgroundColor; // background color of bubble

            /** draw anything using general canvas methods **/
            // draw a triangle
            ctx.save();
            ctx.moveTo(x, y - r);
            ctx.lineTo(x + r, y + r);
            ctx.lineTo(x - r, y + r);
            ctx.closePath();
            ctx.fillStyle = bgColor;
            ctx.fill();
            ctx.restore();
         });
      }
   });
}
ᴡᴏʀᴋɪɴɢ ᴇxᴀᴍᴘʟᴇ ⧩

Chart.controllers.bubble.prototype.draw=function(){
设c=this.chart;//图表实例
让datasets=c.data.datasets;//数据集数组
forEach(函数(e,i){//通过datasets数组循环
设isHidden=e.。\u meta[0]。隐藏;//数据集的隐藏属性
如果(!ishiden){//如果数据集未隐藏
让data=c.getDatasetMeta(i).data;//气泡的coords数组
forEach(函数(e){//通过coords数组循环
设ctx=c.chart.ctx;//画布上下文
设x=e._model.x;//x泡泡坐标
设y=e._model.y;//y泡泡坐标
设r=e.\u model.radius;//气泡半径
设bgColor=e.\u model.backgroundColor;//气泡的背景色
/**使用常规画布方法绘制任何内容**/
//画一个三角形
ctx.save();
ctx.moveTo(x,y-r);
ctx.lineTo(x+r,y+r);
ctx.lineTo(x-r,y+r);
ctx.closePath();
ctx.fillStyle=bgColor;
ctx.fill();
ctx.restore();
});
}
});
}
风险值数据={
数据集:[{
标签:“数据集1”,
数据:[
{x:6,y:6,r:10},
{x:12,y:12,r:15}
],
背景颜色:“#07C”
}]
};
变量选项={
回答:错,
比例:{
xAxes:[{ticks:{min:0,max:20}}],
雅克斯:[{ticks:{min:0,max:20}]
},
标题:{
显示:对,
文本:“Chart.js气泡图”
}
};
var canvas=document.getElementById('myChart');
var myBubbleChart=新图表(画布{
类型:'气泡',
数据:数据,
选项:选项
});


这可能是一个bug。也许你可以制造一个问题:是的,整晚禁止我的预演。将为它创建一个bug。谢谢