以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]图表坐标系格式化问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=192845)

--  作者:浙江仔
--  发布时间:2024/7/26 11:34:00
--  [求助]图表坐标系格式化问题

图片点击可在新窗口打开查看此主题相关图片如下:微信截图_20240726113141.png
图片点击可在新窗口打开查看

代码使用    Series.DataLabelText = "{#YVAL:0.00%}"

结果没有显示真实数值,都显示成了100%

另外Y轴在窗口中可以显示格式化字符,但是这个专业报表中还是显示数值,这该怎么处理一下?



--  作者:有点蓝
--  发布时间:2024/7/26 11:48:00
--  
请提供实例测试
--  作者:浙江仔
--  发布时间:2024/7/26 12:21:00
--  
\'生成图表
Dim Chart As New ChartBuilder \'定义一个图表变量
Dim Series As WinForm.ChartSeries \'定义一个图系变量
Chart.SeriesList.Clear() \'清除图表原来的图系
Chart.HeaderText = "设备分时在线率"
Dim projects As List(Of String) = DataTables("ssls_make_device_status_count").GetValues("PROJECT")
For Each project As String In projects
    Series = Chart.SeriesList.Add() \'每个项目一个图系
    Series.DataLabelText = "{#YVAL:0.00%}"
    Dim ln As String = project
    Dim fdr As DataRow = DataTables("ssls_dw_project").Find("PROJECT_ID=\'" & project & "\'")
    If fdr IsNot Nothing Then
        ln = fdr("PROJECT_NAME")
    End If 
    Series.Text = ln \'指定图系名称为项目(到时改名称)
    Dim sjs As List(Of String) = DataTables("ssls_make_device_status_count").GetValues("sj", "", "sj")
    Dim x As Integer = 4 \'每个8个点取一个
    Series.Length = sjs.count \\ x \'指定图系的数据点数
    \'    Output.Logs("调试日志").Add(Series.Length)
    \'    Output.Logs("调试日志").Save(ProjectPath & "logs\\调试日志" + format(Date.today, "yyyy-MM-dd") + ".txt", True)
    Dim i As Integer = 0
    Dim j As Integer = 0
    For Each sj As String In sjs
        If (j Mod x) = 0 Then
            Series.X(i) = i \'指定水平坐标为月份
            Chart.AxisX.SetValueLabel(i, sj.SubString(11, 5)) \'指定字符表示
            Dim p As DataRow = DataTables("ssls_make_device_status_count").Find("PROJECT = \'" & project & "\' And  SJ = \'" & sj & "\' And  lx = \'总数\'")
            Dim it As Integer = 0
            If p IsNot Nothing Then
                it = p("COUNT(PRODUCTION)")
            End If
            
            Dim zx As Integer = 0
            p = DataTables("ssls_make_device_status_count").Find("PROJECT = \'" & project & "\' And SJ = \'" & SJ & "\' And lx = \'在线\'")
            If p IsNot Nothing Then
                zx = p("COUNT(PRODUCTION)")
            End If
            If it > 0 AndAlso zx > 0 Then
                Series.Y(i) = zx / it \'指定数量作为垂直坐标 
                
            Else
                Series.Y(i) = 0 \'指定数量作为垂直坐标    
            End If
            
            \'            Output.Logs("调试日志").Add(Series.Y(i))
            \'            Output.Logs("调试日志").Save(ProjectPath & "logs\\调试日志" + format(Date.today, "yyyy-MM-dd") + ".txt", True)
            i = i + 1
        End If
        j = j + 1
        \'        Series.TooltipText = "X = {#XVAL}, Y = {#YVAL}"
    Next
    
Next

Chart.AxisX.AnnoWithLabels = True \'启用字符标示
Chart.LegendVisible = True \'显示图列
Chart.LegendCompass = CompassEnum.South \'图列显示在南方(底端)
Chart.AxisY.AnnoFormatString = "0%"
Chart.PrintWidth = 120
Chart.PrintHeight = 70
\'打印图表
Dim rm As New prt.RenderImage
rm.Image = Chart.Image
doc.Body.Children.Add(rm)

--  作者:有点蓝
--  发布时间:2024/7/26 13:39:00
--  
我测试没有问题,请上传实例说明


图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看