anchor.diff:  -define(HOST_CHART_TYPES, [<<"CPU utilization">>, <<"memory usage">>, <<"network throughput">>, <<"network transfer">>, <<"ports transfer">>]).
   -define(GEN_SERVER_TIMEOUT, 5000).
   
  --record(page_state, {nodes, node, time_range, chart_type, charts = dict:new()}).
  +-record(page_state, {nodes, node, time_range, chart_type, charts = []}).
   -record(chart, {id, node, time_range, type, update_period}).
   
   -export([main/0, event/1, comet_loop/2]).
  
positive.code: %% ====================================================================
  get_json_data(Id, Node, Period, Target, Command, TimeRange, ChartType) ->
      {MegaSecs, Secs, _} = erlang:now(),
      EndTime = trunc(((1000000 * MegaSecs + Secs - Period - 1) / Period) * Period),
      StartTime = EndTime - time_range_to_integer(TimeRange),
      BinaryStartTime = integer_to_binary(StartTime),
      BinaryEndTime = integer_to_binary(EndTime),
  
negative.code:             add_chart ->
                  gui_utils:remove("error_message"),
                  gui_utils:flush(),
                  case validate_page_state(PageState) of
                      ok ->
                          case validate_chart(Node, TimeRange, ChartType, Charts) of
                              ok ->
                                  case create_chart(Counter, Node, TimeRange, ChartType) of
                                      {ok, Chart} ->
                                          reset_dropdowns(Nodes),
                                          erlang:send_after(1000 * Chart#chart.update_period, self(), {update_chart, Counter}),
                                          ?MODULE:comet_loop(Counter + 1, PageState#page_state{node = undefined, time_range = undefined, chart_type = undefined, charts = [{Counter, Chart} | Charts]});
                                      _ ->
                                          error_message(<<"There has been an error in chart creation. Please try again.">>)
                                  end;
                              _ -> error_message(<<"Chart already added.">>)
                          end;
                      _ -> ok
                  end,
                  ?MODULE:comet_loop(Counter, PageState);
  
              {update_chart, Id} ->
                  try
                      case proplists:get_value(Id, Charts) of
                          undefined ->
                              ?error("Can not update chart ~p: chart does not exist.", [Id]);
                          Chart ->
                              ok = update_chart(Chart),
                              erlang:send_after(1000 * Chart#chart.update_period, self(), {update_chart, Id})
                      end
                  catch
                      _:Error -> ?error("Can not update chart ~p: ~p", [Id, Error])
                  end,
  