primeNG p-chart consolidate legend - chart.js

My p-chart looks like this:
Most of it is fine. However the legend is kind of redundant. So instead of having two blocks for each value A, B, A1 I want only one block for each value.
I think this stems from the fact that in the data input I set two objects for each value (six objects in total). So theres one object with label "A" with all the positive values and another object, also with the label "A", containing all the negative values. The same goes for B and A1. I think that primeNG creates a block in the legend for each object in the data. However in my case this creates this redundant legend.
How can I make it so that there is only one block for A, B and A1 in the legend?

Related

AmCharts4: amCore.percent() not working as intended

I have the following graph:
"1" is a LineSeries, and "2" is a columnSeries. I set the width of the columnSeries like this:
series.columns.template.width = am4core.percent(90);
But as you can see, the columns are far away from 90% width.
Interestingly, without the LineSeries, it looks like this, which is what I want it to look like:
Furthermore, if I write a very high value (80 000) instead of 90, I get the desired columns:
I noticed that the dateAxis behaves differently(different time showing), but I cannot see where this is coming from.
Also, this high value for percentage is not a solution, because it has different widths on different graphs
So after experimenting I found out that the only way to avoid something like this is to use an own dateaxis for columns.
If, for example, you want a line+column, you can add a dateAxis to the line, and a dateAxis to the column.
If you have multiple columns, you could either use one dateAxis for all of them, or give one to every single column. The latter will make the columns "stack", so they are on the exact same positions if one would use the same dates for both datasets.
Furthermore, doing so means that you have to disable labeling on all dateaxes except for one, otherwise the labels on the xAxis will stack.

Calculate ever expanding number of columns with data to the right

Currently have a spreadsheet that tracks attendance. First column is name, second column is attendance % and contains the formula I need to revise, subsequent columns simply have an X or O in them and denote whether someone attended or not (headers for these columns are dates).
Currently using a COUNTIF() I can check how many X's there are and then the formula is SUM(100/no_of_columns*COUNTIF(A3:A12))
Ideally I want to firstly replace no_of_columns with the actual number of columns with data to the right.
I've thought about replacing this with a SUM(COUNTIF('X')+COUNTIF('O')) but it seems pretty messy?
Secondly I want to replace the A12 with whatever the last column value is.
I could just make the last column a very high column value, but again feels messy and would like to know if there is a better way...
Example: https://docs.google.com/spreadsheets/d/1rjnUQP7V-U1EZTp3Z8yO7HybBCuQjf2y4LJ4Dv4ctF8/edit?usp=sharing
Presume you only have the attendance dates in Row 1 without other information such as headers for Column A and B,
Put the following formula in Cell B2 and drag it down,
=COUNTIF(INDEX(OFFSET($C2,,,,COUNTA($1:$1)),),"x")/COUNTA($1:$1)*100
The logic is to use INDEX + OFFSET function to dynamically return the range of columns on the right, and use COUNTA to find out how many dates are there, and you should understand the use of COUNTIF, the calculation is self-explanatory.
EDIT #2
After looking into your worksheet, I guess you are adding the new dates by inserting columns between B and C so you probably want to use the following formula in Cell B2 instead to avoid the system shifting the starting cell reference automatically:
=COUNTIF(INDEX(OFFSET($B2,,1,,COUNTA($1:$1)),),"x")/COUNTA($1:$1)*100
The logic is the same as the previous one but just a little change to the OFFSET references so it starts looking for the range from Column B instead of C.
I have tested the above in both Excel and Google-sheets working just fine. Let me know if you have any questions. Cheers :)
paste in B2:
=ARRAYFORMULA(IFERROR(IF(LEN(A2:A),
MMULT(IF(INDIRECT("C2:"&ADDRESS(ROWS(A2:A), MAX(IF(1:1<>"", COLUMN(1:1), ))))="x", 1, 0),
TRANSPOSE(COLUMN(INDIRECT("C2:"&ADDRESS(ROWS(A2:A), MAX(IF(1:1<>"", COLUMN(1:1), )))))^0))/
MMULT(IF(INDIRECT("C2:"&ADDRESS(ROWS(A2:A), MAX(IF(1:1<>"", COLUMN(1:1), ))))<>"", 1, 0),
TRANSPOSE(COLUMN(INDIRECT("C2:"&ADDRESS(ROWS(A2:A), MAX(IF(1:1<>"", COLUMN(1:1), )))))^0))*100, ), 0))
spreadsheet demo

Iterate through all cells in a column instead of checking all cells individually

