#이미지 한 장을 보여주는 방법 .
1. Document properties 등록
File > Document properties > Properties > Document Properties 창에서 New 선택
New Property 창 > Property name 입력 > Data type : Binary 선택 > Ok
2. Script 등록
Document properites 창에서 1번에서 생성한 Property 선택 > Script 선택
Script - Act on Property Change 창 > Execute the script selected below 선택 > New 선택
New Script 창 > Scipt Name 입력 > Scipt 입력 > OK 선택
from System.IO import MemoryStream, SeekOrigin
from System import Uri
from System.Net import HttpWebRequest
from System.Drawing import Image
from System.Drawing.Imaging import ImageFormat
from Spotfire.Dxp.Data import BinaryLargeObject
uriString = "web url path"
uri = Uri(uriString)
webRequest = HttpWebRequest.Create(uri)
webRequest.Method = "GET"
rsp = WebRequest.GetResponse()
img = Image.FromStream(rsp.GetResponseStream())
rsp.Close()
stream = MemoryStream()
img.Save(stream, ImageFormat.Png)
stream.Seek(0, SeekOrigin.Begin)
blob = BinaryLargeObject.Create(stream)
Document.Properties["PngImage"] = blob
방금 저장한 script 선택 > ok
Ok 선택
4. Text area 생성
Edit Text Area 선택
Insert Property Control > Label > Property Control 창 팝업
2번에서 등록한 property 선택 후 저장
## Marking 된 데이터에 해당하는 이미지 변경하기
데이터셋
Name , URL
A, "A image Path"
B, "B image Path"
C, "C image Path"
A, B, C 를 선택할때마다 해당에 이미지가 보여지게 만들자.
1. Marking을 하기 위한 bar-Chart 생성
그래프 오른쪽 상단 property 아이콘 선택 > Distribution Properties 창에서 Data 선택
Marking Name 확인 : 제일 처음에는 Marking 이라고 되어 있음
밑에 Script에서 MyMarkingName에 Marking name을 입력해주면 됨 .
2. Document properties 등록
File > Document properties > Properties > Document Properties 창에서 New 선택
New Property 창 > Property name 입력 > Data type : Binary 선택 > Ok
3. Script 등록
Document properites 창에서 1번에서 생성한 Property 선택 > Script 선택
Script - Act on Property Change 창 > Execute the script selected below 선택 > New 선택
New Script 창 > Scipt Name 입력 > Scipt 입력 > OK 선택
from System.IO import MemoryStream, SeekOrigin
from System import Uri
from System.Net import HttpWebRequest
from System.Drawing import Image
from System.Drawing.Imaging import ImageFormat
from System.Collections.Generic import List
from Spotfire.Dxp.Data import *
########## import marking data
dataTable = Document.Data.Tables["MyDataTable"]
dataMarkingSelection = Document.Data.Markings["MyMarkingName"]
cursor = DataValueCursor.CreateFormatted(dataTable.Columns["MyColumn"])
selection = Document.ActiveMarkingSelectionReference.GetSelection(dataTable)
markeddata = List [str]()
# iterate through the data talbe rows to retrieve the marked rows
for row in dataTable.GetRows(selection.AsIndexSet(), cursor):
value = cursor.CurrentValue
if value <> str.Empty:
markeddata.Add(value)
# Get only unique values
valData = List [str] (set(markeddata))
# Store in a document property
valImageURLs = ','.join(valData)
############### Show image
uriString = valImagesURLs
uri = Uri(uriString)
webRequest = HttpWebRequest.Create(uri)
webRequest.Method = "GET"
rsp = webRequest.GetResponse()
img = Image.FromStream(rsp.GetResponseStream())
rsp.Close()
stream = MemoryStream()
img.Save(stream, ImageFormat.Png)
stream.Seek(0, SeekOrigin.Begin)
blob = BinaryLargeObject.Create(stream)
Document.Properties["PropertyName"] = blob
Script - Act on Property Change 창에서 저장된 Script 선택 후 OK 선택
Document Properties 창에서 생성한 Property 선택 후 OK 선택
4. 이미지를 보여주기 위한 Text Area 생성
오른쪽상단 연필모양 Edit Text Area 선택
Edit Text Area 창 > 메뉴바에서 Insert Action Control 선택
Action Control 창 > 왼쪽 Script 선택 > Display text 입력 : 이미지 업로드 > Control type : Button > 3번에서 생성한 스크립트 선택 > OK 선택
Edit Text Area 창 > 메뉴바에서 Insert Property Contro 선택 > Label 선택
Property Control 창 > Document Properties 탭 선택 > 3번에서 만든 property 선택 > ok 선택
Edit Text Area 창 > 저장 후 닫기
5. 이미지 연동확인
1번에서 생성한 bar-Chart에서 img1 을 선택 > Text Area에서 이미지 업로드 버튼 선택 > image 확인
'IT' 카테고리의 다른 글
SSO(Single Sign On) 이란? 어디에다 쓰는거임? (0) | 2024.04.22 |
---|