@Test
 public void parsexYDataSerieToSeries() {
   final String name = "test";
   final MolgenisSerieType molgenisSerieType = MolgenisSerieType.SCATTER;
   XYDataSerie xYDataSerie = mock(XYDataSerie.class);
   when(xYDataSerie.getName()).thenReturn(name);
   when(xYDataSerie.getType()).thenReturn(molgenisSerieType);
   when(xYDataSerie.getAttributeXFieldTypeEnum()).thenReturn(FieldTypeEnum.DECIMAL);
   when(xYDataSerie.getAttributeYFieldTypeEnum()).thenReturn(FieldTypeEnum.DECIMAL);
   Series series = highchartSeriesUtil.parsexYDataSerieToSeries(xYDataSerie);
   assertEquals(series.getName(), name);
   assertEquals(series.getType(), "scatter");
   assertNull(series.getMarker());
   assertNull(series.getLineWidth());
 }
Пример #2
0
  /**
   * Parse the xYDataSerie to a Series object computable with the Highcharts xy series standard.
   *
   * @param xYDataSerie
   * @return Series
   */
  public Series parsexYDataSerieToSeries(XYDataSerie xYDataSerie) {
    Series series = new Series();
    series.setName(xYDataSerie.getName());
    series.setType(SeriesType.getSeriesType(xYDataSerie.getType()));
    series.setData(
        parseXYDataToList(
            xYDataSerie.getData(),
            xYDataSerie.getAttributeXFieldTypeEnum(),
            xYDataSerie.getAttributeYFieldTypeEnum()));

    if (MolgenisSerieType.SCATTER.equals(xYDataSerie.getType())
        && (AttributeType.DATE.equals(xYDataSerie.getAttributeXFieldTypeEnum())
            || AttributeType.DATE_TIME.equals(xYDataSerie.getAttributeXFieldTypeEnum()))) {
      series.setLineWidth(0);
      series.setMarker(new Marker(true, 4));
      series.setType(SeriesType.getSeriesType(MolgenisSerieType.LINE));
    }
    return series;
  }