Scruffy是什么?

Scruffy是一个用来生成图表的ruby库,它的功能非常强大,可以用它来做web开发,在页面上输出多媒体数据。
Scruffy的主要特性包括:
  • 基于 SVG
    Scruffy 基于 SVG 技术来生成图表 . 这也使得Scruffy具备SVG的许多优点,譬如文件的大小与图形的复杂程度有关,而与图形的具体尺寸无关。
  • Mix-n-Match Graphs
    对于Scruffy生成的图表不局限于单一的图表类型(线,柱状,区域等)。你可以对每一个数据集指定一个不同的类型
  • 快照呈递
    你可以任意的多次输出同一个Scruffy图表,或者是修改每一次输出图表的设置(数据、颜色,甚至图表的尺寸和图标类型)。
  • 可扩展性
    Scruffy具有很强的可扩展性。可以通过仅仅几行代码来添加新的图表类型或者主题。  如果你需要更多的图像控制功能,也可以自定义输出,生成数据等等内容。
安装
sudo gem install scruffy

实例:

graph = Scruffy::Graph.new graph.title = "Favourite Snacks" graph.renderer = Scruffy::Renderers::Pie.new graph.add :pie, '', { 'Apple' => 20, 'Banana' => 100, 'Orange' => 70, 'Taco' => 30 } graph.render :to => "pie_test.svg" graph.render :width => 300, :height => 200, :to => "pie_test.png", :as => 'png'
graph = Scruffy::Graph.new graph.title = "Sample Line Graph" graph.renderer = Scruffy::Renderers::Standard.new graph.add :line, 'Example', [20, 100, 70, 30, 106] graph.render :to => "line_test.svg" graph.render :width => 300, :height => 200, :to => "line_test.png", :as => 'png'
graph = Scruffy::Graph.new graph.title = "Sample Line Graph" graph.renderer = Scruffy::Renderers::Standard.new graph.add :line, 'Example', [20, 100, 70, 30, 106] graph.render :to => "line_test.svg" graph.render :width => 300, :height => 200, :to => "line_test.png", :as => 'png'
graph = Scruffy::Graph.new graph.title = "Long-term Comparisons" graph.value_formatter = Scruffy::Formatters::Currency.new( :special_negatives => true, :negative_color => '#ff7777') graph.renderer = Scruffy::Renderers::Split.new( :split_label => 'Northeastern (Top) / Central (Bottom)') graph.add :area, 'Jeff', [20, -5, 100, 70, 30, 106, 203, 100, 50, 203, 289, 20], :category => :top graph.add :area, 'Jerry', [-10, 70, 20, 102, 201, 26, 30, 106, 203, 100, 50, 39], :category => :top graph.add :bar, 'Jack', [30, 0, 49, 29, 100, 203, 70, 20, 102, 201, 26, 130], :category => :bottom graph.add :line, 'Brasten', [42, 10, 75, 150, 130, 70, -10, -20, 50, 92, -21, 19], :categories => [:top, :bottom] graph.add :line, 'Jim', [-10, -20, 50, 92, -21, 56, 92, 84, 82, 100, 39, 120], :categories => [:top, :bottom] graph.point_markers = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] graph.render :to => "split_test.svg" graph.render :width => 500, :to => "split_test.png", :as => 'png'
堆叠图
graph = Scruffy::Graph.new
    graph.title = "Comparative Agent Performance"
    graph.value_formatter = Scruffy::Formatters::Percentage.new(:precision => 0)
    graph.add :stacked do |stacked|
      stacked.add :bar, 'Jack', [30, 60, 49, 29, 100, 120]
      stacked.add :bar, 'Jill', [120, 240, 0, 100, 140, 20]
      stacked.add :bar, 'Hill', [10, 10, 90, 20, 40, 10]
    end
    graph.point_markers = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
    graph.render :to => "stacking_test.svg"
    graph.render  :width => 500, :to => "stacking_test.png", :as => 'png'
graph = Scruffy::Graph.new graph.title = "Some Kind of Information" graph.renderer = Scruffy::Renderers::Cubed.new graph.add :area, 'Jeff', [20, -5, 100, 70, 30, 106], :categories => [:top_left, :bottom_right] graph.add :area, 'Jerry', [-10, 70, 20, 102, 201, 26], :categories => [:bottom_left, :buttom_right] graph.add :bar, 'Jack', [30, 0, 49, 29, 100, 203], :categories => [:bottom_left, :top_right] graph.add :line, 'Brasten', [42, 10, 75, 150, 130, 70], :categories => [:top_right, :bottom_left] graph.add :line, 'Jim', [-10, -20, 50, 92, -21, 56], :categories => [:top_left, :bottom_right] graph.point_markers = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'] graph.render :to => "multi_test.svg" graph.render :width => 500, :to => "multi_test.png", :as => 'png'

