回 帖 发 新 帖 刷新版面

主题:求助:我设计了一个图,但是图中的数据如何设置?

thisform.mschart1.visible=.t.
select 1
no=reccount()-1
thisform.mschart1.charttype=mycharttype
thisform.mschart1.rowcount=no
thisform.mschart1.columnlabel="完成数"
thisform.mschart1.titletext="&rwjm"    &&设置图表标题
thisform.mschart1.title.vtfont.size=16  &&设置字体大小
thisform.mschart1.footnotetext="杭州"   &&设置注脚文本
thisform.mschart1.footnote.vtfont.size=12  &&设置字体大小
thisform.mschart1.showlegend=.f.
for i=1 to no step 1
    select 1
    go i
    mymonth=项目内容
    mymoney=杭州完成
    thisform.mschart1.row=i
    thisform.mschart1.rowlabel=alltrim(mymonth)
    *thisform.mschart1.rowLabel(2)=ALLTRIM(STR(杭州完成))
    thisform.mschart1.data=mymoney
    ENDFOR
    其中 thisform.mschart1.data=mymoney  是c1,现在想问C2怎么设?

回复列表 (共1个回复)

沙发

********************************************************************************************
****  图表模块初始化,导入外部数据(如有的话),初始化数据列表
********************************************************************************************
Note: aDataArray(X , N)=行数据数组,第一列数据是列标题,第2~N列数据是数据值
Note: aCol_Label_Array( X )=系列标题数组,其元素个数和aDataArray数组的数据列数相同(列数-1)
Note: 列标题和系列标题的关系是:每个列可以有多个系列(例如“张三”列,有销售额、回款额2个系列)
Note: [cFormCaption] = 表单表题
Note: [cTitleText] = 图表标题
Note: nChartType = 图表类型(详见Chart控件的属性)
Parameters aDataArray  , aCol_Label_Array , cFormCaption , cTitleText , nChartType
Extern array aDataArray , aCol_Label_Array        && 声明外部引用数组(N*2)
Local I , J , ItemCount , Col_Count , cExample , cTitle , nData

if VarType(aDataArray)= "C" and VarType(aCol_Label_Array)="C"
** 第一维数据是字符,其他维数据是数字
        m.ItemCount = Alen(aDataArray,1)        && 数据行数
        m.Col_Count = Alen(aDataArray,2)-1        && 数据列数
        IF m.Col_Count<>ALEN(aCol_Label_Array)
            RETURN MESSAGEBOX("数据的列数和列标题个数不符!" , 48 , "系统提示")
        ENDIF
        ****** 绘制图表 ******
        WITH thisform.MsChart
            .RowCount = m.ItemCount
            .ColumnCount = m.Col_Count
            .RandomFill = .F.                        && 不使用随机数据
[color=FF0000]        for m.I=1 to m.Col_Count
            m.cExample = aCol_Label_Array(m.I)        && 列标题
            .Column = m.I
            .ColumnLabel = m.cExample
            for m.J=1 to m.ItemCount
                m.cTitle = aDataArray(m.J , 1)        && 行标题
                m.nData = aDataArray(m.J , m.I+1)    && 数值数据
                .Row = m.J
                 .RowLabel = m.cTitle
                .Data = m.nData
            endfor
        endfor[/color]            

        if VarType(m.cFormCaption)="C"
            thisform.Caption = m.cFormCaption
        else
            thisform.Caption = "图表"                        && 默认表单标题
        endif

        if VarType(m.cTitleText)="C"
            .TitleText = m.cTitleText
        else
            .TitleText = ""                && 默认图表标题
        endif
        ENDWITH
            
        if VARTYPE(m.nChartType)="N"
            thisform.MsChart.ChartType = m.nChartType    && 如果指定了图表类型就直接使用
        ELSE
            thisform.MsChart.ChartType = 1                && 默认为折线型
        ENDIF
ELSE
    MESSAGEBOX("请输入正确的数据格式!" , 48 , "系统提示")
ENDIF

我来回复

您尚未登录,请登录后再回复。点此登录或注册