using mschart
using mschart
dlls
copy /y mschrt20.ocx C:\WINDOWS\system32\mschrt20.ocx
regsvr32 mschrt20.ocx
regs:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Licenses\12B142A4-BD51-11d1-8C08-0000F8754DA1]
@="aadhgafabafajhchnbchehfambfbbachmfmb"
HKEY_CLASSES_ROOT\Licenses = Licensing: Copying the keys may be a violation of established copyrights.
// MSCHART license key
HKEY_CLASSES_ROOT\Licenses\7C35CA30-D112-11cf-8E72-00A0C90F26F8 = whmhmhohmhiorhkouimhihihwiwinhlosmsl
http://blogs.msdn.com/b/askie/archive/2009/02/20/certain-vb-controls-no-longer-display-on-web-pages-after-installing-kb960715.aspx
Just to give some background information, when a control is kill-bitted, the value of the Compatibility Flags DWORD under the following registry hive gets set to 0x00000400. if set to 0x2020, then Ok
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\<CLSID of the ActiveX control>
examples:
<html>
<head>
<title>Pareto Chart of Lot Defect</title>
<HTA:APPLICATION ID="oLotDefectParetoChart" APPLICATIONNAME="LotDefectParetoChart" SHOWINTASKBAR="yes"/>
<script type="text/javascript">
//*********************Global constants**************************
// For file operation.
var FOR_READ = 1;
var FOR_WRITE = 2;
//***************************************************************
//*********************Global variables**************************
var g_aoLotFileData = new Array();
var g_nLotCount = 0;
var g_aoLotDefectData = new Array();
//***************************************************************
//*********************General functions*************************
function normalizeString(str)
{
str = str.replace(/^\s+/, "");
str = str.replace(/\s+$/, "");
return str;
}
function isUnsignedInteger(input)
{
return (input.toString().search(/^[0-9]+$/) == 0);
}
//***************************************************************
//*********************Data structures***************************
function FileData(path, dateLastModified, parentFolderName)
{
this.path = path;
this.dateLastModified = dateLastModified;
this.parentFolderName = parentFolderName;
}
function DefectData(defect, module, count)
{
this.defect = defect;
this.module = module;
this.count = count;
}
function ParetoChartData(x, yColumn, yLine)
{
this.x = x;
this.yColumn = yColumn;
this.yLine = yLine;
}
//***************************************************************
//*******************Pareto Chart functions**********************
function pushFileData(sLotDataDir, sDefectCountFileName, aoFileData)
{
var oFileSys = new ActiveXObject("Scripting.FileSystemObject");
if (!oFileSys.FolderExists(sLotDataDir))
{
alert(sLotDataDir + " does not exist.");
return false;
}
var oFolder = oFileSys.GetFolder(sLotDataDir);
var oSubFolderPointer = new Enumerator(oFolder.SubFolders);
for (; !oSubFolderPointer.atEnd(); oSubFolderPointer.moveNext())
{
var sSubFolderPath = oSubFolderPointer.item().Path.toString();
var sXMLFilePath = sSubFolderPath + "\\" + sDefectCountFileName;
if (oFileSys.FileExists(sXMLFilePath))
{
aoFileData.push(new FileData(sXMLFilePath, oFileSys.GetFile(sXMLFilePath).DateLastModified, oSubFolderPointer.item().Name.toString()));
}
}
aoFileData.sort(function(a, b){return b.dateLastModified - a.dateLastModified;});
return true;
}
function coreExtractLotDefectData(oFileData, aoLotDefectData)
{
var oXMLDoc = new ActiveXObject("MSXML2.DOMDocument.4.0");
oXMLDoc.async = false;
oXMLDoc.load(oFileData.path);
var aoItemNodes = oXMLDoc.selectNodes("/SESSION/ITEM[count(FDNAME)=1]");
var sLotID = oFileData.parentFolderName;
var sDefect = "";
var sModule = "";
var nCount = 0;
for (var i = 0; i < aoItemNodes.length; i++)
{
var sFDName = aoItemNodes[i].selectNodes("FDNAME")[0].text;
if (sFDName.slice(0, 3) == "---")
{
sModule = sFDName.replace(/---/g, "");
}
else
{
sDefect = sFDName;
nCount = parseInt(aoItemNodes[i].selectNodes("FDALLDEFCONTENT")[0].text);
if (aoLotDefectData[sLotID] == null)
{
aoLotDefectData[sLotID] = new Array();
}
aoLotDefectData[sLotID].push(new DefectData(sDefect, sModule, nCount));
}
}
}
function extractLotDefectData(sLotDataDir, sDefectCountFileName, nNumOfLots, aoLotDefectData)
{
var oFileSys = new ActiveXObject("Scripting.FileSystemObject");
var aoFileData = new Array();
if (!pushFileData(sLotDataDir, sDefectCountFileName, aoFileData))
return false;
if (nNumOfLots > aoFileData.length)
nNumOfLots = aoFileData.length;
for (var i = 0; i < nNumOfLots; ++i)
{
coreExtractLotDefectData(aoFileData[i], aoLotDefectData);
g_aoLotFileData[aoFileData[i].parentFolderName] = aoFileData[i];
}
for (var key in g_aoLotFileData)
++g_nLotCount;
return true;
}
function computeTotalNumOfDefects(aoParetoChartData)
{
var nTotalNumOfDefects = 0;
for (var i = 0; i < aoParetoChartData.length; ++i)
{
nTotalNumOfDefects += aoParetoChartData[i].yColumn;
}
return nTotalNumOfDefects;
}
function computeYLine(aoParetoChartData)
{
var nTotalNumOfDefects = computeTotalNumOfDefects(aoParetoChartData);
// No need to compute yLine if total number of defects is 0.
if (nTotalNumOfDefects == 0)
return;
aoParetoChartData[0].yLine = aoParetoChartData[0].yColumn / nTotalNumOfDefects * 100;
for (var i = 1; i < aoParetoChartData.length; ++i)
{
aoParetoChartData[i].yLine = aoParetoChartData[i].yColumn / nTotalNumOfDefects * 100;
aoParetoChartData[i].yLine += aoParetoChartData[i-1].yLine;
}
}
function computeParetoChartData(aoLotDefectData, aoParetoChartData)
{
var oIt = new Enumerator(aoLotDefectData);
var aoDefectData = oIt.item();
// There is no lot at all.
if (aoDefectData == null)
{
alert("No lot is found or selected.");
return false;
}
for (var i = 0; i < aoDefectData.length; ++i)
{
aoParetoChartData.push(new ParetoChartData(aoDefectData[i].defect, aoDefectData[i].count, 0));
}
oIt.moveNext();
for (; !oIt.atEnd(); oIt.moveNext())
{
aoDefectData = oIt.item();
for (var i = 0; i < aoDefectData.length; ++i)
{
var bIsFound = false;
for (var j = 0; j < aoParetoChartData.length; ++j)
{
if (aoParetoChartData[j].x.toLowerCase() == aoDefectData[i].defect.toLowerCase())
{
aoParetoChartData[j].yColumn += aoDefectData[i].count;
bIsFound = true;
break;
}
}
// New entry.
if (!bIsFound)
{
aoParetoChartData.push(new ParetoChartData(aoDefectData[i].defect, aoDefectData[i].count, 0));
}
}
}
aoParetoChartData.sort(function(a, b){return b.yColumn - a.yColumn;});
var nSpliceIndex = 0;
for (var i = 0; i < aoParetoChartData.length; ++i)
{
nSpliceIndex = i;
if (aoParetoChartData[i].yColumn == 0)
break;
}
aoParetoChartData.splice(nSpliceIndex, aoParetoChartData.length - nSpliceIndex);
computeYLine(aoParetoChartData);
return true;
}
function plotPartoChart(aoParetoChartData)
{
var oChart = document.getElementById("MSChart1");
oChart.style.visibility = "hidden";
if (aoParetoChartData.length == 0)
{
alert("Total number of defects is zero.");
return;
}
oChart.chartType = 9;
//oChart.Title.Text = "Pareto Chart of Lot Defect";
oChart.Legend.Location.LocationType = 1;
oChart.ShowLegend = true;
oChart.ColumnCount = 2;
oChart.RowCount = aoParetoChartData.length;
for (var i = 0; i < aoParetoChartData.length; ++i)
{
oChart.DataGrid.RowLabel(i + 1, 1) = aoParetoChartData[i].x;
oChart.DataGrid.SetData(i + 1, 1, aoParetoChartData[i].yColumn, 0);
oChart.DataGrid.SetData(i + 1, 2, aoParetoChartData[i].yLine, 0);
}
oChart.Plot.xGap = 0.1;
oChart.Plot.SeriesCollection(1).SeriesType = 1;
oChart.Plot.SeriesCollection(1).LegendText = "Defect Frequency";
oChart.Plot.SeriesCollection(1).DataPoints(-1).Brush.FillColor.Set(0, 0, 255);
oChart.Plot.SeriesCollection(1).SecondaryAxis = false;
oChart.Plot.SeriesCollection(1).DataPoints(-1).DataPointLabel.LocationType = 3;
oChart.Plot.SeriesCollection(1).DataPoints(-1).DataPointLabel.VtFont.VtColor.Set(255, 255, 0);
oChart.Plot.SeriesCollection(2).SeriesType = 6;
oChart.Plot.SeriesCollection(2).LegendText = "Cumulative Percentage";
oChart.Plot.SeriesCollection(2).DataPoints(-1).Brush.FillColor.Set(255, 0, 0);
oChart.Plot.SeriesCollection(2).SeriesMarker.Auto = false;
oChart.Plot.SeriesCollection(2).SeriesMarker.Show = true;
oChart.Plot.SeriesCollection(2).DataPoints(-1).Marker.Size = 50;
oChart.Plot.SeriesCollection(2).DataPoints(-1).Marker.Style = 6;
oChart.Plot.SeriesCollection(2).DataPoints(-1).Marker.Pen.VtColor.Set(255, 0, 0);
oChart.Plot.SeriesCollection(2).DataPoints(-1).Marker.Visible = true;
oChart.Plot.SeriesCollection(2).SecondaryAxis = true;
oChart.Plot.SeriesCollection(2).Pen.Width = 2;
oChart.Plot.Axis(0).AxisTitle.Text = "Defect";
oChart.Plot.Axis(0).AxisGrid.MajorPen.Style = 0;
oChart.Plot.Axis(1).AxisTitle.Text = "Defect Frequency";
oChart.Plot.Axis(1).AxisGrid.MajorPen.Style = 3;
oChart.Plot.Axis(1).ValueScale.Auto = false;
oChart.Plot.Axis(1).ValueScale.Maximum = aoParetoChartData[0].yColumn / aoParetoChartData[0].yLine * 100;
oChart.Plot.Axis(1).ValueScale.Minimum = 0;
oChart.Plot.Axis(1).ValueScale.MajorDivision = 10;
oChart.Plot.Axis(2).AxisTitle.Text = "Cumulative Percentage";
oChart.Plot.Axis(2).AxisGrid.MajorPen.Style = 3;
oChart.Plot.Axis(2).ValueScale.Auto = false;
oChart.Plot.Axis(2).ValueScale.Maximum = 100;
oChart.Plot.Axis(2).ValueScale.Minimum = 0;
oChart.Plot.Axis(2).ValueScale.MajorDivision = 10;
oChart.style.visibility = "visible";
}
function refreshParetoChart()
{
var oChart = document.getElementById("MSChart1");
oChart.style.visibility = "hidden";
var aoLotDefectData = new Array();
var aoParetoChartData = new Array();
for (var key in g_aoLotDefectData)
{
if (document.getElementById(key + "CheckBox").checked)
{
aoLotDefectData[key] = g_aoLotDefectData[key];
}
}
if (computeParetoChartData(aoLotDefectData, aoParetoChartData))
plotPartoChart(aoParetoChartData);
}
function selectAllLots()
{
for (var key in g_aoLotDefectData)
{
document.getElementById(key + "CheckBox").checked = true;
}
}
function unSelectAllLots()
{
for (var key in g_aoLotDefectData)
{
document.getElementById(key + "CheckBox").checked = false;
}
}
function appendControlButtons()
{
var oDiv = document.getElementById("lotSelectionArea");
var oInput = document.createElement("Input");
// Refresh button
var oInputCell = oInput.cloneNode(false);
oInputCell.type = "button";
oInputCell.value = "Refresh Chart";
oInputCell.onclick = refreshParetoChart;
oInputCell.width = "150";
oDiv.appendChild(oInputCell);
// Select All button
var oInputCell = oInput.cloneNode(false);
oInputCell.type = "button";
oInputCell.value = "Select All Lots";
oInputCell.onclick = selectAllLots;
oInputCell.width = "150";
oDiv.appendChild(oInputCell);
// Unselect All button
var oInputCell = oInput.cloneNode(false);
oInputCell.type = "button";
oInputCell.value = "Unselect All Lots";
oInputCell.onclick = unSelectAllLots;
oInputCell.width = "150";
oDiv.appendChild(oInputCell);
}
function appendLotInfoTable(aoLotDefectData, nDataStart, nDataEnd, oTable)
{
var oThead = document.createElement("THead");
var oTbody = document.createElement("TBody");
var oTd = document.createElement("TD");
var oTr = document.createElement("TR");
var oTh = document.createElement("TH");
var oInput = document.createElement("Input");
// thead
var oRow = oTr.cloneNode(false);
var oCell = oTh.cloneNode(false);
oCell.appendChild(document.createTextNode("Select"));
oRow.appendChild(oCell);
var oCell = oTh.cloneNode(false);
oCell.appendChild(document.createTextNode("Lot ID"));
oRow.appendChild(oCell);
var oCell = oTh.cloneNode(false);
oCell.appendChild(document.createTextNode("Date Modified"));
oRow.appendChild(oCell);
oThead.appendChild(oRow);
// tbody
var nIndex = 0;
for (var key in aoLotDefectData)
{
if (nIndex < nDataStart)
{
++nIndex;
continue;
}
else if (nIndex > nDataEnd)
break;
var oRow = oTr.cloneNode(false);
var oInputCell = oInput.cloneNode(false);
oInputCell.type = "checkbox";
oInputCell.defaultChecked = true;
oInputCell.id = key + "CheckBox";
oInputCell.height = "10";
var oCell = oTd.cloneNode(false);
oCell.appendChild(oInputCell);
oRow.appendChild(oCell);
var oCell = oTd.cloneNode(false);
oCell.appendChild(document.createTextNode(key));
oRow.appendChild(oCell);
var oCell = oTd.cloneNode(false);
var dDate = new Date(g_aoLotFileData[key].dateLastModified);
oCell.appendChild(document.createTextNode(dDate.toLocaleString().replace(/^.*day, /, "")));
oRow.appendChild(oCell);
oTbody.appendChild(oRow);
++nIndex;
}
// table
oTable.appendChild(oThead);
oTable.appendChild(oTbody);
}
function appendLotInfoTableEx(aoLotDefectData)
{
var oDiv = document.getElementById("lotSelectionArea");
var oTable = document.createElement("Table");
var oTbody = document.createElement("TBody");
var oTd = document.createElement("TD");
var oTr = document.createElement("TR");
var nDataStart = 0;
var nDataEnd = g_nLotCount - 1;
if (g_nLotCount > 20)
{
var oTableLeft = oTable.cloneNode(false);
nDataEnd = Math.ceil(g_nLotCount / 2) - 1;
appendLotInfoTable(aoLotDefectData, nDataStart, nDataEnd, oTableLeft);
var oTableRight = oTable.cloneNode(false);
nDataStart = nDataEnd + 1;
nDataEnd = g_nLotCount - 1;
appendLotInfoTable(aoLotDefectData, nDataStart, nDataEnd, oTableRight);
var oRow = oTr.cloneNode(false);
var oCell = oTd.cloneNode(false);
oCell.appendChild(oTableLeft);
oRow.appendChild(oCell);
var oCell = oTd.cloneNode(false);
oCell.appendChild(oTableRight);
oRow.appendChild(oCell);
oTbody.appendChild(oRow);
oTable.appendChild(oTbody);
}
else
{
appendLotInfoTable(aoLotDefectData, nDataStart, nDataEnd, oTable);
}
oDiv.appendChild(oTable);
}
function fillLotSelectionAreaContent(aoLotDefectData)
{
appendControlButtons();
appendLotInfoTableEx(aoLotDefectData);
}
function main()
{
var oChart = document.getElementById("MSChart1");
if (!oChart.Plot)
{
alert("Please install MSChart first.");
return;
}
// Format of command line:
// mshta.exe "[Position of LotDataParetoChart.hta]" "[Directory of Lot Data]" "[Name of Data File (in XML)]" "[Number of Lots]".
var asArguments = oLotDefectParetoChart.commandLine.split("\"");
var sLotDataDir = (asArguments[3] != null) ? asArguments[3] : null;
var sDefectCountFileName = (asArguments[5] != null) ? asArguments[5] : null;
var nNumOfLots = (asArguments[7] != null) ? asArguments[7] : 30;
if (sLotDataDir == null || sDefectCountFileName == null)
{
alert("Invalid arguments!");
return;
}
if (!extractLotDefectData(sLotDataDir, sDefectCountFileName, nNumOfLots, g_aoLotDefectData))
{
return;
}
// From now on, g_aoLotFileData, g_nLotCount and g_aoLotDefectData are read-only.
var aoParetoChartData = new Array();
if (computeParetoChartData(g_aoLotDefectData, aoParetoChartData))
{
plotPartoChart(aoParetoChartData);
fillLotSelectionAreaContent(g_aoLotDefectData);
}
}
//***************************************************************
</script>
<style type="text/css">
table {
font: Icon;
border: 1px Solid ThreeDShadow;
background: Window;
color: WindowText;
background-color: WhiteSmoke;
margin-left: 3px;
}
thead {
background: ButtonFace;
}
td {
padding: 1px 5px 1px 5px;
font-size: 11px;
border-left: 1px solid silver;
border-bottom: 1px solid silver;
text-align: center;
color: black;
}
.sort-arrow {
width: 0px;
height: 0px;
background-position: center center;
}
.sort-arrow.descending {
width: 8px;
height: 8px;
background-image: url("C:/WinEagle/System/Report/InspectionReport/Result_files/images/downsimple.png");
}
.sort-arrow.ascending {
width: 8px;
height: 8px;
background-image: url("C:/WinEagle/System/Report/InspectionReport/Result_files/images/upsimple.png");
}
body {
font-family: Verdana, Helvetica, Arial, Sans-Serif;
font: Message-Box;
}
a {
color: Olive;
font-size: 12px;
cursor: hand;
}
a:link {color: #FF0000}
a:visited {color: #00FF00}
a:hover {color: #FF00FF}
a:active {color: #0000FF}
button {
width: 100%;
}
.MSChart {
HEIGHT: 52%;
WIDTH: 100%;
position: fixed;
top: 0px;
right: 0px ;
background-color: #B7B7B7;
}
</style>
</head>
<body id="content">
<OBJECT class="MSChart" classid="clsid:3A2B370C-BA0A-11D1-B137-0000F8753F5D" id="MSChart1" CODEBASE="mschart.cab" VIEWASTEXT></OBJECT>
<div id="lotSelectionArea" />
</body>
</html>