如何在asp.net中使用折线图 [英] How to use line chart in asp.net

查看:81
本文介绍了如何在asp.net中使用折线图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void M_getreport()
{
    String _strdata = "<chart caption='Temperature Monitoring (in degree C)' subCaption='(on 7/9/2006)' xAxisName='Time' yAxisMaxValue='100' bgColor='91AF46,FFFFFF'  divLineColor='91AF46' divLineAlpha='30' alternateHGridAlpha='5' canvasBorderColor='666666' baseFontColor='666666' lineColor='91AF46' numVDivlines='7' showAlternateVGridColor='1' anchorSides='3' anchorRadius='5' showValues='0' >";
    ArrayList ItemList = new ArrayList();
    ItemList.Add("JA");
    ItemList.Add("FB");
    ItemList.Add("MR");
    ItemList.Add("AP");
    ItemList.Add("MA");
    ItemList.Add("JU");
    ItemList.Add("JL");
    ItemList.Add("AU");
    ItemList.Add("SE");
    ItemList.Add("OC");
    ItemList.Add("NA");
    ItemList.Add("DS");
    Int32 _frommonth = 4;
    Int32 _tomonth = 9;
    Int32 _loop = _tomonth - _frommonth;
    Int32 _val = _tomonth - _frommonth;
    _strdata += "<categories>";
    int i = 0;
    for ( i = 4; i <= 9; i++)

    {

        _strdata += "<category label='" + ItemList[i] + "' /> ";
    }

    String _lastyer = "0";
    Int32 _status = 0;
    _strdata += "</categories>";

    var random = new Random();

    DataSet _ds = _ManagePointMaster.SP_checkreport(2009, 2012, _frommonth, _tomonth);

    for ( int j = 0; j < _ds.Tables[0].Rows.Count;j++)

    {

        if(_lastyer!=_ds.Tables[0].Rows[j]["year"].ToString())

        {

            if (_lastyer != "0")

            {



                if (_loop < _val)

                {

                    for (i = 0; i <= _loop; i++)

                    {

                        _strdata += "<set value='0' /> ";

                    }

                    _loop = _val;

                }



                _strdata += "</dataset>";

            }

            //var color = String.Format("#{0:X6}", random.Next(0x1000000));



            _strdata += "<dataset seriesName='" + _ds.Tables[0].Rows[j]["year"].ToString() + "' color='" + String.Format("#{0:X6}", random.Next(0x1000000)) + "'>";

            _lastyer = _ds.Tables[0].Rows[j]["year"].ToString();
        }

        for (Int32 k = _frommonth; k <= _tomonth; k++)

        {

            if (k.ToString() != _ds.Tables[0].Rows[j]["Month"].ToString())

            {

                _status = 1;

                //break;

            }

            else

            {

                _status = 0;

                break;

            }

        }



        if (_status==1)

        {

            _strdata += "<set value='0' /> ";

        }

        else

        {

            _strdata += "<set  value='" + _ds.Tables[0].Rows[j]["LID"].ToString() + "' /> ";
        }

        _loop = _loop - 1;
    }

    if (_loop < _val)

    {

        for (i = 0; i <= _loop; i++)

        {

            _strdata += "<set value='0' /> ";

            }



    }



    _strdata += "</dataset>";





       _strdata += "<styles>";

        _strdata += "<definition>";



        _strdata += "<style name='Anim1' type='animation' param='_alpha' start='0' duration='1' />";



    _strdata += "</definition>";



    _strdata += "<application>";



        _strdata += "<apply toObject='TRENDLINES' styles='Anim1' />";



    _strdata += "</application>";



_strdata += "</styles>";



    _strdata += "</chart>";





    txtdescc.Text = _strdata;

    Literal2.Text = FusionCharts.RenderChartHTML("FusionCharts/ScrollLine2D.swf", "", _strdata.ToString(), "myNext", "600", "500", false);

    //Response.Write(_strdata);



}

推荐答案

参考:
使用C#为WebForms创建折线图. [ ^ ]
asp.net中的折线图 [在ASP.NET应用程序中使用Microsoft的图表控件:入门 [在Google上 [
Refer:
Creating Line Chart For WebForms Using C#.[^]
Line chart in asp.net[^]
Using Microsoft''s Chart Controls In An ASP.NET Application: Getting Started[^]

Some videos:
on google[^]


这篇关于如何在asp.net中使用折线图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