简体   繁体   English

使用ChartJs Chart中的调整半径大小

[英]Resize the radius with in ChartJs Chart

在此处输入图片说明

Im using ChartJs for "doughnut-pie-chart". 我正在使用ChartJs作为“甜甜圈饼图”。 The default radius is much bigger than what I expect,. 默认半径比我期望的要大得多。 Is there and way to resize the radius width.? 是否有调整半径宽度大小的方法?

The documentatin part did not provide any info. documentatin部分未提供任何信息。

  $( document ).ready(function() {
    var ctx = document.getElementById("chart-area").getContext("2d");

    new Chart(ctx).Doughnut(doughnutData, {responsive : true});
  });

Extend the Doughnut chart to set the outerRadius (perhaps using an option that you pass in) after the prototype's initialization 原型初始化后,扩展甜甜圈图以设置outerRadius(也许使用您传入的选项)

Chart.types.Doughnut.extend({
    name: "DoughnutAlt",
    initialize: function(data){
        Chart.types.Doughnut.prototype.initialize.apply(this, arguments);
        this.outerRadius *= this.options.radiusPercentage;
    }
});

and then use the extended chart type 然后使用扩展的图表类型

var ctx = document.getElementById("chart-area").getContext("2d");
var myNewChart = new Chart(ctx).DoughnutAlt(doughnutData, {
    responsive : true,
    radiusPercentage: 0.8
});     

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM