• <i id='sRrYZ'><tr id='sRrYZ'><dt id='sRrYZ'><q id='sRrYZ'><span id='sRrYZ'><b id='sRrYZ'><form id='sRrYZ'><ins id='sRrYZ'></ins><ul id='sRrYZ'></ul><sub id='sRrYZ'></sub></form><legend id='sRrYZ'></legend><bdo id='sRrYZ'><pre id='sRrYZ'><center id='sRrYZ'></center></pre></bdo></b><th id='sRrYZ'></th></span></q></dt></tr></i><div id='sRrYZ'><tfoot id='sRrYZ'></tfoot><dl id='sRrYZ'><fieldset id='sRrYZ'></fieldset></dl></div>

    <tfoot id='sRrYZ'></tfoot>

      <small id='sRrYZ'></small><noframes id='sRrYZ'>

      1. <legend id='sRrYZ'><style id='sRrYZ'><dir id='sRrYZ'><q id='sRrYZ'></q></dir></style></legend>
          <bdo id='sRrYZ'></bdo><ul id='sRrYZ'></ul>
      2. 如何在charts.js 中旋转饼图?

        How can I rotate a pie chart in charts.js?(如何在charts.js 中旋转饼图?)

        <small id='hMzVy'></small><noframes id='hMzVy'>

      3. <legend id='hMzVy'><style id='hMzVy'><dir id='hMzVy'><q id='hMzVy'></q></dir></style></legend>

            • <bdo id='hMzVy'></bdo><ul id='hMzVy'></ul>
                <tbody id='hMzVy'></tbody>

                  <i id='hMzVy'><tr id='hMzVy'><dt id='hMzVy'><q id='hMzVy'><span id='hMzVy'><b id='hMzVy'><form id='hMzVy'><ins id='hMzVy'></ins><ul id='hMzVy'></ul><sub id='hMzVy'></sub></form><legend id='hMzVy'></legend><bdo id='hMzVy'><pre id='hMzVy'><center id='hMzVy'></center></pre></bdo></b><th id='hMzVy'></th></span></q></dt></tr></i><div id='hMzVy'><tfoot id='hMzVy'></tfoot><dl id='hMzVy'><fieldset id='hMzVy'></fieldset></dl></div>
                1. <tfoot id='hMzVy'></tfoot>
                  本文介绍了如何在charts.js 中旋转饼图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  看起来像 charts.js 中的饼图是通过在圆的上半部分取垂直半径,然后从那里顺时针移动来绘制的.这在大多数情况下都很好用,但是对于只有 2 个类别的饼图,如果可以旋转它以使切片居中,那就太好了,如下所示:

                  It looks like a pie in charts.js is drawn by taking a vertical radius on the top half of the circle, and then moving clockwise from there. This works great most of the time, but for a pie with only 2 categories, it would be nice if it could be rotated so that the slice is centered, like this:

                  旋转是通过取 360 的百分比并除以 2 来计算的.(.14*360)/2 = 25.2 度左,所以如果我可以申请的话

                  The rotation is calculated by taking the percentage of 360 and dividing by 2. (.14*360)/2 = 25.2 degrees left, so if I could just apply

                  transform: rotate(-25.2deg);
                  

                  到那个圈子我就好了.

                  由于 charts.js 将它放在画布上(而不是 <svg>),我不知道如何对其应用任何转换.不确定是否相关,但这是我的图表代码:

                  Since charts.js puts this on a canvas (as opposed to <svg>) I don't know how to apply any transformations to this. Not sure if relevant, but here is my code for the chart:

                  HTML

                  <canvas id=canvas style='width:300px;height:300px;'></canvas>
                  

                  JS

                  openRate = [
                              {
                                  value: 488,
                                  color: "#FF9030",
                                  highlight: "rgba(255, 144, 48, 0.44)",
                              },
                              {
                                  value: 3475,
                                  color: "#008DB7",
                                  highlight: "rgba(0, 141, 183, 0.82)"
                              }
                          ];
                  
                  var ctx=document.getElementById('canvas').getContext("2d");
                  var chart=new Chart(ctx).Pie(openRate);
                  

                  还有一个小提琴:http://jsfiddle.net/msy6kf3a/

                  推荐答案

                  你可以使用

                  chartjs中的轮换选项

                  我正在使用版本:2.1.6"

                  I'm using "Version: 2.1.6"

                  var options = {
                     rotation: (-0.5 * Math.PI) - (25/180 * Math.PI)
                  }
                  
                  var Chart = new Chart(ctx,{
                    type: 'pie',
                    data: data,
                    options: options
                  });
                  

                  更新了 fiddle

                  这篇关于如何在charts.js 中旋转饼图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ChartJS Version 3 - common legend for multiple line charts(ChartJS 版本 3 - 多个折线图的常用图例)
                  Charts.js scales yaxes ticks min max doesnt work(Charts.js 缩放 yaxes 刻度 min max 不起作用)
                  How to expand the slice of donut chart in chartjs?(如何在chartjs中扩展圆环图的切片?)
                  Chart.js yAxes Ticks stepSize not working (fiddle)(Chart.js yAxes Ticks stepSize 不起作用(小提琴))
                  Rounded corners on chartJS v.2 - bar charts (with negative values)(chartJS v.2 上的圆角 - 条形图(带负值))
                  How to hide value in Chart JS bar(如何在 Chart JS 栏中隐藏值)

                    <legend id='3SNDR'><style id='3SNDR'><dir id='3SNDR'><q id='3SNDR'></q></dir></style></legend>

                      <tbody id='3SNDR'></tbody>
                  1. <small id='3SNDR'></small><noframes id='3SNDR'>

                    <i id='3SNDR'><tr id='3SNDR'><dt id='3SNDR'><q id='3SNDR'><span id='3SNDR'><b id='3SNDR'><form id='3SNDR'><ins id='3SNDR'></ins><ul id='3SNDR'></ul><sub id='3SNDR'></sub></form><legend id='3SNDR'></legend><bdo id='3SNDR'><pre id='3SNDR'><center id='3SNDR'></center></pre></bdo></b><th id='3SNDR'></th></span></q></dt></tr></i><div id='3SNDR'><tfoot id='3SNDR'></tfoot><dl id='3SNDR'><fieldset id='3SNDR'></fieldset></dl></div>
                  2. <tfoot id='3SNDR'></tfoot>
                      • <bdo id='3SNDR'></bdo><ul id='3SNDR'></ul>