提交 35304897 编写于 作者: G Georg G

Use defined colour for a language when available

This commit changes the colours of languages in the language graph to
the ones Linguist has defined.  When there is no colour defined for a
language in Linguist, it will fall back to the old method of finding
a colour.
上级 212cf8f9
......@@ -35,15 +35,19 @@ class Projects::GraphsController < Projects::ApplicationController
def languages
@languages = Linguist::Repository.new(@repository.rugged, @repository.rugged.head.target_id).languages
total = @languages.map(&:last).sum
colors = Linguist::Language.colors.
select { |lang| @languages.include? lang.name }.
map { |lang| [lang.name, lang.color] }.
to_h
@languages = @languages.map do |language|
name, share = language
color = Digest::SHA256.hexdigest(name)[0...6]
color = colors[name] || "##{Digest::SHA256.hexdigest(name)[0...6]}"
{
value: (share.to_f * 100 / total).round(2),
label: name,
color: "##{color}",
highlight: "##{color}"
color: color,
highlight: color
}
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册