首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >spotfire获取网格面板的名称

spotfire获取网格面板的名称
EN

Stack Overflow用户
提问于 2016-06-14 06:56:56
回答 2查看 978关注 0票数 13

假设我有一个可视化,它是通过某个分类变量按面板格式化的,每页有一个面板。我想循环遍历面板,并将每个图像导出到一个文件中,文件名与分类变量匹配。

图像导出完全正常,遵循一些已发布的示例。然而,我在实际获取当前面板的名称以便正确命名图像时遇到了很多问题。

下面是我的代码:

代码语言:javascript
复制
from Spotfire.Dxp.Application.Visuals import VisualContent
from System.Drawing import Bitmap, Graphics, Rectangle, Point
from System.IO import Path
import re

vc=viz.As[VisualContent]() #viz is the visualization parameter passed to the script
trellis=vc.Trellis

originalIndex=trellis.ActivePageIndex

outputDir=Document.Properties["imageOutputDir"]

for i in range(trellis.PageCount):
    #move to the right page
    trellis.ActivePageIndex=i

    #make the actual image - 
    viz_r = Document.ActivePageReference.GetVisualBounds(viz)
    width=viz_r.Width
    height=viz_r.Height
    bm = Bitmap(width,height)
    g = Graphics.FromImage(bm)
    g.TextRenderingHint = g.TextRenderingHint.AntiAlias
    r=Rectangle(0, 0, width,height)
    vc.Render(g, r)

    #save the image

    name="%d"%i
    #here we would like to instead get the current value of the trellis variable!
    #name=?

    clean_name=re.sub(r'[/\\:*?"<>|]', '_',name)
    tempFilename = outputDir+"\\%s.png"%clean_name
    bm.Save(tempFilename)
    print "image saved as " + tempFilename

trellis.ActivePageIndex=originalIndex

我似乎找遍了VisualContentTrellis的所有方法,但都没有找到它。

另一种方法是遍历数据,只获取分类变量的值。但是,顺序不一定会被保留,所以这并不能很好地工作。如果我可以得到每个格子面板对应的数据,我当然可以从那里开始工作。

EN

回答 2

Stack Overflow用户

发布于 2016-08-24 05:24:05

这就是我最终要做的。当变量的类型为string并被排序为standard sort order for datatype时,这似乎是有效的。

如果有人能让排序变得更健壮,肯定会很受欢迎。基本上,我必须通过加载文本数据和检查排序来找出spotfire使用的字母数字排序。我可能忘记了一些字符--这似乎暂时适用于我的数据。

我无法访问Niko建议的TryGetCustomSortOrder方法--我使用的是Spotfire 6.5,它只在7.0中可用

代码语言:javascript
复制
from Spotfire.Dxp.Application.Visuals import VisualContent
import Spotfire.Dxp.Data.DataTable
from Spotfire.Dxp.Data import *
from System.Drawing import Bitmap, Graphics, Rectangle, Point
from System.IO import Path
import re

vc=viz.As[VisualContent]()
trellis=vc.Trellis
name_column=trellis.PanelAxis.Expression.Trim('<').Trim('>').Trim('[').Trim(']')
#get the unique column values
myTable = Document.ActiveDataTableReference
rowCount = myTable.RowCount
rowsToInclude = Document.ActiveFilteringSelectionReference.GetSelection(myTable).AsIndexSet()
cursor1 = DataValueCursor.Create(myTable.Columns[name_column])

S=set()
for row in myTable.GetRows(rowsToInclude,cursor1):
    x=cursor1.CurrentDataValue.Value
    if x not in S:
        S.add(x)
L=list(S)

alphabet=r' _-,;:!.\'"(){}@*/\&#%`^+<=>|~$0123456789abcdefghijklmnopqrstuvwxyz'

L=sorted(L,key=lambda s:[alphabet.index(c) if c in alphabet else -1 for c in s.lower()])
#things not in alphabet probably unicode characters that get sorted to the beginning

originalIndex=trellis.ActivePageIndex
outputDir=Document.Properties["imageOutputDir"]

for i,name in enumerate(L):
    trellis.ActivePageIndex=i
    viz_r = Document.ActivePageReference.GetVisualBounds(viz)
    width=viz_r.Width
    height=viz_r.Height
    bm = Bitmap(width,height)
    g = Graphics.FromImage(bm)
    g.TextRenderingHint = g.TextRenderingHint.AntiAlias

    r=Rectangle(0, 0, width,height)
    vc.Render(g, r)

    clean_name=re.sub(r'[/\\:*?"<>|]', '_',name)
    tempFilename = outputDir+"\\%s.png"%clean_name
    bm.Save(tempFilename)
    print "image saved as " + tempFilename

trellis.ActivePageIndex=originalIndex
票数 4
EN

Stack Overflow用户

发布于 2016-08-22 08:41:05

我搜索了几次,最终找到了TIBCO的支持人员。不幸的是,没有办法访问网格标题。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37800420

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档