Below is the example of using the GetWbkMd operation to get a workbook chart. The request contains an instance of opened workbook and parameters of getting various types of charts for the workbook. The response contains the requested charts.
{
"GetWbkMd" :
{
"tWbk" :
{
"id" : "S1!M!S!W7"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"useGridAutoAdjust" : "true",
"lanerChart" : "true",
"getLanerChart" :
{
"pattern" :
{
"data" : "false",
"decoration" : "false",
"hiChart" : "false",
"asImage" :
{
"width" : "400",
"height" : "300",
"dpi" : "96",
"format" : "image\/png"
}
}
},
"getModellingChart" :
{
"pattern" :
{
"data" : "false",
"decoration" : "false",
"hiChart" : "false",
"asImage" :
{
"width" : "400",
"height" : "300",
"dpi" : "96",
"format" : "image\/png"
}
}
}
}
}
}
}
{
"GetWbkMdResult" :
{
"id" :
{
"id" : "S1!M!S!W7"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "2",
"@hf" : "0",
"i" : "WBK_CALC",
"n" : "Calculated series",
"k" : "5541",
"c" : "2827",
"p" : "5471",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"trackElementDependents" : "0",
"isPermanent" : "1",
"isTemp" : "0"
}
},
"dirty" : "1",
"windowsPosition" : "Vertical",
"hasPivot" : "0",
"hasLaner" : "1",
"series" :
{
"@count" : "4",
"its" : ""
},
"lanerChart" :
{
"type" : "Simple",
"series" :
{
"it" :
[
{
"type" : "Simple",
"available" : "0",
"visible" : "0"
},
{
"type" : "Factor",
"available" : "0",
"visible" : "0"
},
{
"type" : "Fact",
"available" : "0",
"visible" : "1"
},
{
"type" : "Modeling",
"available" : "0",
"visible" : "1"
},
{
"type" : "Forecast",
"available" : "0",
"visible" : "1"
},
{
"type" : "Residuals",
"available" : "0",
"visible" : "1"
},
{
"type" : "UpperConfidenceLevel",
"available" : "0",
"visible" : "0"
},
{
"type" : "LowerConfidenceLevel",
"available" : "0",
"visible" : "0"
},
{
"type" : "DUpperConfidenceLevel",
"available" : "0",
"visible" : "0"
},
{
"type" : "DLowerConfidenceLevel",
"available" : "0",
"visible" : "0"
},
{
"type" : "B01",
"available" : "0",
"visible" : "1"
},
{
"type" : "D10",
"available" : "0",
"visible" : "1"
},
{
"type" : "D11",
"available" : "0",
"visible" : "1"
},
{
"type" : "D12",
"available" : "0",
"visible" : "1"
},
{
"type" : "D13",
"available" : "0",
"visible" : "1"
},
{
"type" : "Aggregation",
"available" : "0",
"visible" : "1"
},
{
"type" : "Factors",
"available" : "0",
"visible" : "1"
},
{
"type" : "Weights",
"available" : "0",
"visible" : "1"
},
{
"type" : "CompositionRelevance",
"available" : "0",
"visible" : "1"
}
]
}
},
"getLanerChart" :
{
"id" :
{
"id" : "S1!M!S!W7!wbkChart"
},
"meta" :
{
"asImage" : "iVBORw0KGgoAAAANSUhEUgAAAZAAAAEsCAYAAADtt+XCAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAmJSURBVHhe7drhkdo6G4ZhmqELmqAGGskfOqADKqACGqABGqABCvA3r2eVwzLeg3kSK9nvXNeMRlha\/809srIaACAgIABEBASAiIAAEBEQACICAkBEQACICAgAEQEBICIgAEQEBIBIHJDz+Txcr9ePp8\/2+\/2w3W7H0f7mdDqNzzUD8P1FAal4rFar4XK5fKx8ttlsxr0a9\/t9jEhbq\/mr8ADwfUQBqRNGjamA3G63YbfbjaeNw+EwrtVc0Sk1t3UAvq\/4E1ZFYCog7ZRRc\/tk9fi3NScB+fHjh2EYhtFpzPHbA1InkBqlxeJ3BQSA5f2xgNSJo60fj8dxtFNIqTm5SBcQgD66BqQuxetOpNTpY71ej5+v6lNWXaLXqEv3x7V3CQhAH4sHpELRQlC\/W0BKrVdcHkMxtfYOAQHoY\/GAPEvDMJeAAPTRPSBLExCAPgQEgIiAABAREAAiAgJAREAAiAgIABEBASAiIABEBASAiIAAEBEQACICAkBEQACICAgAEQEBICIgAEQEBICIgAAQERAAIgICQERAAIg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gJAREAAiAgIABEBASAiIABEBASAiIAAEBEQACICAkBEQACICAgAEQEBICIgAEQEBICIgAAQERAAIgICQERAAIgICAARAQEgIiAARAQEgIiAABAREAAiAgJAREAAiAgIABEBASDSLSDn83m4Xq8fT5\/t9\/thu92Oo\/3N6XQan2t+h4AA9NElIBWP1Wo1XC6Xj5XPNpvNuFfjfr+PEWlrNX8VnikCAtBHl4DUCaPGVEBut9uw2+3G08bhcBjXaq7olJrb+hwCAtBHl4CUisBUQNopo+b2yerxb2t+NyCGYRhGnzHHWwFpdxo1N18FpE4gNUqLxa8EBIC\/y1sBqTuL+of\/8e7iq4DUiaOtH4\/HcbRTSKn53Yt0AP4ev\/UTVoWlnU7q9LFer8cTS33Kqkv0GnXp\/rgGwPf0ywGpULQQ1O\/Hz1u1XnF5DMXUGgDfzy8H5JkwAPw3\/PaAAPDfICAARAQEgIiAABAREAAiAgJAREAAiAgIABEBASAiIABEBASAiIAAEBiG\/wEMwTTdmqzdXAAAAABJRU5ErkJggg==",
"toolTipImageMap" : ""
}
},
"getModellingChart" :
{
"id" :
{
"id" : "S1!M!S!W7!wbkModChart"
},
"meta" :
{
"asImage" : "iVBORw0KGgoAAAANSUhEUgAAAZAAAAEsCAYAAADtt+XCAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAARgSURBVHhe7dfBCQMxEARBh67Mz2\/9lgYLn6iCiaGZzwMAgYAAkAgIAImAAJAICACJgACQCAgAiYAAkAgIAImAAJAICACJgACQCAgAiYAAkLwmIGstMzM7tIlXBQSA3xMQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQAJIrA2JmZmc24YEAsBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBILkyIGZmdmYTHggAGwEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBILkyIGZmdmYTHggAGwEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBILkyIGZmdmYTHggAGwEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAkisDYmZmZzbhgQCwERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAkisDYmZmZzbxmoAA8F8EBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAASAQEgERAAEgEBIBEQABIBASAREAACJ7nC5J42aycBqolAAAAAElFTkSuQmCC",
"toolTipImageMap" : ""
}
}
}
}
}
public static GetWbkMdResult GetWbkChart(WbkId wbk)
{ // Set parameters for getting chart
GetChartArg ChartPtn = new GetChartArg()
{
pattern = new ChartMdPattern()
{
data = false,
decoration = false,
hiChart = false,
asImage = new ImageProperties()
{
format = "image/png",
width = 400,
height = 300,
dpi = 96.0
}
}
};
// Set operation execution parameters
var tOp = new GetWbkMd
{
tWbk = wbk,
tArg = new GetWbkMdArg
{// Set pattern for getting data
pattern = new WbkMdPattern
{
getLanerChart = ChartPtn,
lanerChart = true,
getModellingChart = ChartPtn
}
}
};
// Create a proxy object for operation execution
var somClient = new SomPortTypeClient();
// Execute operation
var gRes = somClient.GetWbkMd(tOp);
// Save charts as images
if (chartSave(gRes.meta.getLanerChart.meta.asImage, "D:\\LanerChart.png"))
{ Console.WriteLine("Workbook chart is saved to the 'LanerChart.png' file"); }
else { Console.WriteLine("Workbook chart is absent"); };
if (chartSave(gRes.meta.getModellingChart.meta.asImage, "D:\\ModellingChart.png"))
{ Console.WriteLine("Calculated series chart is saved to the 'ModellingChart.png' file"); }
else { Console.WriteLine("Calculated series chart is absent"); };
// Display workbook chart data in the console window
WbkChart lanerCh = gRes.meta.lanerChart;
switch (lanerCh.type)
{
case WbkChartType.DetermAggregation:
Console.WriteLine("Chart for data obtained after aggregation calculation");
break;
case WbkChartType.Simple:
Console.WriteLine("Chart for table data");
break;
case WbkChartType.SpliceMethod:
Console.WriteLine("Chart for data obtained after series splice");
break;
case WbkChartType.StatMethod:
Console.WriteLine("Chart for data obtained after statistical method calculation");
break;
};
int avable = 0;
int vivsible = 0;
Listseries = new List ();
foreach (WbkChartSerie ser in lanerCh.series)
{
if (ser.available.Value) { avable++; series.Add(ser.type.ToString()); };
if (ser.visible.Value) { vivsible++; };
};
Console.WriteLine("Total number of series available for displaying: " + vivsible);
Console.WriteLine("Available in the current chart:");
foreach (string s in series) { Console.WriteLine("".PadRight(3) + s); }
Console.WriteLine("".PadRight(3) + "Total series: " + avable);
return gRes;
}
// Function for saving chart to file
public static bool chartSave(byte[] chart, string name)
{
if (chart.Length !=0)
{
MemoryStream fs = new MemoryStream(chart);
Bitmap img = new Bitmap(fs);
img.Save(name, System.Drawing.Imaging.ImageFormat.Png);
img.Dispose(); fs.Dispose();
return true;
}
else { return false; };
}
See also: