styleColorLegends

Set legend color palettes. Expect an array of "hex" values or "html" color-names.

Note

You can set as less as you want, if a color is missing it will filled with “#000000”

Specification

Default implementation: { styleColorLegends : ["#5186EC", "#D95040", "#F2BD42"] }

Key

Name Alias Category 
styleColorLegends style__color__legends Style 

Value

Allow hex values including short writing needs to with starting with #.

Default Validation Type 
["#5186EC", "#D95040", "#F2BD42"] ^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$ Array 

Example A.

Set color legend palette to: ["yellow", "red", "green"]

Output

Open output in a blank window. Download examples as zip.

Parameters

This dataset shows the mobile and desktop google pagerank performance score for a certain website.

  Value Type
Source "https://docs.statosio.com/data/performance.json"  
X "name" String
Y [ "mobile", "desktop" ] Array
Options { "styleColorLegends" : ["yellow", "red", "green"] } Object

Javascript

  • Invoke Function
d3.statosio( 
    file, 
    "name", 
    [ "mobile",  "desktop" ], 
    { "styleColorLegends" : ["yellow", "red", "green"] }
)
  • HTML Implementation
<!DOCTYPE html>
<head>
    <title>docs.statosio - styleColorLegends</title>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
    <meta content="utf-8" http-equiv="encoding">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/6.2.0/d3.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/statosio/0.9/statosio.js"></script>
</head>
<body>
    <script>
        d3.json( "https://docs.statosio.com/data/performance.json" )
            .then( ( file ) => {
                d3.statosio( 
                    file, 
                    "name", 
                    [ "mobile",  "desktop" ], 
                    { "styleColorLegends" : ["yellow", "red", "green"] }
                )
            } )
    </script>
</body>

Ruby

  • Gem Install
gem install statosio
gem install prawn
gem install prawn-svg
gem install open-uri
  • Implementation
require "statosio"

require "open-uri"
require "prawn"
require "prawn-svg"

url = "https://docs.statosio.com/data/performance.json"
file = OpenURI::open_uri( url ).read
dataset = JSON.parse( file )

statosio = Statosio::Generate.new
chart = statosio.svg(
    dataset: dataset,
    x: "name", 
    y: [ "mobile",  "desktop" ],
    options: {"styleColorLegends"=>["yellow", "red", "green"]}
    
)

Prawn::Document.generate( "statosio.pdf" ) do | pdf |
  pdf.svg( chart, width: 500 )
end

Example B.

Output

Open output in a blank window. Download examples as zip.

Parameters

This dataset shows the mobile and desktop google pagerank performance score for a certain website.

  Value Type
Source "https://docs.statosio.com/data/performance.json"  
X "name" String
Y [ "mobile", "desktop" ] Array
Options { "styleColorLegends" : ["#f59351", "#c9504a", "#12514c", "#2f7872", "#a6b797"] } Object

Javascript

  • Invoke Function
d3.statosio( 
    file, 
    "name", 
    [ "mobile",  "desktop" ], 
    { "styleColorLegends" : ["#f59351", "#c9504a", "#12514c", "#2f7872", "#a6b797"] }
)
  • HTML Implementation
<!DOCTYPE html>
<head>
    <title>docs.statosio - styleColorLegends</title>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
    <meta content="utf-8" http-equiv="encoding">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/6.2.0/d3.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/statosio/0.9/statosio.js"></script>
</head>
<body>
    <script>
        d3.json( "https://docs.statosio.com/data/performance.json" )
            .then( ( file ) => {
                d3.statosio( 
                    file, 
                    "name", 
                    [ "mobile",  "desktop" ], 
                    { "styleColorLegends" : ["#f59351", "#c9504a", "#12514c", "#2f7872", "#a6b797"] }
                )
            } )
    </script>
</body>

Ruby

  • Gem Install
gem install statosio
gem install prawn
gem install prawn-svg
gem install open-uri
  • Implementation
require "statosio"

require "open-uri"
require "prawn"
require "prawn-svg"

url = "https://docs.statosio.com/data/performance.json"
file = OpenURI::open_uri( url ).read
dataset = JSON.parse( file )

statosio = Statosio::Generate.new
chart = statosio.svg(
    dataset: dataset,
    x: "name", 
    y: [ "mobile",  "desktop" ],
    options: {"styleColorLegends"=>["#f59351", "#c9504a", "#12514c", "#2f7872", "#a6b797"]}
    
)

Prawn::Document.generate( "statosio.pdf" ) do | pdf |
  pdf.svg( chart, width: 500 )
end