open OFC

let () =
  Random.self_init();
  let bar_funcs = [|
    (*  0 *) "Bar Sketch",           new_bar_sketch_elem;
    (*  1 *) "Bar 3d",               new_bar_3d_elem;
    (*  2 *) "Bar Filled",           new_bar_filled_elem;
    (*  3 *) "Bar Cylinder",         new_bar_cylinder_elem;
    (*  4 *) "Bar Cylinder Outline", new_bar_cylinder_outline_elem;
    (*  5 *) "Bar Round Glass",      new_bar_round_glass_elem;
    (*  6 *) "Bar Round",            new_bar_round_elem;
    (*  7 *) "Bar Dome",             new_bar_dome_elem;
    (*  8 *) "Bar Glass",            new_bar_glass_elem;
    (*  9 *) "Bar Plastic",          new_bar_plastic_elem;
    (* 10 *) "Bar Plastic_flat",     new_bar_plastic_flat_elem;
    (* 11 *) "Bar Round3d",          new_bar_round3d_elem;
  |] in
  let n = Random.int(Array.length bar_funcs) in
  let bar_legend, new_bar_elem_func = bar_funcs.(n) in
  let b1 = new_bar_elem_func() in
  bar_elem_set_colour b1 "#9933CC";
  bar_elem_set_alpha b1 0.6;
  bar_elem_set_font_size b1 10;
  bar_elem_add_ints b1 [9; 6; 7; 9; 5; 7; 6; 9; 11];

  let c = new_chart() in
  chart_add_element c b1;
  chart_set_bg_colour c "#FFFFD0";
  chart_set_title c ~style:"font-size:16px; font-family:Verdana; color:#404550;"
                    ("My " ^ bar_legend ^ " Chart");
  let labels = new_labels
    ["January";"February";"March";"April";"May";"June";"July";"August";"September"] in
  let _3d = if bar_legend = "Bar 3d" then (Some 5) else (None) in
  chart_set_x_axis c ~labels ?_3d ();
  chart_set_y_axis c ~max:14 ();
  print_chart c;
;;