【问题标题】:Changing the opacity of the colour on the Polar Area chart更改极区图上颜色的不透明度
【发布时间】:2022-01-18 06:35:39
【问题描述】:

我正在使用 Chart.js 创建一组极区图表,我想更改用于显示数据的颜色的不透明度,使其略微透明。

您将在下面找到代码:

var totals = {{ class_submission_totals|safe }}
    {% for t in type_qs %}
        var labels_{{ t.pk }} = []
        var backgroundColors_{{ t.pk }} = []
        {% for b in behaviour_qs %}
            {% if b.type.pk == t.pk and not b.previous %}
                labels_{{ t.pk }}.push("{{ b.title }}")
                backgroundColors_{{ t.pk }}.push("{{ b.primarycolour }}")
            {% endif %}
        {% endfor %}
    {% endfor %}
  
      
            new Chart("chart_{{ i.pk }}_{{ t.pk }}", {
              type: "polarArea",
              data: {
                labels: labels_{{ t.pk }},
                datasets: [{
                  fillOpacity: 0.3,
                  pointRadius: 1,
                  backgroundColor: backgroundColors_{{ t.pk }},
                  data: totals_{{ i.pk }}_{{ t.pk }}_arr,
                }]
              },
              options: {
                responsive: false,
                maintainAspectRatio: true,
                plugins: {
                    legend: {
                        display: true,
                    },
                    title: {
                        display: false,
                        text: 'Chart.js Polar Area Chart'
                    }
                }
              }
            });

        {% endfor %}
    {% endfor %}

【问题讨论】:

标签: python jquery django charts chart.js


【解决方案1】:

使用 w3schools.com/cssref/func_rgba.asp 我更改了 django adim 中的值并将原色设置为 rgba 值,这使它们变得透明

例如: rgba(255,0,0,0.5)

【讨论】:

    猜你喜欢
    • 2018-08-30
    • 2016-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-14
    • 2018-11-15
    • 2021-10-26
    相关资源
    最近更新 更多