OpenFlashChart使用

最近在做的项目需要经常使用图表,在使用了MSchart之后发现例子少,而且极其难控制.在网上搜了一下,找到OpenFlashChart这个开源项目,发现效果还不错,而且例子满全的,效果也不错.官方下载地址: http://teethgrinder.co.uk/open-flash-chart/.

该控件的数据传输方式是采用了JSON,所以有个C#写得项目是用来翻译把调用代码生成JSON代码.

下面贴下使用方法备忘:

1.编译openflashchart工程生成DLL引用到项目中.

2.在VS工具栏上加上该控件.

各种图形的生成代码:

1.饼图:

ContractedBlock.gif ExpandedBlockStart.gif Code
        OpenFlashChart.OpenFlashChart chart = new OpenFlashChart.OpenFlashChart();
        chart.Title 
= new Title("Pie Chart");

        OpenFlashChart.Pie pie 
= new OpenFlashChart.Pie();
        Random random 
= new Random();

        List
<PieValue> values = new List<PieValue>();
        List
<string> labels = new List<string>();
        
for (int i = 0; i < 12; i++)
        {
            values.Add(
new PieValue(random.NextDouble(),"Pie"+i));
            labels.Add(i.ToString());
        }
        
//values.Add(0.2);
        
        PieValue pieValue 
= new PieValue(10);
        pieValue.Click 
= "http://xiao-yifang.blogspot.com";
        values.Add(pieValue);
        pie.Values 
= values;
        pie.FontSize 
= 20;
        pie.Alpha 
= .5;
        AnimationSeries animationSeries 
= new AnimationSeries();
        animationSeries.Add(
new Animation("bounce",5));
        pie.Animate 
= animationSeries;
        
//pie.GradientFillMode = false;
        
        
//pie.FillAlpha = 10;

        
//pie.Colour = "#fff";
        pie.Colours = new string[]{"#04f","#1ff","#6ef","#f30"};
        pie.Tooltip
="#label#,#val# of #total##percent# of 100%";
        chart.AddElement(pie);
        chart.Bgcolor 
= "#202020";

柱状图:

ContractedBlock.gif ExpandedBlockStart.gif Code
  OpenFlashChart.OpenFlashChart chart = new OpenFlashChart.OpenFlashChart();
        chart.Title 
= new Title("Bar Chart");

        Bar bar 
= new OpenFlashChart.Bar();
        Random random 
= new Random();
        bar.Colour 
= "#344565";
        
        bar.FillAlpha 
= 0.4;
        bar.Text 
= "Test";
     
        bar.FontSize 
= 10;
        List
<object> values = new List<object>();
        
for (int i = 0; i < 12; i++)
            values.Add(random.Next(i, i 
* 2));
        BarValue barValue 
= new BarValue(12);
        barValue.OnClick 
= "http://xiao-yifang.blogspot.com";
        values.Add(barValue);
        bar.Values 
= values;
        chart.AddElement(bar);
        XAxis xaxis 
= new XAxis();
        xaxis.Labels.SetLabels(
new string[] { "text""#ef0""10""vertical" });
        
//xaxis.Steps = 1;
        
//xaxis.Offset = true;
        ////xaxis.SetRange(-2, 15);
        chart.X_Axis = xaxis;
        
//YAxis yaxis = new YAxis();
        
//yaxis.Steps = 4;
        
//yaxis.SetRange(0, 20);
        
//chart.Y_Axis = yaxis;
        chart.Y_Axis.SetRange(0,24,3);
        bar.Tooltip 
= "提示:label:#x_label#<br>#top#<br>#bottom#<br>#val#";

线状图:

ContractedBlock.gif ExpandedBlockStart.gif Code
 
 
本文转自温景良(Jason)博客园博客,原文链接:http://www.cnblogs.com/wenjl520/archive/2009/06/01/1493727.html,如需转载请自行联系原作者
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值