Page 1 of 1

Size Column - Bar Colors

Posted: 19 Jan 2018 14:27
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:

Re: Size Column - Bar Colors

Posted: 20 Jan 2018 07:29
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
}


Re: Size Column - Bar Colors

Posted: 20 Jan 2018 13:56
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:

Apology to Don

Posted: 22 Jan 2018 15:56
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:

Re: Size Column - Bar Colors

Posted: 23 May 2019 08:18
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

Re: Size Column - Bar Colors

Posted: 23 May 2019 10:20
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...

Re: Size Column - Bar Colors

Posted: 31 Oct 2021 17:39
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.