0

I have a dataset that captures the outlet's end of date times as shown in this screenshot below:

Sample Dataset, EOD Int Time is Time in Double format

Note: The last column, EOD Int Time is converted into a 24 hour, decimal format as the DataSeriesItem constructor takes a number value as its second parameter.

I am currently trying to visualize it into a line graph as like the Time Data with Irregular Intervals sample (see here).

Since this was in a dataset, I tried to capture those in the form of a DataSetItem and then putting it into several DataSeries. This chunk of code below is the main thing:

       for(int i=0; i<objList.size(); i++){

            skuLogger.debug("Location value is: " + location);
            Object row = objList.get(i);
            Object[] doj = (Object[])row;
            skuLogger.debug("Record outlet is: " + doj[0].toString());
            skuLogger.debug("DataSeriesData name is: " + dataSeriesData.getStack());
            DataSeriesItem dsItem = new DataSeriesItem(doj[1].toString(),Double.valueOf(doj[3].toString()));

            if(dataSeriesData.getName() != null && location.equalsIgnoreCase(doj[0].toString())){
                skuLogger.debug("ds name is not null: " + dataSeriesData.getName() + "record number " + (i+1));
                location = doj[0].toString();
                dsArray.add(dsItem);
            }else if(dataSeriesData.getName() == null || !location.equals(doj[0].toString())) {
                skuLogger.debug("ds name is null - create new, record number " + (i+1));
                dataSeriesData = new DataSeries();
                dsArray = new ArrayList<DataSeriesItem>();
                location = doj[0].toString();
                dataSeriesData.setName(doj[0].toString());
                skuLogger.debug("ds name after set : " + dataSeriesData.getName() +"record number " + (i+1));
                dsArray.add(dsItem);
            }

            dataSeriesData.setData(dsArray);
            dataSeriesData.setPlotOptions(plotOptions);
            chart.getConfiguration().addSeries(dataSeriesData);
       }

What happened was say that for example of MY012, three series / lines appear in the chart, overlapping one another, same length and curve. Each line has the three EOD dates and time spots. The screenshot below shows the current result:

enter image description here

MY015 appears three times in the legend section. It should only show once.

  1. In this case, can we actually group it as one, as instead of showing 30 records as 30 series, it should show as 30 records in 12 series / outlets?

  2. If not, what alternatives can be considered for this problem?

  3. Is this somewhat a bug / limitation of the line graph under Vaadin Charts 4.0.5?
Melvin Mah
  • 105
  • 2
  • 13

1 Answers1

0

What happened was say that for example of MY012, three series / lines appear in the chart

From the moment you are creating as many "series" as the size of your list:

for(int i=0; i<objList.size(); i++){
    ...
    chart.getConfiguration().addSeries(dataSeriesData);
 }

I seems quite logical, isn't it ?

MY012 appears 3 times in your list, so your are going to add 3 distinct series (with the same legend).

TacheDeChoco
  • 3,683
  • 1
  • 14
  • 17