Как переключать видимость имен линий и кривых на Spotfire с Iron Python? - PullRequest
0 голосов
/ 02 января 2019

Я пытался создать скрипт IronPython для переключения имен горизонтальных линий BarChart безуспешно.

Я бы хотел добиться этого нажатием кнопки: enter image description here

Код, который я сейчас использую:

from System.Drawing import Color
from Spotfire.Dxp.Application.Visuals import *

# vis parameter referencing an existing BarChart visualization
vis = vis.As[BarChart]()

# Read the document property with the toggle value (true/false)
Document.Properties['GenericToggleLineNames'] = not Document.Properties['GenericToggleLineNames']

#Loop through all the Lines & Curves collection
if Document.Properties['GenericToggleLineNames']:
    for fm in vis.FittingModels:
        if fm.Line.DisplayName == 'Defined Underload Limit':
            fm.Line.CustomDisplayName = 'Defined Underload Limit'
        elif fm.Line.DisplayName == 'Defined Warning Limit':
            fm.Line.CustomDisplayName = 'Defined Warning Limit'
        elif fm.Line.DisplayName == 'Defined Critical Limit':
            fm.Line.CustomDisplayName = 'Defined Critical Limit'
else:
    for fm in vis.FittingModels:
        if fm.Line.DisplayName == 'Defined Underload Limit':
            fm.Line.CustomDisplayName = ''
        elif fm.Line.DisplayName == 'Defined Warning Limit':
            fm.Line.CustomDisplayName = ''
        elif fm.Line.DisplayName == 'Defined Critical Limit':
            fm.Line.CustomDisplayName = ''

Но когда я добираюсь до «Show = true», код не меняет CustomDisplayNames.

Согласно API Spotfire, DisplayName предлагает только метод get , в то время как CustomDisplayName предлагает get и set .

Кто-нибудь знает, как создать этот переключатель?

Ответы [ 2 ]

0 голосов
/ 04 января 2019

Мне удалось заставить его работать отвратительно. Поделюсь здесь, если кому-то это нужно, но, пожалуйста, хотелось бы найти правильный способ сделать это.

Несмотря на то, что Документация по Spotfire API упоминает, что ReferenceCurve.DisplayName - это свойство только для чтения (имеет только метод get ), похоже, оно изменяется при обновлении CustomDisplayName.

Имея это в виду, я создал еще один набор IF , ища «новое» DisplayName и заменяя их старыми.

# Imports
from System.Drawing import Color
from Spotfire.Dxp.Application.Visuals import *

#Add a vis parameter referencing an existing LineChart visualization
vis = vis.As[BarChart]()

#Loop through all the Lines & Curves collection
Document.Properties['GenericVisualisationDescriptions'] = not Document.Properties['GenericVisualisationDescriptions']

if Document.Properties['GenericVisualisationDescriptions']:
    for fm in vis.FittingModels:
        if fm.Line.DisplayName == ' ':
            fm.Line.CustomDisplayName = 'Defined Underload Limit'
        elif fm.Line.DisplayName == '  ':
            fm.Line.CustomDisplayName = 'Defined Warning Limit'
        elif fm.Line.DisplayName == '   ':
            fm.Line.CustomDisplayName = 'Defined Critical Limit'
else:
    for fm in vis.FittingModels:
        print fm.Line.DisplayName
        print fm.Line.CustomDisplayName
        if fm.Line.DisplayName == 'Defined Underload Limit':
            fm.Line.CustomDisplayName = ' '
        elif fm.Line.DisplayName == 'Defined Warning Limit':
            fm.Line.CustomDisplayName = '  '
        elif fm.Line.DisplayName == 'Defined Critical Limit':
            fm.Line.CustomDisplayName = '   '
0 голосов
/ 02 января 2019

Я написал сообщение в блоге о том, как это сделать. Пожалуйста, перейдите сюда - https://datashoptalk.com/ironpython-in-spotfire-turning-lines-curves-on-and-off/. Код будет отличаться в зависимости от того, что у вас есть на странице. Пожалуйста, подтвердите, если вы получили правильный ответ с этим сообщением.

...