New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

statosio

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

statosio

  • 0.3.5
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Usage

Statosio.rb is based on statosio.js and helps to generate simple charts, in a fast and reliable way.

Statosio generate charts in a .svg format. Works with prawn-svg to generate .pdf documents. All Charts Data can be searched no information get lost.

✔️ build simple diagrams fast and reliable, with one function!
✔️ pure javascript, no additonal css.
✔️ highly customizable with 40+ style and data options.

Video Introduction: https://www.youtube.com/watch?v=i6od9O8jz1E

Documentation: https://d3.statosio.com

Chart Types

Bar

# d3.statosio
Create simple bar chart

Point

# d3.statosio
Create a simple point chart

Stacked

# d3.statosio
Create simple stacked bar chart

Features

Select

# d3.statosio
Select and change position of columns

Sort Data

# d3.statosio
Sort dataset by values

Change Style

# d3.statosio
Change style to dark-mode

Quickstart

gem install 'statosio'
gem install 'open-uri'
gem install 'json'
require 'statosio'
require 'open-uri'
require 'json'

# Initialize Statosio
statosio = Statosio::Generate.new

# Load Sample Dataset
url = 'https://d3.statosio.com/data/performance.json'
content = URI.open( url ).read
dataset = JSON.parse( content )

# Generate chart as .svg
chart = statosio.svg(
    dataset: dataset,
    x: 'name',
    y: 'mobile',
    options: {}
)

puts chart
# -> <svg>[]....</svg>

Statosio with prawn

gem install 'statosio'
gem install 'prawn'
gem install 'prawn-svg'
require 'open-uri'
require 'statosio'

require 'prawn'
require 'prawn-svg'

# Initialize Statosio
statosio = Statosio::Generate.new

# Load Sample Dataset
url = 'https://d3.statosio.com/data/performance.json'
content = URI.open( url ).read
dataset = JSON.parse( content )

# Generate Statosio
chart = statosio.svg(
    dataset: dataset,
    x: 'name',
    y: 'mobile',
    options: {}
)

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

Parameters

ValueTypeRequired
dataset[{},{}...]Array of Hashyes
x"name"Stringyes
y"mobile", [ "mobile",... ]String or Array of Stringsyes
options{}Hashyes
silenttrue or falseBooleanno

Options

OptionDefaultExamplesDescription 
A.1.showTitlefalseA, BShow or hide title on the front of the diagram.
A.2.showLegendfalseA, B, CShow or hide legend. Recommended for stacked diagrams.
A.3.showAveragetrueA, B, CCalculate and show average line
A.4.showRangeYLogfalseA, BCalculate and show range y in a log scale.
A.5.showDataAsCirclefalseA, B, CShow data as circles instead of rectangles. Only for not stacked diagram available.
B.1.viewTitle"Statosio Demo"ASet title content.
B.2.viewDomId"d3_statosio"ASet id from the
Element which holds the d3 content inside.
B.3.viewMarginTop20A, BSet margin top
B.4.viewMarginRight40A, BSet margin right
B.5.viewMarginBottom100A, BSet margin bottom
B.6.viewMarginLeft60A, BSet margin left
B.7.viewWidthOuter600A, BSet width of the "canvas" including margin, titles etc.
B.8.viewHeightOuter300A, BSet height of the "canvas" including margin.
B.9.viewTranslateMultiplicator1.5A, BBetween title, legend and diagram are spaces. These spaces gets calculated through this multiplicator.
C.1.dataXKey""Expect a "key" name from the dataset to arrange the x range.
C.2.dataXSelectors[]A, BExpect one or more names which are included in the x range.
C.3.dataXTextLength25A, BThis value counts the length of the x range names an cut of the rest.
C.4.dataXTextPlaceholder"..."A, BSet an suffix behind a string. As a signal to the viewer, that the text was cut of.
C.5.dataYKeys[]Expect "keys" from the dataset to arrange the y range. If you use one key the internal state is "bar". if you use multiple the internal is "stacked"
C.6.dataYTicks5A, BTicks in d3 land means "steps". Here you can set the steps from the grid and y range.
C.7.dataSortCurrent"none"A, BSet the general route for sorting. You can choose between "none", "values", "names".
C.8.dataSortByValues"decending"A, B, CHere you can set type of sorting. You can choose between "ascending" and "decending"
C.9.dataSortByNames"ascending"A, BHere you can set type of sorting. You can choose between "ascending" and "decending"
C.10.dataSortSelection"none"A, B, CChange position of your selection. You can choose between "start", "end" and "none"
C.11.dataLegendTextSeparater"_"AThis tweak split your keys with the separater and capitalize every word and insert a space in between.
D.1.styleColorAverage"#000000"A, BSet color of the average line.
D.2.styleColorCanvasBackground"white"A, BSet background color.
D.3.styleColorFont"#000000"A, BSet default font color. Excluding non-selection content.
D.4.styleColorLegends["#5186EC", "#D95040", "#F2BD42"]A, BSet legend color palettes. Expect an array of "hex" values or "html" color-names.
D.5.styleColorGridline"#E5E5E5"A, BSet the gridline color. Use "hex" value or "html" color-names.
D.6.styleColorSelectorsChart["#EE752F", "#5186EC"]A, BColorize the chart of the selection. Use "hex" values or "html" color-names.
D.7.styleColorSelectorsText["#000000", "#000000"]A, BColorize the font of the selection. Use "hex" values or "html" color-names.
D.8.styleFontSizeText10A, BSet default font size, including selection.
D.9.styleFontSizeTitle18A, BSet font size of title
D.10.styleFontFamily"arial"A, BSet default font family
D.11.styleFontFormatSelectors["bold", "normal"]A, BSet format of content use "Html" Syntax ("bold", "underline", "normal" etc.).
D.12.styleStrokeAverage2A, BSet stroke weight of average line.
D.13.styleStrokeGridline2A, BSet stroke weight of gridline.
D.14.styleLegendRectSizeFull16A, BSet rectangle size of legend item.
D.15.styleOtherCircleChartRadius4A, BSet radius of circle.
D.16.styleOtherRangeXTextRotation-45A, BSet text rotation of the x axis.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/a6b8/statosio.rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Statosio project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

FAQs

Package last updated on 05 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc