Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 01-03-2015, 08:14 PM   #1
ElMiko
Addict
ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.
 
ElMiko's Avatar
 
Posts: 320
Karma: 56788
Join Date: Jun 2011
Device: Kindle
Color coding and designing composite columns

I have three custom columns that are Yes/No columns (let's call them "#cola", "#colb", and "#colc"). I would like to create a fourth column that displays 8 values, ideally with each text value as its own color (as in a "Text, but with a fixed set of permitted values" column):
"ColA" (if only #cola's value is "Yes"),
"ColA, ColB" (if only #cola and #colb values are "Yes"),
"ColA, ColB, ColC" (if all three columns have "Yes" values),
"ColA, ColC" (if only #cola and #colc values are "Yes"),
"ColB, ColC" (if only #colb and #colc values are "Yes"),
"ColB" (if only #colb's value is "Yes"),
"ColC" (if only #colc's value is "Yes"), and finally
simply blank (if all values are either "No" or "Blank")

Anyone know how this would be possible, and what the syntax would be?
ElMiko is offline   Reply With Quote
Old 01-03-2015, 08:19 PM   #2
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
@ElMiko - should be possible create the with a column built from other columns using a program mode template, see ==>> The calibre template language — Advanced features

I think you could that colour than column according to its value - not certain on that as I don't colour columns.

BR

Last edited by BetterRed; 01-03-2015 at 08:26 PM.
BetterRed is offline   Reply With Quote
Old 01-03-2015, 08:50 PM   #3
ElMiko
Addict
ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.
 
ElMiko's Avatar
 
Posts: 320
Karma: 56788
Join Date: Jun 2011
Device: Kindle
@BR-thanks for the quick reply. I had already looked at the tutorial for custom column syntax, but couldn't make heads or tails of it (I'm assuming it's some variation on the "contains" syntax). I was rather hoping that one of the gurus here would be able to get me started...
ElMiko is offline   Reply With Quote
Old 01-04-2015, 02:03 AM   #4
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,575
Karma: 26954694
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by ElMiko View Post
@BR-thanks for the quick reply. I had already looked at the tutorial for custom column syntax, but couldn't make heads or tails of it (I'm assuming it's some variation on the "contains" syntax). I was rather hoping that one of the gurus here would be able to get me started...
@ElMiko - I had the in_list function in mind. I'm away from my calibre system so I can't hack out any ideas

Have a look in these two threads while you're waiting for the Masters of the Templates to report for duty

Custom Column Recommendations

Plugboard, template, and custom composite column recipes

I have a suspicion I saw something in one of them that were along the lines of what your after.

BR
BetterRed is offline   Reply With Quote
Old 01-04-2015, 02:39 AM   #5
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Code:
program:

part1=contains(field('#cola'), 'Yes', 'colA', '');
part2=contains(field('#colb'), 'Yes', 'colB', '');
part3=contains(field('#colc'), 'Yes', 'colC', '');

final=list_union(
    '', 
    strcat(part1, ',', part2, ',', part3)
    ','
);
Will display the concatenated and comma-separated values.

I've never really played around with custom columns, but you can set 8 rules to match each state with a different color. I think you have to have a rule per color.

Edit: Right, like chaley said, templates are "hiding" at the bottom.

Last edited by eschwartz; 01-04-2015 at 03:08 AM.
eschwartz is offline   Reply With Quote
Old 01-04-2015, 02:49 AM   #6
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
For the column contents, the following general program mode template should work:
Code:
program:
	list_union(
		'',
		strcat(
			contains(field('#cola'), 'yes', 'ColA,', ''),
			contains(field('#colb'), 'yes', 'ColB,', ''),
			contains(field('#colc'), 'yes', 'ColC,', ''),
		), ',')
For coloring, you would define a custom coloring rule that looks something like the following. It works because the above template produces the list in a known order.
Code:
program:
	v = field('#composite');
	first_non_empty(
		strcmp(v, '', '', 'azure', ''),
		strcmp(v, 'cola', '', 'orange', ''),
		strcmp(v, 'colb', '', 'red', ''),
		strcmp(v, 'colc', '', 'blue', ''),
		strcmp(v, 'cola, colb', '', 'yellow', ''),
		strcmp(v, 'cola, colc', '', 'pink', ''),
		strcmp(v, 'colb, colc', '', 'mauve', ''),
		strcmp(v, 'cola, colb, colc', '', '#445533', ''),
	)
The last color is an RGB specification. Note that it is very possible that the performance will not be acceptable because of all the tests.
chaley is offline   Reply With Quote
Old 01-04-2015, 03:05 AM   #7
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
chaley, the first template produces "colAcolBcolC"...

add
',',
to the end of the first two lines inside strcat.

I stole your idea of strcat'ing inside the list_union and edited my post above.

Last edited by eschwartz; 01-04-2015 at 03:10 AM.
eschwartz is offline   Reply With Quote
Old 01-04-2015, 03:08 AM   #8
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by eschwartz View Post
chaley, the first template produces "colAcolBcolC"...

add
',',
to the end of the first to lines inside strcat.
The commas are in my template. 'ColA,' etc.
chaley is offline   Reply With Quote
Old 01-04-2015, 11:10 AM   #9
ElMiko
Addict
ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.
 
ElMiko's Avatar
 
Posts: 320
Karma: 56788
Join Date: Jun 2011
Device: Kindle
I'm embarrassed to admit it, but it looks like I'm in way over my head. I really appreciate all your input, but I don't know where I am adding these programs or how I am referring to them within the custom column. And that's just for starters!

@chaley: with the commas inside the display value, does that mean that if only #cola was positive, the displayed value would be "ColA,"?
ElMiko is offline   Reply With Quote
Old 01-04-2015, 11:20 AM   #10
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ElMiko View Post
I'm embarrassed to admit it, but it looks like I'm in way over my head. I really appreciate all your input, but I don't know where I am adding these programs or how I am referring to them within the custom column. And that's just for starters!
Eschwartz's template or my first template are used in a custom "column built from other columns, behaves like tags". You can add/edit the template when you define the column or by pressing F2 in any cell in that column after you define it.

My second template goes into an advanced coloring rule.
Quote:
@chaley: with the commas inside the display value, does that mean that if only #cola was positive, the displayed value would be "ColA,"?
No. The list_union eliminates empty list items, which is what a trailing comma would produce. In other words, "ColA,,,ColB," would become "ColA, ColB". That is also why eschwartz used list_union, to eliminate extra commas that his template generates when any of the "part?" variables are empty.
chaley is offline   Reply With Quote
Old 01-04-2015, 03:17 PM   #11
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,422
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by chaley View Post
The commas are in my template. 'ColA,' etc.
So they are. Didn't notice it because it was hidden in the return value for contains. I put them in separate strings to strcat, I guess it just makes it easier for me to visualize.



Is it strictly necessary for this to be a behaves-like-tags custom template column?
eschwartz is offline   Reply With Quote
Old 01-04-2015, 03:48 PM   #12
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by eschwartz View Post
Is it strictly necessary for this to be a behaves-like-tags custom template column?
No, but I think using behaves-like-tags makes the column more useful in the tag browser and (if used) calibre companion. After all, it is in fact a list of values, which is what "like tags" is designed for.
chaley is offline   Reply With Quote
Old 01-04-2015, 08:55 PM   #13
ElMiko
Addict
ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.ElMiko actually enjoys Vogon poetry.
 
ElMiko's Avatar
 
Posts: 320
Karma: 56788
Join Date: Jun 2011
Device: Kindle
@chaley & eschwartz — Thank you both for all your help! You were tremendously helpful. Frankly, I had hoped (and tried) to figure this out on my own, but soon relaized that I was boxing outside my weightclass. Thanks again!
ElMiko is offline   Reply With Quote
Reply

Tags
custom column


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Color Columns shows 2 'Formats' phossler Calibre 2 10-22-2014 10:22 AM
Composite column problem combining two tag type columns At_Libitum Recipes 1 08-29-2013 12:31 PM
Designing for Kobo AlexBell ePub 45 01-21-2013 01:09 AM
composite custom columns sorted numerically Doug-W Library Management 2 02-18-2011 02:16 AM
Coding headings in color Alda ePub 11 01-27-2011 07:57 AM


All times are GMT -4. The time now is 02:42 PM.


MobileRead.com is a privately owned, operated and funded community.