Download the PHP package mistralys/column-widths-calculator without Composer

On this page you can find all versions of the php package mistralys/column-widths-calculator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package column-widths-calculator

Build Status Scrutinizer Code Quality

Column widths calculator

Small utility that can be used to convert arbitrary numeric values to column widths. Given a list of column names and values, it will intelligently convert the values to percentages, and fill empty columns with meaningful values.

Features:

Installation

Using composer, simply require the package.

Via command line:

Via composer.json:

Usage

Use the factory method to instantiate the calculator:

This will return an array with the same keys, and the missing column value filled out:

Switching between integers and floats

By default, the calculator will produce integer values, even if all internal calculations are float based for precision. This can be turned off to retrieve float values:

In this case, no rounding is done at all - you will have to manually handle any rounding you wish to apply.

Handling minimum widths

When leaving columns empty to be automatically filled, there may not be enough width left for the columns to fill. Consider this configuration of columns:

By default, the calculator will guarantee that every column has a minimum width of 1. As a result, the list would be adjusted like this, to allow the third column to have a width:

The surplus is subtracted from all non-empty columns, proportionally to their size (without going below the minimum width).

Setting the minimum size

The minimum size can be set like this:

This will ensure that all columns have a minimum size of 20%.

Example:

Would give the following result:

NOTE: The maximum possible value for the minimum size depends on the amount of columns. Trying to set the minimum size to 40% for 3 columns for example, will throw an exception (40 x 3 is bigger than 100).

Arbitrary numbering

The calculator can work with any number system, and converts the values proportionally.

Consider the following values:

This will be converted to the following values:

Missing values

As long as there are more than one column with values, missing values will be filled with a value based on an average of the existing values, to get realistic results.

For example, the values:

Will be converted to this:

Changing the target value

By default, the Calculator assumes you want to work with percentages, and has the target value locked to 100. However, it is possible to adjust this value:

In the example above, the column widths will be calculated to reach a total of 1000, instead of the default 100.

Converting to absolute pixel values

For convenience, the getPixelValues() method can convert the column percentages to absolute pixel values, given the maximum target width.

The following example converts the column widths to reach a width of 600px:

The resulting widths will be:


All versions of column-widths-calculator with dependencies

PHP Build Version
Package Version
Requires mistralys/application-utils Version >=1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mistralys/column-widths-calculator contains the following files

Loading the files please wait ....