Я добавил таблицу в документ InDesign и заполненные данные в том же месте с помощью javascript. Но в одном месте мне нужно будет отображать горизонтальную гистограмму в зависимости от процента в ячейке таблицы. Ниже показано, как должен быть результат вывода? Гистограмма в ячейке таблицы InDesign с использованием javascript
На рисунке ниже это то, что я заселена
Кто-нибудь, пожалуйста, дайте мне знать, как это может быть сделано? Ниже приведен мой код для этого.
main();
function main(){
var inputBuild = "/C/Test/xml/A";
var inputIndt = "/C/Test/indt/B";
// Read indt file object.
var curFile = File (inputIndt+"/Draft.indt");
// check if the file exists
if (!curFile.exists) {
alert ("no template!");
exit();
}
// open the file
var curDoc = app.open(curFile);
// Reading xml file file
xmlFile = new File(inputBuild+"/Build.xml");
if (!xmlFile.exists) exit();
xmlFile.open("r");
xmlStr = xmlFile.read();
xmlFile.close();
root = new XML(xmlStr);
// Get text frames start
var curLayer = curDoc.layers[0];
tfTableFP = curLayer.textFrames.item("Tab_Fund_Position");
loadDataToTables(root, curLayer, '');
}
function loadDataToTables(root, curLayer, reportId){
var fundPosTable = tfTableFP.tables[0];
loadDataToFundPosition(root,fundPosTable);
}
function loadDataToFundPosition(root,tblName){
var fundPositionList = root.xpath("/Component/FundPositions/TableData/Item");
var rowCount = fundPositionList.length();
if(rowCount != 0){
tblName.bodyRowCount = rowCount;
for(counter = 0; counter < tblName.rows.length; counter++){
if (counter == 0 || counter == 1){
}else{
tblRow = tblName.rows.item(counter);
component = fundPositionList[counter-2];
for(cellCounter = 0; cellCounter < tblRow.cells.length; cellCounter++){
if(cellCounter == 0){
tblString = component.AssetGroup;
tblRow.cells.item(cellCounter).contents = tblString.toString();
}else if(cellCounter == 1){
/*Progress bar/bar graph for negative data to be populated in this cell*/
tblString = component.NetMarketExposure;
tblRow.cells.item(cellCounter).contents = tblString.toString();
}else if(cellCounter == 2){
/*Progress bar/bar graph for positive data to be populated in this cell*/
tblString = component.StrategicAllocation;
tblRow.cells.item(cellCounter).contents = tblString.toString();
}else if(cellCounter == 3){
tblString = component.FlexibleOverlay;
tblRow.cells.item(cellCounter).contents = tblString.toString();
}else if(cellCounter == 4){
tblString = component.NetRange;
tblRow.cells.item(cellCounter).contents = tblString.toString();
}
}
}
}
}
}
build.xml
<?xml version="1.0" encoding="UTF-8" ?>
<Component ID="645248" asmid="1" def="Sheet" type="Document">
<FundPositions>
<TableData>
<Item>
<RowRank>9</RowRank>
<Port_ID>201</Port_ID>
<RowType>asset_group total</RowType>
<AssetGroup>Test1</AssetGroup>
<AssetDetail>N/A</AssetDetail>
<ActiveSecurity>28.38%</ActiveSecurity>
<DerivativeOverlay>-13.34%</DerivativeOverlay>
<NetMarketExposure>15.04%</NetMarketExposure>
<StrategicAllocation>35%</StrategicAllocation>
<FlexibleOverlay>+/- 35%</FlexibleOverlay>
<NetRange>0% to 70%</NetRange>
</Item>
<Item>
<RowRank>9</RowRank>
<Port_ID>201</Port_ID>
<RowType>asset_group total</RowType>
<AssetGroup>Test2</AssetGroup>
<AssetDetail>N/A</AssetDetail>
<ActiveSecurity>29.17%</ActiveSecurity>
<DerivativeOverlay>-1.36%</DerivativeOverlay>
<NetMarketExposure>27.80%</NetMarketExposure>
<StrategicAllocation>30%</StrategicAllocation>
<FlexibleOverlay>+/- 30%</FlexibleOverlay>
<NetRange>0% to 60%</NetRange>
</Item>
<Item>
<RowRank>2</RowRank>
<Port_ID>201</Port_ID>
<RowType>asset_group total</RowType>
<AssetGroup>Test3</AssetGroup>
<AssetDetail>N/A</AssetDetail>
<ActiveSecurity>14.72%</ActiveSecurity>
<DerivativeOverlay>0.00%</DerivativeOverlay>
<NetMarketExposure>14.72%</NetMarketExposure>
<StrategicAllocation>15%</StrategicAllocation>
<FlexibleOverlay>+/- 20%</FlexibleOverlay>
<NetRange>-5% to 35%</NetRange>
</Item>
<Item>
<RowRank>2</RowRank>
<Port_ID>201</Port_ID>
<RowType>asset_group total</RowType>
<AssetGroup>Test4</AssetGroup>
<AssetDetail>N/A</AssetDetail>
<ActiveSecurity>17.15%</ActiveSecurity>
<DerivativeOverlay>0.00%</DerivativeOverlay>
<NetMarketExposure>17.15%</NetMarketExposure>
<StrategicAllocation>15%</StrategicAllocation>
<FlexibleOverlay>+/- 20%</FlexibleOverlay>
<NetRange>-5% to 35%</NetRange>
</Item>
<Item>
<RowRank>3</RowRank>
<Port_ID>201</Port_ID>
<RowType>asset_group total</RowType>
<AssetGroup>Test5</AssetGroup>
<AssetDetail>N/A</AssetDetail>
<ActiveSecurity>5.34%</ActiveSecurity>
<DerivativeOverlay>0.00%</DerivativeOverlay>
<NetMarketExposure>5.34%</NetMarketExposure>
<StrategicAllocation>5%</StrategicAllocation>
<FlexibleOverlay>+/- 15%</FlexibleOverlay>
<NetRange>-10% to 20%</NetRange>
</Item>
<Item>
<RowRank>1</RowRank>
<Port_ID>201</Port_ID>
<RowType>detail</RowType>
<AssetGroup>Test6</AssetGroup>
<AssetDetail>Cash & Cash Equivalents</AssetDetail>
<ActiveSecurity>18.24%</ActiveSecurity>
<DerivativeOverlay>0.91%</DerivativeOverlay>
<NetMarketExposure>19.15%</NetMarketExposure>
<StrategicAllocation>N/A</StrategicAllocation>
<FlexibleOverlay>N/A</FlexibleOverlay>
<NetRange>N/A</NetRange>
</Item>
<Item>
<RowRank>2</RowRank>
<Port_ID>201</Port_ID>
<RowType>asset_group total</RowType>
<AssetGroup>Test7</AssetGroup>
<AssetDetail>N/A</AssetDetail>
<ActiveSecurity>-16.25%</ActiveSecurity>
<DerivativeOverlay>17.06%</DerivativeOverlay>
<NetMarketExposure>0.80%</NetMarketExposure>
<StrategicAllocation>N/A</StrategicAllocation>
<FlexibleOverlay>N/A</FlexibleOverlay>
<NetRange>N/A</NetRange>
</Item>
</TableData>
<FundPositions_Summary>Net Market exposure summary</FundPositions_Summary>
<FundPositions_Total>100.00%</FundPositions_Total>
</FundPositions>
</Component>
Эй! друзья знали, как это сделать? – yatinbc