Module: LcpRuby::Widgets::ChartPalette

Defined in:
lib/lcp_ruby/widgets/chart_palette.rb

Overview

Okabe-Ito colorblind-safe 8-color palette (Wong, 2011, Nature Methods 8:441). Default series colors for chart widgets when no explicit color is supplied.

Constant Summary collapse

COLORS =
%w[
  #0072B2
  #E69F00
  #009E73
  #CC79A7
  #56B4E9
  #D55E00
  #F0E442
  #999999
].map(&:freeze).freeze

Class Method Summary collapse

Class Method Details

.color_for(index, theme: nil) ⇒ Object

Returns the palette color for the given series index, wrapping with modulo. ‘theme:` is accepted for forward-compatibility with v1.1 theme.charts.palette but currently ignored.



20
21
22
# File 'lib/lcp_ruby/widgets/chart_palette.rb', line 20

def self.color_for(index, theme: nil)
  COLORS[index % COLORS.size]
end