class Playbook::PbCircleChart::CircleChart

def chart_data_formatted

def chart_data_formatted
  chart_data.map { |hash| hash[:y] = hash.delete :value }
  chart_data
end

def chart_options

def chart_options
  {
    id: id,
    colors: colors,
    borderColor: rounded_border_color,
    borderWidth: rounded_border_width,
    chartData: chart_data_formatted,
    dark: dark ? "dark" : "",
    title: title,
    height: height,
    type: chart_type,
    showInLegend: legend,
    dataLabelHtml: data_label_html,
    dataLabels: data_labels,
    headerFormat: header_format,
    tooltipHtml: tooltip_html,
    useHTML: use_html,
    minPointSize: min_point_size,
    maxPointSize: max_point_size,
    innerSize: inner_size_format,
    zMin: z_min,
    startAngle: start_angle,
  }.to_json.html_safe
end

def chart_type

def chart_type
  style == "variablepie" ? "variablepie" : "pie"
end

def classname

def classname
  generate_classname("pb_circle_chart")
end

def inner_size_format

def inner_size_format
  case inner_size
  when "lg"
    "85%"
  when "sm"
    "35%"
  when "none"
    "0%"
  when "md"
    "50%"
  end
end

def rounded_border_color

def rounded_border_color
  rounded == true ? "null" : nil
end

def rounded_border_width

def rounded_border_width
  rounded ? 20 : nil
end