Degrafa + Datagrids = Visual Display of Data

原文链接:http://www.insideria.com/2008/03/degrafa-datagrids-visual-displ.html

If you are a Flex developer, and you haven't checked out Degrafa yet, you should. Degrafa is an open source declarative graphics framework for Flex. It allows you to easily create complex shapes, patterns, skins, gradients, strokes, etc... without intimate knowledge of the drawing API. The framework allows you to do some really cool things, without a lot of code. Kudos to the Degrafa team for their efforts.

I decided to try out Degrafa on a concept from one of my Cynergy blog posts: "Thinking Outside Of The Grid", from last May. Datagrids are great for displaying tabular data. With a little creative coding, you can turn them into dynamic charting components. Here's a quick example of what can be done with a Flex datagrid, Degrafa, and some time to kill.

View this demo full screen at:

http://www.tricedesigns.com/portfolio/degrafadatagrid/main.html 

This example doesn't cover the broad range of renderers shown in my previous post, however Degrafa helped make the code for this simple enough for anyone to duplicate.

I used Degrafa to create bar-chart representations of data displayed within a datagrid. Its quite simple actually... I created datagrid item renderers that use degrafa to dynamically draw a rectangle that represents disk usage. The code is pretty simple actually. You just create a fill style, then declare a rectangle that uses the fill. The width of the rectangle is dynamcially calculated based on the available width of the item renderer, and the calculated values. All of the calculation is done within data bindings, thus making the code very simple.

<mx:DataGridColumn headerText="Free" dataField="free">
   <mx:itemRenderer>
      <mx:Component>
         <mx:Canvas>
               
            <degrafa:Surface>
         
             <degrafa:fills>
          <paint:LinearGradientFill id="greenGradient" angle="90">
          <paint:GradientStop alpha="1" color="#00FF00"/>
          <paint:GradientStop alpha=".5" color="#333333"/>
          </paint:LinearGradientFill>
          </degrafa:fills>
         
          <degrafa:GeometryGroup>
          <geometry:RoundedRectangle
             fill="{greenGradient}"
          cornerRadius="0"
          width="{ width * ( data.free / data.capacity ) }"
          height="{ height }" />
          </degrafa:GeometryGroup>
         
          </degrafa:Surface>
         
         </mx:Canvas>
      </mx:Component>
   </mx:itemRenderer>
</mx:DataGridColumn>

You can view this demo full screen at:
http://www.tricedesigns.com/portfolio/degrafadatagrid/main.html

You can view the source code at:
http://www.tricedesigns.com/portfolio/degrafadatagrid/srcview/index.html

You can download the source code at:
http://www.tricedesigns.com/portfolio/degrafadatagrid/Degrafa Datagrid.zip

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值