How to add two TimeSeries JfreeChart - jfreechart

I want to add two or more timeSeries in order to generate stacked line graph.
I could not find something in the API. I am trying to do it manually but still does not work as I want.
Is there any function in the API, or not, that could manage this?
Thanks

Well this worked ^^
rtp: RegulatTimePeriod instance.
As iterating through the datasets of the two series we use this code to add a new node if there is not a record for the current rtp or udate the existing by the sum of the values.
if(StackedSerie.getValue(rtp)!=null){ //stacked lines dataset
StackedSerie.addOrUpdate(rtp,(double)((float)v + StackedSerie.getValue(rtp).floatValue()));
}
else
{
StackedSerie.add(rtp,v);
}

Related

Return empty cell instead of 0 in Google Sheets when data being displayed is an array from another sheet

I have a Google Sheet workbook with multiple sheets being used to track COVID-19 cases in institutions across the country. The built-in Google Sheets geo chart works perfectly for the data visualization I need to accomplish, with one issue: It currently can't differentiate between actual 0 and "no data", which super skews how the
(essentially you can choose what color to use on the map for high value, mid value, low value, and no value. Where it should be using the color for "no value", it uses the low value color instead which makes the visualization confusing.)
The reason it's doing that is the array it's using as its data source contains zeroes to represent "no data available".
The array is imported from a different sheet by using ={'State Totals'!N4:P54}. I found an explanation for how to generally use a formula to return empty cells, the example there being =if(B2-C2>0, B2-C2, " ").
I'm extremely noob when it comes to these formulas, and I cannot figure out if I can nest an IF condition in an array import, or vice versa, or... what or how.
Here's a link to the sheet in question, if that helps at all. Really I just need a formula that
Imports the array values
Returns empty cells in place of zeroes where they appear
I don't want to affect the origin sheet's zero handling, just the one that the chart's using. (I also am absolutely not being paid enough to try and rig up a better map with Google Data Queries instead of the in-built Google Sheets chart maker, so here's to hoping it's a simple matter of syntax.)
instead of ={'State Totals'!N4:P54} use:
=ARRAYFORMULA(IF('State Totals'!N4:P54=0,,'State Totals'!N4:P54))

Google Sheets Function replication

Is it possible to have a function that contains two ranges and you want to drag that formula across multiple cells but only have one of the ranges auto-advance while keeping the other function the original without advancing?
Here is the function
=IFNA(JOIN(", ", FILTER(Input!A5:A31, Input!JZ5:JZ="V")))
I want to drag this across multiple cells in a row, however, I only want the Input!JZ5:JZ="V" portion to advance to Input!KA5:KA="V" and leave the Input!A5:A31 the same due to that's the location of the information I am looking for and doesn't change.
Currently, both will advance to the next cell and so I am having to go back and fix each one and I have about 300 of these I need to do.
Any suggestions, please?
sure, lock it down with $ symbols. try:
=IFNA(JOIN(", ", FILTER(Input!$A$5:$A$31, Input!JZ5:JZ="V")))

Get SUM from CATEGORY and by MONTH

So I'm trying to sort some data from a form in google sheets. I need to sort the data by category. and by the month.
So far I have been able to sort these individually but not in the same cell.
my code so far for my test form is below the image.
To Filter by a category, in F2:
=UNIQUE(B2:B25)
for cells G2 and below I used: =SUMIF(B$2:B$25,F2,C$2:C$25)
to get the TOTAL for entire categories I used: =SUMPRODUCT((MONTH(spending_response!D2:D100)=5)*(YEAR(spending_response!D2:D100)=2020)*(spending_response!C2:C100))
my problem is I can't put these two together. I tried adding the two codes in the same cell separate by a comma but it doesn't seem to work. please see the below image for what I am using this for and dismiss the test values.
Put this in G2 and drag downwards :
=SUMPRODUCT((spending_response!$B$2:$B$100=F2)*(MONTH(spending_response!$D$2:$D$100)=5)*(YEAR(spending_response!$D$2:$D$100)=2020)*(spending_response!$C$2:$C$100))
Idea : add another draggable 'checking' criteria to the sumproduct. /(^_^)
use:
=QUERY(A2:C, "select A,sum(B) where month(C)+1=5 group by A label sum(B)''", 0)

FireStore and maps/arrays, document-list to array in Kotlin

I've finally started to understand a lot of info regarding FireStore, but I'm wondering if I can get some assistance.
If I had a setup similar to or like this:
          races
                Android
                      name: Android
                      size: medium
                       stats          <---- this is the map
                                str: 10
                                sex: 12.... (more values)
How would I parse this? I am looking to make specific TextViews apply values found in the database so that I can simply update the database and my app will populate those values so that hard coding and code updating won't be nearly as troublesome in the future.
I currently use something like this:
val androidRef = db.collection("races").document("Android")
androidRef.get().addOnSuccessListener { document ->
if (document != null) {
oneOfTheTextViews.text = document.getString("str")
} else {
}
The issue is currently I can only seem to access from collection (races) / document (android) / then a single field (I have "str" set as a single field, not part of a map or array)
What would the best practice be to do this? Should I not nest them at all? And if I can reference said nesting/mapping/array, what functions need to be called? (To be clear, I am not asking only whether or not it is possible - the reference guides and documents allude to such - but what property/class/method/etc needs to be called in order to access only one of those values or point to one of those values?).
Second question: Is there a way to get a list of document names? If I have several races, and simply want to make a spinner or recycler view based on document names as part of a collection, can I read that to the app?
What would the best practice be to do this?
If you want to get the value of your str property which is nested within your stats map, please change the following line of code:
oneOfTheTextViews.text = document.getString("str")
to
oneOfTheTextViews.text = document.getString("stats.str")
If your str property is a number and not a String, then instead of the above line of code please use this one:
oneOfTheTextViews.text = document.getLong("stats.str")
Should I not nest them at all?
No, you can nest as many properties as you want within a Map.
Is there a way to get a list of document names?
Yes, simply iterate the collection and get the document ids using getId() function.

How to deal with 2 TimeSerieses with the exact values?

I'm creating a TimeSeries chart with 2 TimeSerieses in it (i.e. A Dataset holding 2 TimeSeries objects.
It happens that both TimeSeries objects holds the same exact values and they are simply overlapping but that's not clear to the client as he only sees the result color or mixing the colors of both TimeSeries objects !
So he's seeing that the chart is displaying 2 sets of data, while only one line is drawn !
Is their a build-in way to deal with that ? How would you fix that ?
Personally I'm thinking of splitting this chart into 2 for it to be clear to the customer but I'm wondering if there is a way with less effort\more efficient to solve this situation.
EDIT: Final output should be images so this isn't a desktop application (i.e. Swing)
Thank you.
One approach is to let the user control series visibility using a suitable Action, a shown in this example.

Resources