javascript - Chart.js 图例位置错误

标签 javascript typescript charts chart.js chart.js2

我尝试将饼图的图例(使用 Chart.js 2.0 创建)向左或向右移动,但总是出现错误。底部和顶部选项有效。

var myChart = new Chart(ctx, {
        type: 'pie',
        data: {
            labels: optionLabels,
            datasets: [{
                label: '# of Resources',
                data: optionData,
                backgroundColor: optionColor,
                borderColor: "white",
                borderWidth: 1,

            }]
        },
        options: {
            legend: {
                position: 'left'
            }
        }
    });

enter image description here

是否存在库错误或类似问题?

最佳答案

似乎您正在使用旧版本的 ChartJS (可能有此错误)

确保您使用最新版本的 ChartJS,目前为 2.7.0

查看working example .

关于javascript - Chart.js 图例位置错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46149874/

相关文章:

javascript - jQuery:来自 URL 的变量,带有 ÆØÅ 等等

javascript - java 中的 3e5 for android

c# - 如何使用 C# 在 Excel 图表中添加虚线网格?

jquery - 使用flot jquery实时图表

JavaScript 增量器

javascript - 将日期更改为 00 :00:00 format

typescript - 如何将一个方法的签名复制到另一个方法?

reactjs - 在 Typescript 中使用 useContext 传递状态

安卓 AChartEngine : SalesComparisonChart lines do not reach the exact value

javascript - Angular 的 ng-options 没有正确显示默认值