本文转自 fsjoy1983 51CTO博客,原文链接:http://blog.51cto.com/fsjoy/168842,如需转载请自行联系原作者

Don’t Worry.Be Scruffy.相关推荐

  1. 忧天的“杞人” worry wart

    "我今天迟到了30秒,老板会不会炒我鱿鱼啊?""刚才老板经过我这里的时候看了我一眼,我是不是做错什么事情了啊?"--你身边有这样的同事吗?他们成天有担不完的心, ...

  2. pytorch测试,pil 读取图片 “IOError incurred when reading ‘{}‘. Will redo. Don‘t worry. Just chill

    #"IOError incurred when reading '{}'. Will redo. Don't worry. Just chill 加入以下 问题解决 from PIL imp ...

  3. Steave Jobs

    乔布斯传中总计包括数字在内用词15487个. 出现3次(包括三次以上的单词)6788个. 1: 49 1,000: 9 1,500: 3 1,995: 3 1.0: 4 1.2: 3 1.8-inch ...

  4. 最近收集的9000个英语单词

    wrong                                   adj.错误的:不道德的:不适合的:不正常的adv.错误地n.坏事:不公正的事:错误v.无礼地对待:冤枉 visuali ...

  5. 深度学习之:使用 Hugging face 做知识蒸馏 teacher-bert 到 student-bert

    文章目录 导包 加载参数 前期准备工作 蒸馏 构造 dataloader 构造 student 和 teacher 模型 github 资源 源代码在上面的 github 资源中 导包 import ...

  6. php recordarray,Array 数组 - [ php中文手册 ] - 在线原生手册 - php中文网

    用户评论: [#1] florenxe [2015-10-07 18:53:45] //a nice little way to print leap years using array for ($ ...

  7. Dissecting BERT Part 1: The Encoder 解析BERT解码器(transformer)

    原文:https://medium.com/dissecting-bert/dissecting-bert-part-1-d3c3d495cdb3 A meaningful representatio ...

  8. 开放神经网络交换(ONNX)工具

    开放神经网络交换(ONNX)工具 开放神经网络交换(ONNX)是一个开放的生态系统,它使人工智能开发人员能够在项目发展过程中选择正确的工具.ONNX为人工智能模型提供了一种开源格式,包括深度学习和传统 ...

  9. Simple NHibernate Architecture[from]

    原文地址:http://www.codeproject.com/aspnet/NHibernateArchitecture.asp Download source - 2,523.7 KB Intro ...

最新文章

  1. 搜狗CEO王小川:AI领域存在泡沫 但留下的是珍珠
  2. 模板实参推导 xx_cast的实现
  3. Java程序员从笨鸟到菜鸟之(二十八)Javascript总结之语言基础
  4. Redis 命令--Redis哈希(hash)
  5. Android之URL “page={page}category_id={***} string For dynamic query parameters use @Query.
  6. P1445-[Violet]樱花【数学】
  7. elementUI vue 编辑中的input的验证残留清除
  8. tomcat vue 不用 前后端_部署前后端分离项目(后端 tomcat 前端 nginx)
  9. word for Mac 符号插入
  10. cad导入图片之间相互转换
  11. python 将一串数字形式的时间转换为标准时间格式
  12. d3带箭头和点击事件的力导向关系图
  13. 正态分布累积函数及其反函数 C/C++
  14. 不要去外包亲身经历告诉你 去外包的后果
  15. 字母不同类型_只是我的类型跟踪字母的演变,第2部分
  16. fedora 25 安装字体
  17. 天津高一学业水平测试计算机,2019年1月天津高中学业水平考试标准
  18. 老吕架构-2022~2021年文章索引
  19. 小灰熊卡拉OK字幕设计工具KBuilder 3.5 使用说明
  20. 论文解析[5] nnU-Net: Breaking the Spell on Successful Medical Image Segmentation

热门文章

  1. 内部控制检查和内部控制审计的区别
  2. 【转】VB动态拖曳ListBox Item位置
  3. 【引用】mkswap 把一个分区格式化成为swap交换区
  4. WINDOWS系统自动登录设置
  5. 搜狗Q1每天进账1886万,输入法日处理6亿请求成中国最大语音App
  6. 超详细深度学习debug指南,国外小哥手把手教你如何调试模型 | 附PPT
  7. 真·干货!这套深度学习教程整理走红,从理论到实践的带你系统学习 | 资源...
  8. 大咖来信 | 李国杰院士:AI创业光靠算法走不远,警惕命运魔咒
  9. ubuntu 下 lighttpd 支持 mod_cgi 的配置文件
  10. Android断点续传下载器JarvisDownloader