I have a simple list with labels and values in a Google Spreadsheet. Below, I have some fields in which I would like to get the value when writing the label.
For example, if I write D in a cell, I want the next cell to show 4, the value corresponding to D.
This can of course be done with repetitive IFs inside IFs inside IFs... in cell B8, like this:
=IF(A8=A1;B1; IF(A8=A2;B2; IF(A8=A3;B3; IF(A8=A4;B4; IF(A8=A5;B5;0)))))
This simply checks row by row: If the written value matches the label of row 1, then show the value. If not, then perform a new IF command on the second row. Etc.
With many rows this is quite tedious. Is it possible in Google Spreadsheets to simplify this a bit? For instance, can I in some way collect all cells in a column in one IF statement by doing A1:A5 or something like that? Something along the lines of:
=IF(A8=A1:A5;B1:B5;0)
solve it by using simple VLOOKUP:
=VLOOKUP(A8, A1:B5, 2, 0)

crossfilter dimension on 2 fields

My data looks like this
field1,field2,value1,value2
a,b,1,1
b,a,2,2
c,a,3,5
b,c,6,7
d,a,6,7
I don't have a good way of rearranging that data so let's assume the data has to stay like this.
I want to create a dimension on field1 and field2 combined : a single dimension that would take the union of all values in both field1 and field2 (in my example, the values should be [a,b,c,d])
As a reduce function you can assume reduceSum on value2 for example (allowing double counting for now).
(have tagged dc.js and reductio because it could be useful for users of those libraries)
First I need to point out that your data is denormalized, so the counts you get might be somewhat confusing, no matter what technique you use.
In standard usage of crossfilter, each row will be counted in exactly one bin, and all the bins in a group will add up to 100%. However, in your case, each row will be counted twice (unless the two fields are the same), so for example a pie chart wouldn't make any sense.
That said, the "tag dimension" feature is perfect for what you're trying to do.
The dimension declaration could be as simple as:
var tagDimension = cf.dimension(function(d) { return [d.field1,d.field2]; }, true);
Now each row will get counted twice - this dimension and its associated groups will act exactly as if each of the rows were duplicated, with one copy indexed by field1 and the other by field2.
If you made a bar chart with this, say, the total count will be 2N minus the number of rows where field1 === field2. If you click on bar 'b', all rows which have 'b' in either fields will get selected. This only affects groups built on this dimension, so any other charts will only see one copy of each row.

Applying a formula to all cells in a column, not just one at a time?

In OpenOffice.org Calc, I would like to apply a formula to a column that references a cell from the same row but in a different column. I.e., =C1*48 in cell D1, but I want all cells in column D to do this without having to copy the formula to each one manually. Or another way of saying it, for each cell in C that has a number, I want to fill in the corresponding row-cell in D with a formula value based on that number. So far, all I can see from the documentation is that I'd have to copy/adjust the formula for every new row in the spreadsheet. And since I have 4 such columns that need calculation, this will get to be tiresome. I have little experience with spreadsheets at all, so I'm hoping that my problem is actually very simple, and that I just am looking at the wrong parts of the documentation.
I don't have OpenOffice in front of me, but it tries really hard to be Excel like in many ways, so usually assumptions about Calc based on Excel are fairly close to reality.
In Excel, a formula in cell D1, that points to a cell in C1, is treated as a relative reference - that is, one column back from where I am now. So when that formula is filled into other cells (either by Fill Down, or dragging the little handle in the corner of the cell outline, or by copy-pasting the formula into a range of selected cells) the new formulas are similarly treated, by default, as referring to the cell that is one column back from them, in the same row.
To force a formula to use an absolute reference, one specifies the cell address with a dollar sign - $C$1 will always point to (use) the contents of cell C1, regardless of where the formula ends up. ($C1 and C$1 are alternates that allow one parameter of the address to change in the usual relative sense while fixing the other half in place... this probably isn't important to you yet).
In other words, I'd expect that you can type the formulas in the first row of your OpenOffice Calc sheet and copy them down to the rest of the row, and things will just work.
If you want to extend your range down you can do this by calculating the first 2 cells with your formula and then highlighting them. You now grab the little square on the bottom right of the highlighted area and drag that down, across or both.
If you have a specific cell (e.g. D2) which you wish to have remain in all the cells you extend your range to, then in your 2 initial cell calculations use the following:
Extending Down
=G2*D$2
=G3*D$2
Extending Across
=G2*$D2
=H2*$D2
Extending Down and Across
Use $D$2
From your question it seems that you are trying to apply the same formula on whole row (or column) of cells and show the result on another row (or column).
The best way to do this is to use something called array formulas or array functions (in libre office). This link has very good explanation - https://help.libreoffice.org/Calc/Array_Functions
The way you would implement this in your case is
Type this formula in cell D1
=C1:C30 *48
and press ctrl + shift + enter
The formula now looks like this with the flower braces {..}
={C1:C30 *48}
and the formula gets applied all the way from D1 to D30.
You can even extrapolate the same concept to a whole matrix (for example: A1:C10)
(The way to tell excel/open office/ libre office that you wrote an array formula is to press ctrl + shift + enter. Never press enter as that will break the array function and convert it to a regular function)