Size Column - Bar Colors

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Irwin of Upton
Posts: 131
Joined: 28 Feb 2015 19:42

Size Column - Bar Colors

Post by Irwin of Upton »

Have done some research and comprehend that the Width is hard coded to 50 pixels. But how to change those arbitrary colors to something more logical? Have in mind the visible portion of the Electromagnetic spectrum as the frequency increases; Red, Orange, Yellow, Green, Blue, Indigo and Violet. :eh:

jupe
Posts: 2757
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Size Column - Bar Colors

Post by jupe »

If you wanted to make the width bigger you could create a custom column, and that would enable you to set the color as you see fit. Granted it would take a bit of effort on your part, but you should be able to get something close to what it is you seem to want to achieve, if you are interested in further information then you can type the following into the XY address bar:

Code: Select all

help "idh_customcolumns.htm#idh_ccdrawingbars";
and here is an example:

Code: Select all

// draws colored bars according to the file size
$size = "<cc_size>";
switch (true){
 case $size == 0:          return ''; // draw nothing
 case $size < 1024:        return '>draw.bar ' . 100 * $size \ 1024 . ', 66CC66, BBEEBB';        //smaller 1 KB
 case $size < 1048576:     return '>draw.bar ' . 100 * $size \ 1048576 . ', FFBB00, FFEE88';     //smaller 1 MB
 case $size < 1073741824:  return '>draw.bar ' . 100 * $size \ 1073741824 . ', DD4444, FFAAAA';  //smaller 1 GB
 default:                  return '>draw.bar ' . 100 * $size \ 1099511627776 . ', DD44AA, FFAADD';  //1 GB or more
}


Irwin of Upton
Posts: 131
Joined: 28 Feb 2015 19:42

Re: Size Column - Bar Colors

Post by Irwin of Upton »

Whoo - that is way different then what had been expected! Thank you for taking the time to show the path to pursue . Will work on it over the weekend. Am optimistic! :appl:

Irwin of Upton
Posts: 131
Joined: 28 Feb 2015 19:42

Apology to Don

Post by Irwin of Upton »

In the post mentioned it would be better to have colors "more logical". While playing with this Saturday it dawned on me the the sequence green-yellow-red comes right off a traffic light. That clearly is making more sense to the average Joe than a piece of the spectrum.

Understanding that will leave things as they are. Indeed, one does have to know "when to hold 'em and when to fold "em". :biggrin:

giuliastar
Posts: 365
Joined: 14 Sep 2013 07:22

Re: Size Column - Bar Colors

Post by giuliastar »

jupe wrote: 20 Jan 2018 07:29 If you wanted to make the width bigger you could create a custom column, and that would enable you to set the color as you see fit. Granted it would take a bit of effort on your part, but you should be able to get something close to what it is you seem to want to achieve, if you are interested in further information then you can type the following into the XY address bar:

Code: Select all

help "idh_customcolumns.htm#idh_ccdrawingbars";
and here is an example taken directly from the help file:

Code: Select all

// draws colored bars according to the file size
$size = "<cc_size>";
switch (true){
 case $size == 0:          return ''; // draw nothing
 case $size < 1024:        return '>draw.bar ' . 100 * $size \ 1024 . ', 66CC66, BBEEBB';        //smaller 1 KB
 case $size < 1048576:     return '>draw.bar ' . 100 * $size \ 1048576 . ', FFBB00, FFEE88';     //smaller 1 MB
 case $size < 1073741824:  return '>draw.bar ' . 100 * $size \ 1073741824 . ', DD4444, FFAAAA';  //smaller 1 GB
 default:                  return '>draw.bar ' . 100 * $size \ 1099511627776 . ', DD44AA, FFAADD';  //1 GB or more
}

hi
sorry my silly question , i really like xyplorer but i use simple task
to run this code should i go scripting -> run script.... -> and paste the code?
thanks

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Size Column - Bar Colors

Post by highend »

to run this code should i go scripting -> run script.... -> and paste the code?
No, it's a custom column script, it's only usable there...
One of my scripts helped you out? Please donate via Paypal

autocart
Posts: 1246
Joined: 26 Sep 2013 15:22

Re: Size Column - Bar Colors

Post by autocart »

jupe wrote: 20 Jan 2018 07:29

Code: Select all

// draws colored bars according to the file size
$size = "<cc_size>";
switch (true){
 case $size == 0:          return ''; // draw nothing
 case $size < 1024:        return '>draw.bar ' . 100 * $size \ 1024 . ', 66CC66, BBEEBB';        //smaller 1 KB
 case $size < 1048576:     return '>draw.bar ' . 100 * $size \ 1048576 . ', FFBB00, FFEE88';     //smaller 1 MB
 case $size < 1073741824:  return '>draw.bar ' . 100 * $size \ 1073741824 . ', DD4444, FFAAAA';  //smaller 1 GB
 default:                  return '>draw.bar ' . 100 * $size \ 1099511627776 . ', DD44AA, FFAADD';  //1 GB or more
}
Slight improvement, just in case somebody interested in using it:

Code: Select all

// draws colored bars according to the file size
$size = "<cc_size>";
switch (true){
 case $size == 0:          return ''; // draw nothing
 case $size < 1024:        return '>draw.bar ' . 100 * $size \ 1024 + 1 . ', 66CC66';        //smaller 1 KB
 case $size < 1048576:     return '>draw.bar ' . 100 * $size \ 1048576 + 1 . ', FFBB00';     //smaller 1 MB
 case $size < 1073741824:  return '>draw.bar ' . 100 * $size \ 1073741824 + 1 . ', DD4444';  //smaller 1 GB
 default:                  return '>draw.bar ' . 100 * $size \ 1099511627776 + 1 . ', DD44AA';  //1 GB or more
}
Changes are:
Minimum with of bar: 1 percent. Otherwise it could have "0 percent" which results in XY drawing the whole bar like if it was 100 percent.
Skipped secondary color: Thus, the right part of the bar is transparent.

Could look like in the pic.
Attachments
Clipboard-20211031 (2).png
Clipboard-20211031 (2).png (8.33 KiB) Viewed 967 times

Post Reply