【问题标题】:Legends colors are not proper in axlsx stacked bar chartaxlsx 堆积条形图中的图例颜色不正确
【发布时间】:2017-10-19 04:39:32
【问题描述】:

您好,我正在使用 axlsx 在 rails 中生成 excel 文件

在堆叠组 barchat 图例中,颜色不正确。

它不喜欢我的颜色。

sheet.add_chart(Axlsx::Bar3DChart, :start_at => "G2", :end_at => "O15", :title => "#{business_unit}",:barDir => :col,:grouping=> :stacked) do |chart|
    chart.add_series :data => sheet["B3:B6"], :labels => sheet["A3:A6"], :title => sheet["B2"], :colors => ['222','222','222','222']
    chart.add_series :data => sheet["C3:C6"], :labels => sheet["A3:A6"], :title => sheet["C2"], :colors => ['ffff00','ffff00','ffff00','ffff00']
    chart.add_series :data => sheet["D3:D6"], :labels => sheet["A3:A6"], :title => sheet["D2"], :colors => ['ff0000','ff0000','ff0000','ff0000']
    chart.add_series :data => sheet["E3:E6"], :labels => sheet["A3:A6"], :title => sheet["E2"], :colors => ['0f52d6','0f52d6','0f52d6','0f52d6']
   end

详情请看图片。它采用默认颜色不是我的 enter image description here

【问题讨论】:

    标签: ruby axlsx


    【解决方案1】:

    您使用 alpha 通道指定颜色:

    #                                      ⇓⇓⇓⇓⇓⇓⇓⇓
    :colors => ['ffff00','ffff00','ffff00','ffff00']
    

    删除它或设置为1 应该可以解决问题。

    【讨论】:

    • 感谢您的回复。实际上它并没有把标签当作传说。它以标题为图例。因此它采用默认颜色。
    【解决方案2】:

    试试这个,下面为我工作

    :colors => ['FF0000', '00FF00', '0000FF']
    

    【讨论】:

    • 请尝试使用堆叠条形。对于堆叠的 barchat,它不起作用。你能发布你的代码吗?
    猜你喜欢
    • 2017-04-29
    • 1970-01-01
    • 2017-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-02
    相关资源
    最近更新 更多