天天看点

OpenFlashChart使用

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

下面贴下使用方法备忘:

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

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

各种图形的生成代码:

1.饼图:

OpenFlashChart使用
OpenFlashChart使用

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";

柱状图:

OpenFlashChart使用
OpenFlashChart使用

  OpenFlashChart.OpenFlashChart chart = new OpenFlashChart.OpenFlashChart();

        chart.Title = new Title("Bar Chart");

        Bar bar = new OpenFlashChart.Bar();

        bar.Colour = "#344565";

        bar.FillAlpha = 0.4;

        bar.Text = "Test";

        bar.FontSize = 10;

        List<object> values = new List<object>();

            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#";

线状图:

OpenFlashChart使用
OpenFlashChart使用