Jpgraph Chinese manual jpgraph Color Control Instruction Tutorial

Source: Internet
Author: User
Tags array manual transparent color php tutorial php web development range require

Continue to translate the Jpgraph help document in the form of a Chinese PHP tutorial, today is about how to control the color of the chart when using Jpgraph, mainly involving the description of several colors in the Jpgraph class library; color transparency, How brightness is controlled and how the color transparency and brightness are indicated during use. You want to help developers who create charts using Jpgraph.

Using the appropriate color is an important part of creating clear, intuitive charts. To simplify color processing, Jpgraph supports several methods of adjusting and manipulating colors, such as by name or value.

Almost all of the color setting methods for all objects have two main naming styles

  SetColor () sets the color of the outline or if the object has only one color (such as a font) set this color

  Setfillcolor () fills the color of the specified Range object.

Both methods require a parameter to identify the color

  To specify a color by color name

Jpgraph has a list of names that correspond to a standard set of colors, refer to the list of color names in Appendix D in the Jpgraph English document.

SetColor (' white ')
Setfillcolor (' orange ')

It's quicker and easier to always use a single quote string when you don't need to replace a variable

  Specify color by RGB value

Using a named color depends on the color that the Jpgraph class library knows. If additional colors are required, they need to be specified manually.

The first method uses RGB values to specify the color, which is red, green, and blue. Each component is specified by an integer in the range 0-255. Like what

SetColor (Array (255,255,255))
SetColor (Array (0XFF,0XFF,0XFF))
Setfillcolor (Array (0X44,0X54,0XA4))

The commonly used array arrays (0,0,0) represent black, and Array (255,255,255) represents white.

  Use HTML color to specify

The second approach is to use a 16-in-color RGB value similar to the RGB array, which is used in HTML Web pages, such as

SetColor (' #333 '), note that it is a short form, consistent with SetColor (' #333333 ')
SetColor (' #12be7a ')
Setfillcolor (' #99eff5)

  Fine-tuning processing of colors

This part mainly introduces the control of color transparency and brightness.

  Specify alpha channel (color transparency)

By specifying transparency, colors can also become translucent.

The alpha channel can specify the color transparency by specifying a number within the 0.0-1.0 range, 0.0 for opacity, and 1.0 for full transparency, which shows only the background color. Transparency is added with the @ character. Typically used in zone fills (that is, when using the Setfillcolor () method), such as

Setfillcolor (' red@0.2′), slightly transparent red
Setfillcolor (' red@0.8′), almost full transparent color

The effect of using different alpha values is as follows, and as the blue becomes more and more transparent, the Red bar chart becomes clearer.

Example of using jpgraph to control transparency of colors

  Use Jpgraph to adjust brightness

Brightness coefficient by: character separation annoying color. The brightness coefficient value range is 0.0-2.0. Using brightness factor 0.0 indicates that the color will darken (without any brightness), and the 2.0 coefficient indicates a white color (maximum brightness). Using a factor of 1 will leave the original color unchanged.

Luminance coefficients can be used in named color names or HTML colors, such as

SetColor (' red:0.8′), slightly darker red.
SetColor (' red:1.5′), bright Hongse
SetColor (' #3485a9:1.8), bright blue-green

Adjusts the named color brightness and adjusts the brightness of the HTML color specifier, as shown in

Example of using jpgraph to adjust the brightness of a color

  A method of combining brightness and transparency adjustments

SetColor (' red@0.7:1.2′)
Setfillcolor (' #4545aa @0.3:1.5′)

The first value after @ represents transparency, and the second value represents brightness

  Additional Color processing Instructions

There are some plot types that require additional color processing to make it easier to handle and differentiate between datasets.

  Pie plots

Pie charts support the concept of color themes. A color theme is a simple set of colors for continuous slices within a pie chart.

  Color maps

Matrices (only in pro versions) and contour graphs also have the concept of color maps.

At this point, the tutorial on using the Jpgraph class library to work with the chart colors is done, and the color transparency and brightness controls supported by Jpgraph are very useful, and the methods and naming methods for color settings are ideal for web designers.

  Note : PHP Web Development Tutorials-leapsoul.cn Copyright, reproduced in the form of links to indicate the original source and this statement, thank you.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.