Skip to content

Commit

Permalink
Address #3918 by adding x evolution for series with accumulate_values:
Browse files Browse the repository at this point in the history
true
  • Loading branch information
AlexisDrogoul committed Oct 23, 2023
1 parent 1c4ca84 commit 05fbad3
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -779,30 +779,30 @@ public void savehistory(final IScope scope, final ChartHistory history) {
history.append(this.getName() + ",");
if (mysource.isByCategory()) {
if (this.cvalues.size() > 0) {
if (this.getMysource().isCumulative) {
if (this.getMysource().isCumulative()) {
history.append(this.cvalues.get(this.cvalues.size() - 1) + ",");
} else {
savelists(scope, history, this.cvalues);
}
}
} else if (this.xvalues.size() > 0) {
if (this.getMysource().isCumulative) {
if (this.getMysource().isCumulative()) {
history.append(this.xvalues.get(this.xvalues.size() - 1) + ",");
} else {
savelistd(scope, history, this.xvalues);
}

}
if (this.yvalues.size() > 0) {
if (this.getMysource().isCumulative) {
if (this.getMysource().isCumulative()) {
history.append(this.yvalues.get(this.yvalues.size() - 1) + ",");
} else {
savelistd(scope, history, this.yvalues);
}

}
if (this.svalues.size() > 0 && this.svalues.size() >= this.yvalues.size()) {
if (this.getMysource().isCumulative) {
if (this.getMysource().isCumulative()) {
history.append(this.svalues.get(this.svalues.size() - 1) + ",");
} else {
savelistd(scope, history, this.svalues);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public void BackwardSim(final IScope scope, final int cycle) {
final ArrayList<ChartDataSource> sourcestoremove = new ArrayList<>();
final ArrayList<ChartDataSource> sourcestoadd = new ArrayList<>();
for (final ChartDataSource source : sources) {
if (source.isCumulative || source.isCumulativeY) {
if (source.isCumulative() || source.isCumulativeY) {

final ChartDataSource newsource = source.getClone(scope, chartCycle);
newsource.createInitialSeries(scope);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public class ChartDataSource {
ChartDataSet myDataset;

/** The is cumulative. */
boolean isCumulative = false;
private boolean isCumulative = false;

/** The is cumulative Y. */
boolean isCumulativeY = false;
Expand Down Expand Up @@ -542,7 +542,7 @@ public int get_data_type(final IScope scope, final Object o) {
* the scope
* @param myserie
* the myserie
* @param o
* @param newValue
* the o
* @param chartCycle
* the chart cycle
Expand All @@ -552,9 +552,9 @@ public int get_data_type(final IScope scope, final Object o) {
* the listvalue
*/
// final Object o = expr.value(scope);
void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, final Object o, final int chartCycle,
final HashMap barvalues, final int listvalue) {
final int type_val = this.get_data_type(scope, o);
void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, final Object newValue,
final int chartCycle, final HashMap barvalues, final int listvalue) {
final int type_val = this.get_data_type(scope, newValue);
// could move into outputs object... would be (a little) less complex.
// But less factorisation...

Expand All @@ -572,7 +572,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin

switch (type_val) {
case ChartDataSource.DATA_TYPE_POINT: {
final GamaPoint pvalue = Cast.asPoint(scope, o);
final GamaPoint pvalue = Cast.asPoint(scope, newValue);
myserie.addxysvalue(scope,
getDataset().getXSeriesValues().get(getDataset().getCommonXIndex()), pvalue.getX(),
pvalue.getY(), chartCycle, barvalues, listvalue);
Expand All @@ -581,7 +581,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_12:
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_3:
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_N: {
final IList lvalue = Cast.asList(scope, o);
final IList lvalue = Cast.asList(scope, newValue);
if (lvalue.length(scope) == 0) {
myserie.initColor(scope, barvalues, listvalue);
} else if (lvalue.length(scope) == 1) {
Expand All @@ -603,7 +603,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin
}
case ChartDataSource.DATA_TYPE_DOUBLE:
default: {
final Double dvalue = Cast.asFloat(scope, o);
final Double dvalue = Cast.asFloat(scope, newValue);
myserie.addxyvalue(scope,
getDataset().getXSeriesValues().get(getDataset().getCommonXIndex()), dvalue,
chartCycle, barvalues, listvalue);
Expand All @@ -613,13 +613,12 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin

}

}
if (!this.isCumulative()) {
} else {
// new non cumulative y value
// serie in the order of the dataset
switch (type_val) {
case ChartDataSource.DATA_TYPE_POINT: {
final GamaPoint pvalue = Cast.asPoint(scope, o);
final GamaPoint pvalue = Cast.asPoint(scope, newValue);
myserie.addxysvalue(scope, getDataset().getXSeriesValues().get(0), pvalue.getX(),
pvalue.getY(), chartCycle, barvalues, listvalue);

Expand All @@ -628,7 +627,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_12:
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_3:
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_N: {
final IList l1value = Cast.asList(scope, o);
final IList l1value = Cast.asList(scope, newValue);
if (l1value.isEmpty()) {
myserie.initColor(scope, barvalues, listvalue);
} else {
Expand All @@ -648,7 +647,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin
case ChartDataSource.DATA_TYPE_LIST_LIST_DOUBLE_12:
case ChartDataSource.DATA_TYPE_LIST_LIST_DOUBLE_3:
case ChartDataSource.DATA_TYPE_LIST_LIST_DOUBLE_N: {
final IList l1value = Cast.asList(scope, o);
final IList l1value = Cast.asList(scope, newValue);
if (l1value.isEmpty()) {
myserie.initColor(scope, barvalues, listvalue);
} else {
Expand Down Expand Up @@ -677,8 +676,8 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin
}
case ChartDataSource.DATA_TYPE_DOUBLE:
default: {
final Double dvalue = Cast.asFloat(scope, o);
myserie.addxyvalue(scope, getDataset().getXSeriesValues().get(0), dvalue, chartCycle,
final Double dvalue = Cast.asFloat(scope, newValue);
myserie.addxyvalue(scope,/* getDataset().getXSeriesValues().get(0) */ getDataset().getXSeriesValues().get(getDataset().getCommonXIndex()), dvalue, chartCycle,
barvalues, listvalue);
break;

Expand All @@ -698,7 +697,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin

switch (type_val) {
case ChartDataSource.DATA_TYPE_POINT: {
final GamaPoint pvalue = Cast.asPoint(scope, o);
final GamaPoint pvalue = Cast.asPoint(scope, newValue);
myserie.addxysvalue(scope, pvalue.getX(), pvalue.getY(), pvalue.getZ(), chartCycle,
barvalues, listvalue);

Expand All @@ -707,7 +706,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_12:
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_3:
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_N: {
final IList lvalue = Cast.asList(scope, o);
final IList lvalue = Cast.asList(scope, newValue);
if (lvalue.length(scope) < 2) {

}
Expand All @@ -729,7 +728,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin
}
case ChartDataSource.DATA_TYPE_DOUBLE:
default: {
final Double dvalue = Cast.asFloat(scope, o);
final Double dvalue = Cast.asFloat(scope, newValue);
myserie.addxyvalue(scope,
getDataset().getXSeriesValues().get(getDataset().getCommonXIndex()), dvalue,
chartCycle, barvalues, listvalue);
Expand All @@ -739,13 +738,11 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin

}

}

if (!this.isCumulative()) {
} else {
// new XY values
switch (type_val) {
case ChartDataSource.DATA_TYPE_POINT: {
final GamaPoint pvalue = Cast.asPoint(scope, o);
final GamaPoint pvalue = Cast.asPoint(scope, newValue);
myserie.addxysvalue(scope, pvalue.getX(), pvalue.getY(), pvalue.getZ(), chartCycle,
barvalues, listvalue);

Expand All @@ -754,7 +751,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_12:
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_3:
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_N: {
final IList lvalue = Cast.asList(scope, o);
final IList lvalue = Cast.asList(scope, newValue);
if (lvalue.length(scope) < 2) {

}
Expand All @@ -774,7 +771,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin
case ChartDataSource.DATA_TYPE_LIST_LIST_DOUBLE_12:
case ChartDataSource.DATA_TYPE_LIST_LIST_DOUBLE_3:
case ChartDataSource.DATA_TYPE_LIST_LIST_DOUBLE_N: {
final IList l1value = Cast.asList(scope, o);
final IList l1value = Cast.asList(scope, newValue);
for (final Object o2 : l1value) {
final IList lvalue = Cast.asList(scope, o2);
if (lvalue.length(scope) < 2) {
Expand All @@ -800,7 +797,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin
}
case ChartDataSource.DATA_TYPE_DOUBLE:
default: {
final Double dvalue = Cast.asFloat(scope, o);
final Double dvalue = Cast.asFloat(scope, newValue);
myserie.addxyvalue(scope,
getDataset().getXSeriesValues().get(getDataset().getCommonXIndex()), dvalue,
chartCycle, barvalues, listvalue);
Expand All @@ -823,15 +820,15 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin

switch (type_val) {
case ChartDataSource.DATA_TYPE_POINT: {
final GamaPoint pvalue = Cast.asPoint(scope, o);
final GamaPoint pvalue = Cast.asPoint(scope, newValue);
myserie.addcysvalue(scope, getDataset().getLastCategories(scope), pvalue.getX(),
pvalue.getY(), chartCycle, barvalues, listvalue);
break;
}
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_12:
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_3:
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_N: {
final IList lvalue = Cast.asList(scope, o);
final IList lvalue = Cast.asList(scope, newValue);
if (lvalue.length(scope) == 0) {

}
Expand Down Expand Up @@ -860,7 +857,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin
}
case ChartDataSource.DATA_TYPE_DOUBLE:
default: {
final Double dvalue = Cast.asFloat(scope, o);
final Double dvalue = Cast.asFloat(scope, newValue);
myserie.addcyvalue(scope, getDataset().getLastCategories(scope), dvalue, chartCycle,
barvalues, listvalue);

Expand All @@ -869,14 +866,12 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin

}

}

if (!this.isCumulative()) {
} else {
// new non cumulative category value
// category in the order of the dataset
switch (type_val) {
case ChartDataSource.DATA_TYPE_POINT: {
final GamaPoint pvalue = Cast.asPoint(scope, o);
final GamaPoint pvalue = Cast.asPoint(scope, newValue);
myserie.addcysvalue(scope, getDataset().getCategories(scope, 0), pvalue.getX(),
pvalue.getY(), chartCycle, barvalues, listvalue);

Expand All @@ -885,7 +880,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_12:
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_3:
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_N: {
final IList l1value = Cast.asList(scope, o);
final IList l1value = Cast.asList(scope, newValue);
for (int n1 = 0; n1 < l1value.size(); n1++) {
final Object o2 = l1value.get(n1);
myserie.addcyvalue(scope, getDataset().getCategories(scope, n1),
Expand All @@ -898,7 +893,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin
case ChartDataSource.DATA_TYPE_LIST_LIST_DOUBLE_12:
case ChartDataSource.DATA_TYPE_LIST_LIST_DOUBLE_3:
case ChartDataSource.DATA_TYPE_LIST_LIST_DOUBLE_N: {
final IList l1value = Cast.asList(scope, o);
final IList l1value = Cast.asList(scope, newValue);
for (int n1 = 0; n1 < l1value.size(); n1++) {
final Object o2 = l1value.get(n1);
final IList lvalue = Cast.asList(scope, o2);
Expand Down Expand Up @@ -931,7 +926,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin
}
case ChartDataSource.DATA_TYPE_DOUBLE:
default: {
final Double dvalue = Cast.asFloat(scope, o);
final Double dvalue = Cast.asFloat(scope, newValue);
myserie.addcyvalue(scope, getDataset().getCategories(scope, 0), dvalue, chartCycle,
barvalues, listvalue);
break;
Expand All @@ -951,7 +946,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin

switch (type_val) {
case ChartDataSource.DATA_TYPE_POINT: {
final GamaPoint pvalue = Cast.asPoint(scope, o);
final GamaPoint pvalue = Cast.asPoint(scope, newValue);
myserie.addxysvalue(scope, getDataset().getXSeriesValues().get(0),
getDataset().getYSeriesValues().get(0), pvalue.getX(), chartCycle, barvalues, listvalue);

Expand All @@ -960,7 +955,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_12:
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_3:
case ChartDataSource.DATA_TYPE_LIST_DOUBLE_N: {
final IList l1value = Cast.asList(scope, o);
final IList l1value = Cast.asList(scope, newValue);
for (int n1 = 0; n1 < l1value.size(); n1++) {
final Object o2 = l1value.get(n1);
while (n1 >= getDataset().getXSeriesValues().size()) {
Expand All @@ -977,7 +972,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin
case ChartDataSource.DATA_TYPE_LIST_LIST_DOUBLE_12:
case ChartDataSource.DATA_TYPE_LIST_LIST_DOUBLE_3:
case ChartDataSource.DATA_TYPE_LIST_LIST_DOUBLE_N: {
final IList l1value = Cast.asList(scope, o);
final IList l1value = Cast.asList(scope, newValue);
for (int n1 = 0; n1 < l1value.size(); n1++) {
final Object o2 = l1value.get(n1);
final IList lvalue = Cast.asList(scope, o2);
Expand All @@ -1004,7 +999,7 @@ void updateseriewithvalue(final IScope scope, final ChartDataSeries myserie, fin
}
case ChartDataSource.DATA_TYPE_DOUBLE:
default: {
final Double dvalue = Cast.asFloat(scope, o);
final Double dvalue = Cast.asFloat(scope, newValue);
myserie.addxysvalue(scope, getDataset().getXSeriesValues().get(0),
getDataset().getYSeriesValues().get(0), dvalue, chartCycle, barvalues, listvalue);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public void initChart_post_data_init(final IScope scope) {
} else if ("default".equals(this.series_label_position)) {
if (!this.getChartdataset().getSources().isEmpty()) {
final ChartDataSource onesource = this.getChartdataset().getSources().get(0);
if (onesource.isCumulative) {
if (onesource.isCumulative()) {
this.series_label_position = "legend";
} else {
this.series_label_position = XAXIS;
Expand Down

0 comments on commit 05fbad3

Please sign in to comment.