@RequestMapping(
      value = "/getData",
      produces = {"image/png"},
      method = POST)
  public void getTimeseriesCollectionChart(
      HttpServletResponse response, @RequestBody DesignedParameterSet requestParameters)
      throws Exception {

    checkIfUnknownTimeseries(requestParameters.getTimeseries());

    IoParameters map = createFromQuery(requestParameters);
    UndesignedParameterSet parameters = createFromDesignedParameters(requestParameters);
    checkAgainstTimespanRestriction(parameters.getTimespan());
    parameters.setGeneralize(map.isGeneralize());
    parameters.setExpanded(map.isExpanded());
    parameters.setBase64(map.isBase64());

    String[] timeseriesIds = parameters.getTimeseries();
    TimeseriesMetadataOutput[] timeseriesMetadatas =
        timeseriesMetadataService.getParameters(timeseriesIds, map);
    RenderingContext context = createContextWith(requestParameters, timeseriesMetadatas);
    IoHandler renderer = IoFactory.createWith(map).createIOHandler(context);

    handleBinaryResponse(response, parameters, renderer);
  }
  @RequestMapping(
      value = "/{timeseriesId}/getData",
      produces = {"image/png"},
      method = GET)
  public void getTimeseriesChart(
      HttpServletResponse response,
      @PathVariable String timeseriesId,
      @RequestParam(required = false) MultiValueMap<String, String> query)
      throws Exception {

    checkIfUnknownTimeseries(timeseriesId);

    IoParameters map = createFromQuery(query);
    TimeseriesMetadataOutput metadata = timeseriesMetadataService.getParameter(timeseriesId, map);
    RenderingContext context =
        createContextForSingleTimeseries(metadata, map.getStyle(), map.getTimespan());
    context.setDimensions(map.getChartDimension());

    UndesignedParameterSet parameters = createForSingleTimeseries(timeseriesId, map.getTimespan());
    checkAgainstTimespanRestriction(parameters.getTimespan());

    parameters.setGeneralize(map.isGeneralize());
    parameters.setBase64(map.isBase64());
    parameters.setExpanded(map.isExpanded());

    IoHandler renderer = IoFactory.createWith(map).createIOHandler(context);
    handleBinaryResponse(response, parameters, renderer);
  }
  @RequestMapping(
      value = "/{timeseriesId}/getData",
      produces = {"application/json"},
      method = GET)
  public ModelAndView getTimeseriesData(
      HttpServletResponse response,
      @PathVariable String timeseriesId,
      @RequestParam(required = false) MultiValueMap<String, String> query) {

    checkIfUnknownTimeseries(timeseriesId);

    IoParameters map = createFromQuery(query);
    Interval timespan = map.getTimespan();
    checkAgainstTimespanRestriction(timespan.toString());
    UndesignedParameterSet parameters = createForSingleTimeseries(timeseriesId, timespan);

    parameters.setGeneralize(map.isGeneralize());
    parameters.setExpanded(map.isExpanded());

    // TODO add paging

    TvpDataCollection timeseriesData = getTimeseriesData(parameters);
    TimeseriesDataCollection<?> formattedDataCollection = format(timeseriesData, map.getFormat());
    if (map.isExpanded()) {
      return new ModelAndView().addObject(formattedDataCollection.getTimeseriesOutput());
    }
    Object formattedTimeseries = formattedDataCollection.getAllTimeseries().get(timeseriesId);
    return new ModelAndView().addObject(formattedTimeseries);
  }