S
Salil Gaitonde
Hello.
I have a 3D Chart in OWC that is taking a long time to generate
because of the size of the data.
The chart has 6 series, each with about 8500+ data points in it. I've
attached the code below, with some lines snipped out so that's more
readable.
One possible performance issue I can think of is that I have to build
a 2 dimensional array in VB. This is array is about 6 by 8866
elements. (Incidentally, I've found that this step is significantly
faster in VB versus JScript. Has anyone else seen this?) This step
is labeled "PERFORMANCE PROBLEM #1".
The second area of the code I suspect a bottleneck is that I have to
individually set the interior and border color of each data point. I
have to do this because the data is individually color coded, and I
cannot use the "Range" function to set the color en mass. This is
labeled as "PERFORMANCE PROBLEM #2".
Can anyone recommend alternatives to these approaches that could speed
this code up? Or does anyone see other bad practices in my code that
are causing the slowness? I greatly appreciate any help on this.
Thank you very much, in advance.
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns="urn:schemas-microsoft-comfficeffice"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
</style>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<script language="VBScript">
Function createTimeAxis()
Dim timeAxis( 8866 , 0 )
timeAxis(0 , 0 ) = "Tue Jun 01 00:00:00 CDT 2004"
....snip...
timeAxis(8862 , 0 ) = "Sun Aug 01 13:00:00 CDT 2004"
timeAxis(8863 , 0 ) = "Sun Aug 01 13:10:00 CDT 2004"
timeAxis(8864 , 0 ) = "Sun Aug 01 13:20:00 CDT 2004"
createTimeAxis = timeAxis
End Function
// ----------------PERFORMANCE ISSUE #1 ------------ //
Function createSeries()
Dim seriesData( 8866 , 5 )
seriesData(0 , 0) = "0.0"
....snip...
seriesData(8863 , 0) = "0.0"
seriesData(8864 , 0) = "0.0"
seriesData(0 , 1) = "16.46"
....snip...
seriesData(8862 , 1) = "0.0"
seriesData(8863 , 1) = "0.0"
seriesData(8864 , 1) = "0.0"
seriesData(0 , 2) = "98.10001"
....snip...
seriesData(8862 , 2) = "0.0"
seriesData(8863 , 2) = "0.0"
seriesData(8864 , 2) = "0.0"
seriesData(0 , 3) = "66.0"
....snip...
seriesData(8862 , 3) = "0.0"
seriesData(8863 , 3) = "0.0"
seriesData(8864 , 3) = "0.0"
seriesData(0 , 4) = "79.02001"
....snip...
seriesData(8862 , 4) = "0.0"
seriesData(8863 , 4) = "0.0"
seriesData(8864 , 4) = "0.0"
seriesData(0 , 5) = "95.00501"
....snip...
seriesData(8862 , 5) = "0.0"
seriesData(8863 , 5) = "0.0"
seriesData(8864 , 5) = "0.0"
createSeries = seriesData
End Function
</script>
<script language="JScript">
function genSpreadSheet() {
objNew = document.createElement("OBJECT");
objNew.classid = "clsid:0002E551-0000-0000-C000-000000000046";
x objNew.id = "sp";
objNew.Visible = true;
// Get a new workbook.
var oWB = objNew.ActiveWorkbook;
var oSheet = oWB.ActiveSheet;
range = objNew.ActiveCell;
cellRange = "A2:A" + 8866;
range.Range( cellRange ).NumberFormat = "General";
range.Range( cellRange ).Font.Size = "8";
range.Range( cellRange ).Value = createTimeAxis();
cellRange = "B2:B4000";
cellRange = "B2:G8866";
range.Range( cellRange ).NumberFormat = "Standard";
range.Range( cellRange ).Font.Size = "8";
range.Range( cellRange ).Value = createSeries();
return objNew;
}
function genGraph( objNew ) {
objNew2 = document.createElement("OBJECT");
objNew2.classid = "clsid:0002E556-0000-0000-C000-000000000046";
objNew2.id = "chsp";
var c = objNew2.Constants;
//load some sample data
var ch = objNew2.Charts.Add();
objNew2.Charts(0).Type = c.chChartTypeColumn3D;
objNew2.Charts(0).ProjectionMode =
c.chProjectionModeOrthographic;
objNew2.Charts(0).AmbientLightIntensity = 0.75;
objNew2.Charts(0).DirectionalLightInclination = 60;
objNew2.Charts(0).DirectionalLightIntensity = 1.0;
objNew2.Charts(0).DirectionalLightRotation = 90;
objNew2.DisplayToolbar= false;
objNew2.DisplayPropertyToolbox = false;
objNew2.DataSource = objNew;
objNew2.HasPlotDetails = false;
var timeAxisConfig =
objNew2.Charts(0).Axes(c.chAxisPositionTimescale);
var yAxisConfig = objNew2.Charts(0).Axes(1);
yAxisConfig.HasTitle = true;
yAxisConfig.Title.Caption = "RAM utilization %";
yAxisConfig.Title.Font.Size = 8;
timeAxisConfig.Font.Size = 8;
timeAxisConfig.Font.Color = "black";
timeAxisConfig.MajorTickMarks = c.chTickMarkAutomatic;
timeAxisConfig.HasTickLabels = true;
timeAxisConfig.TickLabelSpacing = 443;
timeAxisConfig.GroupingType = c.chAxisGroupingNone
categs = new Array();
var i = 0;
categs = "ultra1id";
i = i + 1;
categs = "ultra2id";
i = i + 1;
categs = "linuxp2id";
i = i + 1;
categs = "linuxdp3id";
i = i + 1;
categs = "hp712id";
i = i + 1;
categs = "ibm43pid";
i = i + 1;
// set the categories (series ;-)
ch.SetData( c.chDimSeriesNames, c.chDataLiteral, categs );
cellRange = "A2:A" + 8866;
ch.SeriesCollection(0).SetData( c.chDimCategories,
c.chDataBound, cellRange )
ch.SeriesCollection(0).SetData( c.chDimValues,
c.chDataBound,"B2:B8866");
ch.SeriesCollection(0).Interior.Color="White";
ch.SeriesCollection(0).Border.Color="White";
ch.SeriesCollection(1).SetData( c.chDimCategories,
c.chDataBound, cellRange )
ch.SeriesCollection(1).SetData( c.chDimValues, c.chDataBound,
"C2:C8866");
ch.SeriesCollection(2).SetData( c.chDimCategories,
c.chDataBound, cellRange )
ch.SeriesCollection(2).SetData( c.chDimValues, c.chDataBound,
"D28866");
ch.SeriesCollection(3).SetData( c.chDimCategories,
c.chDataBound, cellRange )
ch.SeriesCollection(3).SetData( c.chDimValues, c.chDataBound,
"E2:E8866");
ch.SeriesCollection(4).SetData( c.chDimCategories,
c.chDataBound, cellRange )
ch.SeriesCollection(4).SetData( c.chDimValues, c.chDataBound,
"F2:F8866");
ch.SeriesCollection(5).SetData( c.chDimCategories,
c.chDataBound, cellRange )
ch.SeriesCollection(5).SetData( c.chDimValues, c.chDataBound,
"G2:G8866");
// ----------------PERFORMANCE ISSUE #2 ------------ //
ch.SeriesCollection(0).Points(1).Interior.Color="Green";
....snip...
ch.SeriesCollection(0).Points(6805).Border.Color="DarkGreen";
ch.SeriesCollection(0).Points(6834).Interior.Color="Green";
ch.SeriesCollection(0).Points(6834).Border.Color="DarkGreen";
ch.SeriesCollection(1).Points(1).Interior.Color="Green";
....snip...
ch.SeriesCollection(1).Points(6834).Border.Color="DarkGreen";
ch.SeriesCollection(1).Points(6835).Interior.Color="Green";
ch.SeriesCollection(1).Points(6835).Border.Color="DarkGreen";
ch.SeriesCollection(2).Points(0).Interior.Color="Red";
....snip...
ch.SeriesCollection(2).Points(8306).Border.Color="DarkRed";
ch.SeriesCollection(2).Points(8307).Interior.Color="Red";
ch.SeriesCollection(2).Points(8307).Border.Color="DarkRed";
ch.SeriesCollection(3).Points(0).Interior.Color="Green";
....snip...
ch.SeriesCollection(3).Points(8306).Border.Color="DarkGreen";
ch.SeriesCollection(3).Points(8307).Interior.Color="Green";
ch.SeriesCollection(3).Points(8307).Border.Color="DarkGreen";
ch.SeriesCollection(4).Points(0).Interior.Color="Yellow";
....snip...
ch.SeriesCollection(4).Points(8306).Border.Color="DarkRed";
ch.SeriesCollection(4).Points(8307).Interior.Color="Red";
ch.SeriesCollection(4).Points(8307).Border.Color="DarkRed";
ch.SeriesCollection(5).Points(0).Interior.Color="Red";
....snip...
ch.SeriesCollection(5).Points(8278).Border.Color="DarkRed";
ch.SeriesCollection(5).Points(8306).Interior.Color="Red";
ch.SeriesCollection(5).Points(8306).Border.Color="DarkRed";
// set the style
objNew2.style.width = "98%";
objNew2.style.height = "98%";
// objNew2.Border.Weight = chConstants.owcLineWeightThick;
document.all.graphContainer.appendChild(objNew2);
document.all.chsp.attachEvent("CommandExecute", CmdExec);
document.all.chsp.attachEvent("BeforeContextMenu", CtxMenu);
return;
}
function init() {
var o = genSpreadSheet();
genGraph( o );
return;
}
</script>
</head>
<body onload="init()" link="#0000CC" alink="#0000CC" vlink="#0000CC">
<center>
<br/>
<div align="center">
<table id="graphView" border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#111111" width="100%"
height="100%">
<tr>
<td align="left" width="100%" height="3">
<p>
<br/>
<font class="basicText">
Graph for Query: <b>"Show graph of RAM
utilization "</b><br>
Zoom: 1
<a target="_top"
href="/itmc/basicAction.do?link=/itmc/resultAction.do&zoom=140&reuseSheet=true&key=2004-08-01
13:22:14.673Report">2</a>
<a target="_top"
href="/itmc/basicAction.do?link=/itmc/resultAction.do&zoom=180&reuseSheet=true&key=2004-08-01
13:22:14.673Report">3</a>
<a target="_top"
href="/itmc/basicAction.do?link=/itmc/resultAction.do&zoom=220&reuseSheet=true&key=2004-08-01
13:22:14.673Report">4</a>
</font>
<br/>
<br/>
</p>
</td>
</tr>
<tr>
<td align="center" id="graphContainer" width="100%" height=500">
</td>
</tr>
</table>
</div>
</center>
<table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" width="100%" height="2%">
<tr>
<td align="center" valign="top" width="100%" height="100%">
</td>
</tr>
</table>
</body>
</html>
I have a 3D Chart in OWC that is taking a long time to generate
because of the size of the data.
The chart has 6 series, each with about 8500+ data points in it. I've
attached the code below, with some lines snipped out so that's more
readable.
One possible performance issue I can think of is that I have to build
a 2 dimensional array in VB. This is array is about 6 by 8866
elements. (Incidentally, I've found that this step is significantly
faster in VB versus JScript. Has anyone else seen this?) This step
is labeled "PERFORMANCE PROBLEM #1".
The second area of the code I suspect a bottleneck is that I have to
individually set the interior and border color of each data point. I
have to do this because the data is individually color coded, and I
cannot use the "Range" function to set the color en mass. This is
labeled as "PERFORMANCE PROBLEM #2".
Can anyone recommend alternatives to these approaches that could speed
this code up? Or does anyone see other bad practices in my code that
are causing the slowness? I greatly appreciate any help on this.
Thank you very much, in advance.
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns="urn:schemas-microsoft-comfficeffice"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
</style>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<script language="VBScript">
Function createTimeAxis()
Dim timeAxis( 8866 , 0 )
timeAxis(0 , 0 ) = "Tue Jun 01 00:00:00 CDT 2004"
....snip...
timeAxis(8862 , 0 ) = "Sun Aug 01 13:00:00 CDT 2004"
timeAxis(8863 , 0 ) = "Sun Aug 01 13:10:00 CDT 2004"
timeAxis(8864 , 0 ) = "Sun Aug 01 13:20:00 CDT 2004"
createTimeAxis = timeAxis
End Function
// ----------------PERFORMANCE ISSUE #1 ------------ //
Function createSeries()
Dim seriesData( 8866 , 5 )
seriesData(0 , 0) = "0.0"
....snip...
seriesData(8863 , 0) = "0.0"
seriesData(8864 , 0) = "0.0"
seriesData(0 , 1) = "16.46"
....snip...
seriesData(8862 , 1) = "0.0"
seriesData(8863 , 1) = "0.0"
seriesData(8864 , 1) = "0.0"
seriesData(0 , 2) = "98.10001"
....snip...
seriesData(8862 , 2) = "0.0"
seriesData(8863 , 2) = "0.0"
seriesData(8864 , 2) = "0.0"
seriesData(0 , 3) = "66.0"
....snip...
seriesData(8862 , 3) = "0.0"
seriesData(8863 , 3) = "0.0"
seriesData(8864 , 3) = "0.0"
seriesData(0 , 4) = "79.02001"
....snip...
seriesData(8862 , 4) = "0.0"
seriesData(8863 , 4) = "0.0"
seriesData(8864 , 4) = "0.0"
seriesData(0 , 5) = "95.00501"
....snip...
seriesData(8862 , 5) = "0.0"
seriesData(8863 , 5) = "0.0"
seriesData(8864 , 5) = "0.0"
createSeries = seriesData
End Function
</script>
<script language="JScript">
function genSpreadSheet() {
objNew = document.createElement("OBJECT");
objNew.classid = "clsid:0002E551-0000-0000-C000-000000000046";
x objNew.id = "sp";
objNew.Visible = true;
// Get a new workbook.
var oWB = objNew.ActiveWorkbook;
var oSheet = oWB.ActiveSheet;
range = objNew.ActiveCell;
cellRange = "A2:A" + 8866;
range.Range( cellRange ).NumberFormat = "General";
range.Range( cellRange ).Font.Size = "8";
range.Range( cellRange ).Value = createTimeAxis();
cellRange = "B2:B4000";
cellRange = "B2:G8866";
range.Range( cellRange ).NumberFormat = "Standard";
range.Range( cellRange ).Font.Size = "8";
range.Range( cellRange ).Value = createSeries();
return objNew;
}
function genGraph( objNew ) {
objNew2 = document.createElement("OBJECT");
objNew2.classid = "clsid:0002E556-0000-0000-C000-000000000046";
objNew2.id = "chsp";
var c = objNew2.Constants;
//load some sample data
var ch = objNew2.Charts.Add();
objNew2.Charts(0).Type = c.chChartTypeColumn3D;
objNew2.Charts(0).ProjectionMode =
c.chProjectionModeOrthographic;
objNew2.Charts(0).AmbientLightIntensity = 0.75;
objNew2.Charts(0).DirectionalLightInclination = 60;
objNew2.Charts(0).DirectionalLightIntensity = 1.0;
objNew2.Charts(0).DirectionalLightRotation = 90;
objNew2.DisplayToolbar= false;
objNew2.DisplayPropertyToolbox = false;
objNew2.DataSource = objNew;
objNew2.HasPlotDetails = false;
var timeAxisConfig =
objNew2.Charts(0).Axes(c.chAxisPositionTimescale);
var yAxisConfig = objNew2.Charts(0).Axes(1);
yAxisConfig.HasTitle = true;
yAxisConfig.Title.Caption = "RAM utilization %";
yAxisConfig.Title.Font.Size = 8;
timeAxisConfig.Font.Size = 8;
timeAxisConfig.Font.Color = "black";
timeAxisConfig.MajorTickMarks = c.chTickMarkAutomatic;
timeAxisConfig.HasTickLabels = true;
timeAxisConfig.TickLabelSpacing = 443;
timeAxisConfig.GroupingType = c.chAxisGroupingNone
categs = new Array();
var i = 0;
categs = "ultra1id";
i = i + 1;
categs = "ultra2id";
i = i + 1;
categs = "linuxp2id";
i = i + 1;
categs = "linuxdp3id";
i = i + 1;
categs = "hp712id";
i = i + 1;
categs = "ibm43pid";
i = i + 1;
// set the categories (series ;-)
ch.SetData( c.chDimSeriesNames, c.chDataLiteral, categs );
cellRange = "A2:A" + 8866;
ch.SeriesCollection(0).SetData( c.chDimCategories,
c.chDataBound, cellRange )
ch.SeriesCollection(0).SetData( c.chDimValues,
c.chDataBound,"B2:B8866");
ch.SeriesCollection(0).Interior.Color="White";
ch.SeriesCollection(0).Border.Color="White";
ch.SeriesCollection(1).SetData( c.chDimCategories,
c.chDataBound, cellRange )
ch.SeriesCollection(1).SetData( c.chDimValues, c.chDataBound,
"C2:C8866");
ch.SeriesCollection(2).SetData( c.chDimCategories,
c.chDataBound, cellRange )
ch.SeriesCollection(2).SetData( c.chDimValues, c.chDataBound,
"D28866");
ch.SeriesCollection(3).SetData( c.chDimCategories,
c.chDataBound, cellRange )
ch.SeriesCollection(3).SetData( c.chDimValues, c.chDataBound,
"E2:E8866");
ch.SeriesCollection(4).SetData( c.chDimCategories,
c.chDataBound, cellRange )
ch.SeriesCollection(4).SetData( c.chDimValues, c.chDataBound,
"F2:F8866");
ch.SeriesCollection(5).SetData( c.chDimCategories,
c.chDataBound, cellRange )
ch.SeriesCollection(5).SetData( c.chDimValues, c.chDataBound,
"G2:G8866");
// ----------------PERFORMANCE ISSUE #2 ------------ //
ch.SeriesCollection(0).Points(1).Interior.Color="Green";
....snip...
ch.SeriesCollection(0).Points(6805).Border.Color="DarkGreen";
ch.SeriesCollection(0).Points(6834).Interior.Color="Green";
ch.SeriesCollection(0).Points(6834).Border.Color="DarkGreen";
ch.SeriesCollection(1).Points(1).Interior.Color="Green";
....snip...
ch.SeriesCollection(1).Points(6834).Border.Color="DarkGreen";
ch.SeriesCollection(1).Points(6835).Interior.Color="Green";
ch.SeriesCollection(1).Points(6835).Border.Color="DarkGreen";
ch.SeriesCollection(2).Points(0).Interior.Color="Red";
....snip...
ch.SeriesCollection(2).Points(8306).Border.Color="DarkRed";
ch.SeriesCollection(2).Points(8307).Interior.Color="Red";
ch.SeriesCollection(2).Points(8307).Border.Color="DarkRed";
ch.SeriesCollection(3).Points(0).Interior.Color="Green";
....snip...
ch.SeriesCollection(3).Points(8306).Border.Color="DarkGreen";
ch.SeriesCollection(3).Points(8307).Interior.Color="Green";
ch.SeriesCollection(3).Points(8307).Border.Color="DarkGreen";
ch.SeriesCollection(4).Points(0).Interior.Color="Yellow";
....snip...
ch.SeriesCollection(4).Points(8306).Border.Color="DarkRed";
ch.SeriesCollection(4).Points(8307).Interior.Color="Red";
ch.SeriesCollection(4).Points(8307).Border.Color="DarkRed";
ch.SeriesCollection(5).Points(0).Interior.Color="Red";
....snip...
ch.SeriesCollection(5).Points(8278).Border.Color="DarkRed";
ch.SeriesCollection(5).Points(8306).Interior.Color="Red";
ch.SeriesCollection(5).Points(8306).Border.Color="DarkRed";
// set the style
objNew2.style.width = "98%";
objNew2.style.height = "98%";
// objNew2.Border.Weight = chConstants.owcLineWeightThick;
document.all.graphContainer.appendChild(objNew2);
document.all.chsp.attachEvent("CommandExecute", CmdExec);
document.all.chsp.attachEvent("BeforeContextMenu", CtxMenu);
return;
}
function init() {
var o = genSpreadSheet();
genGraph( o );
return;
}
</script>
</head>
<body onload="init()" link="#0000CC" alink="#0000CC" vlink="#0000CC">
<center>
<br/>
<div align="center">
<table id="graphView" border="1" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" bordercolor="#111111" width="100%"
height="100%">
<tr>
<td align="left" width="100%" height="3">
<p>
<br/>
<font class="basicText">
Graph for Query: <b>"Show graph of RAM
utilization "</b><br>
Zoom: 1
<a target="_top"
href="/itmc/basicAction.do?link=/itmc/resultAction.do&zoom=140&reuseSheet=true&key=2004-08-01
13:22:14.673Report">2</a>
<a target="_top"
href="/itmc/basicAction.do?link=/itmc/resultAction.do&zoom=180&reuseSheet=true&key=2004-08-01
13:22:14.673Report">3</a>
<a target="_top"
href="/itmc/basicAction.do?link=/itmc/resultAction.do&zoom=220&reuseSheet=true&key=2004-08-01
13:22:14.673Report">4</a>
</font>
<br/>
<br/>
</p>
</td>
</tr>
<tr>
<td align="center" id="graphContainer" width="100%" height=500">
</td>
</tr>
</table>
</div>
</center>
<table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" width="100%" height="2%">
<tr>
<td align="center" valign="top" width="100%" height="100%">
</td>
</tr>
</table>
</body>
</html>