anchor.diff:              {delete_chart, Id} ->
                   wf:wire("deleteChart(\"" ++ integer_to_list(Id) ++ "\");"),
                   gui_utils:flush(),
  -                ?MODULE:comet_loop(Counter, PageState#page_state{charts = dict:erase(Id, Charts)})
  +                ?MODULE:comet_loop(Counter, PageState#page_state{charts = proplists:delete(Id, Charts)})
   
           end
       catch Type:Msg ->
  
positive.code:             add_chart ->
                  gui_utils:remove("error_message"),
                  gui_utils:flush(),
                  case validate(PageState) of
                      ok ->
                          reset_dropdowns(Nodes),
                          case create_chart(Counter, Node, TimeRange, ChartType) of
                              {ok, Chart} ->
                                  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 = dict:store(Counter, Chart, Charts)});
                              _ ->
                                  error_message(<<"There has been an error in chart creation. Please try again.">>),
                                  ?MODULE:comet_loop(Counter, PageState#page_state{node = undefined, time_range = undefined, chart_type = undefined})
                          end;
                      _ ->
                          ?MODULE:comet_loop(Counter, PageState)
                  end;
  
              {update_chart, Id} ->
                  try
                      Chart = dict:fetch(Id, Charts),
                      ok = update_chart(Chart),
                      erlang:send_after(1000 * Chart#chart.update_period, self(), {update_chart, Id})
                  catch
                      _:Error -> ?error("Can not update chart ~p: ~p", [Id, Error])
                  end,
  
negative.code: %% ====================================================================
  get_json_data(Id, Node, Period, Target, Command, TimeRange, ChartType) ->
      {MegaSecs, Secs, _} = erlang:now(),
      EndTime = trunc(((1000000 * MegaSecs + Secs - 2 * Period) / Period) * Period),
      StartTime = EndTime - time_range_to_integer(TimeRange),
      BinaryStartTime = integer_to_binary(StartTime),
      BinaryEndTime = integer_to_binary(EndTime),
  