天天看點

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使用