SlideShare a Scribd company logo
1 of 4
Simple Kaplan-Meier chart in plain
JavaScript and HTML
SharonXiaoLiu. 2017/10/31.
<!DOCTYPE html>
<html>
<head>
<title>PlainJavaScriptKaplan-Meierchart</title>
</head>
<body>
<!-- Use of librarypart.
-->
<script>
var kaplanMeierData={
"treated":{
"xMonths":[0,50, 100, 150, 200, 250, 300, 350, 400, 450, 500],
"yPeople":[0,50, 100, 150, 200, 250, 300, 350, 400, 450, 500]
},
"treatedCensorMarks":{
"xMonths":[45, 245],
"yPeople":[50,250]
},
"untreated":{
"xMonths":[0,25, 50, 75, 100, 125, 150, 175, 200, 225, 250],
"yPeople":[0,50, 100, 150, 200, 250, 300, 350, 400, 450, 500]
}
};
</script>
<!-- Library part.
-->
<p>Kaplan-Meierchart,withblackastreated, blue asuntreated,x-axismonthsandy-axis
people.</p>
<p>There is a censormark if deathdoesnot occur. Stepsare whendeathoccurs.</p>
<svg height="500" width="500"id="kaplanMeierSvg">
<line x1="0" y1="500" x2="500" y2="500" style="stroke:rgb(0,0,0);stroke-width:2"
id="xAxis"/>
<line x1="0" y1="0" x2="0" y2="500" style="stroke:rgb(0,0,0);stroke-width:2"id="yAxis"/>
<polyline id="treated_steps_svg"/>
<polyline id="nonTreatedStepsSvg"/>
</svg>
<script>
window.onload=function(){
var getKaplanMeierSvg=document.getElementById('kaplanMeierSvg');
var kaplanMeierSvgHeight=kaplanMeierData.treated.yPeople[10];
var kaplanMeierSvgWidthTreated=kaplanMeierData.treated.xMonths[10];
var kaplanMeierSvgWidthUntreated=kaplanMeierData.untreated.xMonths[10];
if (kaplanMeierSvgWidthTreated>=kaplanMeierSvgWidthUntreated) {
var kaplanMeierSvgWidth=kaplanMeierSvgWidthTreated;
} else {
var kaplanMeierSvgWidth=kaplanMeierSvgWidthUntreated;
}
var getXAxis=document.getElementById('xAxis');
//The heightandwidthof the graph are determinedbythe data.
getXAxis.setAttribute("x2",kaplanMeierSvgWidth);
getXAxis.setAttribute("y1",kaplanMeierSvgHeight);
getXAxis.setAttribute("y2",kaplanMeierSvgHeight);
var getYAxis=document.getElementById('yAxis');
getYAxis.setAttribute("y2",kaplanMeierSvgHeight);
//Above all working.
var treatedSteps="";
for (vari = 0; i < kaplanMeierData.treated.xMonths.length;i++) {
treatedSteps+=kaplanMeierData.treated.xMonths[i] +","+
kaplanMeierData.treated.yPeople[i] +" ";
if (i != kaplanMeierData.treated.xMonths.length-1){
treatedSteps+=kaplanMeierData.treated.xMonths[i] +"," +
kaplanMeierData.treated.yPeople[i+1] + " ";
}
}
get_treated_steps_svg=document.getElementById('treated_steps_svg');
get_treated_steps_svg.setAttribute("points",treatedSteps);
get_treated_steps_svg.setAttribute("style","fill:none;stroke:black;stroke-width:1");
//0,0 0,50 50,50 50,100 100,100
var untreatedSteps="";
for (varj = 0; j < kaplanMeierData.untreated.xMonths.length;j++) {
untreatedSteps+=kaplanMeierData.untreated.xMonths[j] +","+
kaplanMeierData.untreated.yPeople[j] +" ";
if (j != kaplanMeierData.untreated.xMonths.length-1){
untreatedSteps+=kaplanMeierData.untreated.xMonths[j] +"," +
kaplanMeierData.untreated.yPeople[j+1] +" ";
}
}
document.getElementById("nonTreatedStepsSvg").setAttribute("points",untreatedSteps);
document.getElementById("nonTreatedStepsSvg").setAttribute("style",
"fill:none;stroke:blue;stroke-width:1");
//(0,0) 0,50 (25,50) 25,100 (50,100)
var censorMarksLength= kaplanMeierData.treatedCensorMarks.xMonths.length;
var censorMarks= "";
for (vari = 0; i<censorMarksLength;i++) {
censorMarks += "<line x1="";
var verticalCensorMarkX =kaplanMeierData.treatedCensorMarks.xMonths[i];
censorMarks+= verticalCensorMarkX;
censorMarks+= "" y1="";
var verticalCensorMarkYStart=kaplanMeierData.treatedCensorMarks.yPeople[i]-10;
censorMarks+= verticalCensorMarkYStart;
censorMarks+= "" x2="";
censorMarks+= verticalCensorMarkX;
censorMarks+= "" y2="";
var verticalCensorMarkYFinish=kaplanMeierData.treatedCensorMarks.yPeople[i]+10;
censorMarks+= verticalCensorMarkYFinish;
censorMarks+= "" style="stroke:black;stroke-width:2;"/>";
}
//Appendthe censormarkstogetKaplanMeierSvg.
getKaplanMeierSvg.innerHTML+= censorMarks;
};
</script>
</body>
</html>

More Related Content

More from Sharon Liu

20231102 Plan for Ice Skating.docx
20231102 Plan for Ice Skating.docx20231102 Plan for Ice Skating.docx
20231102 Plan for Ice Skating.docxSharon Liu
 
20231017 xy view of Rotated 45 degrees down and 45 left Sphere.docx
20231017 xy view of Rotated 45 degrees down and 45 left Sphere.docx20231017 xy view of Rotated 45 degrees down and 45 left Sphere.docx
20231017 xy view of Rotated 45 degrees down and 45 left Sphere.docxSharon Liu
 
20231006 Sphere rotated 45 degrees down.docx
20231006 Sphere rotated 45 degrees down.docx20231006 Sphere rotated 45 degrees down.docx
20231006 Sphere rotated 45 degrees down.docxSharon Liu
 
20230904 Recycling Clay.docx
20230904 Recycling Clay.docx20230904 Recycling Clay.docx
20230904 Recycling Clay.docxSharon Liu
 
20230831 a of the equator - Rotated sphere.docx
20230831 a of the equator - Rotated sphere.docx20230831 a of the equator - Rotated sphere.docx
20230831 a of the equator - Rotated sphere.docxSharon Liu
 
20230829 Rotated Ellipse.docx
20230829 Rotated Ellipse.docx20230829 Rotated Ellipse.docx
20230829 Rotated Ellipse.docxSharon Liu
 
20230819 Recall Tests.pptx
20230819 Recall Tests.pptx20230819 Recall Tests.pptx
20230819 Recall Tests.pptxSharon Liu
 
20230810 Radial Plot of an Ellipse.docx
20230810 Radial Plot of an Ellipse.docx20230810 Radial Plot of an Ellipse.docx
20230810 Radial Plot of an Ellipse.docxSharon Liu
 
20230809 South Pole of the Rotated Sphere.docx
20230809 South Pole of the Rotated Sphere.docx20230809 South Pole of the Rotated Sphere.docx
20230809 South Pole of the Rotated Sphere.docxSharon Liu
 
20230804 Rotated Sphere with new North Pole.docx
20230804 Rotated Sphere with new North Pole.docx20230804 Rotated Sphere with new North Pole.docx
20230804 Rotated Sphere with new North Pole.docxSharon Liu
 
20230802 Horizontal Sphere.docx
20230802 Horizontal Sphere.docx20230802 Horizontal Sphere.docx
20230802 Horizontal Sphere.docxSharon Liu
 
20230727 Upright Sphere from North Pole.docx
20230727 Upright Sphere from North Pole.docx20230727 Upright Sphere from North Pole.docx
20230727 Upright Sphere from North Pole.docxSharon Liu
 
20230724 3D Off Centre Line.docx
20230724 3D Off Centre Line.docx20230724 3D Off Centre Line.docx
20230724 3D Off Centre Line.docxSharon Liu
 
20230710 Skewed Ellipse.docx
20230710 Skewed Ellipse.docx20230710 Skewed Ellipse.docx
20230710 Skewed Ellipse.docxSharon Liu
 
20230704 Torus Polar Plots.docx
20230704 Torus Polar Plots.docx20230704 Torus Polar Plots.docx
20230704 Torus Polar Plots.docxSharon Liu
 
20230623 Torus Tangent Typeup.docx
20230623 Torus Tangent Typeup.docx20230623 Torus Tangent Typeup.docx
20230623 Torus Tangent Typeup.docxSharon Liu
 
20230613 ACMJ Diagrams.docx
20230613 ACMJ Diagrams.docx20230613 ACMJ Diagrams.docx
20230613 ACMJ Diagrams.docxSharon Liu
 
20230512 Torus Equations.docx
20230512 Torus Equations.docx20230512 Torus Equations.docx
20230512 Torus Equations.docxSharon Liu
 
20230503 Talking Constantly.pptx
20230503 Talking Constantly.pptx20230503 Talking Constantly.pptx
20230503 Talking Constantly.pptxSharon Liu
 
20230418 Melting Steel.docx
20230418 Melting Steel.docx20230418 Melting Steel.docx
20230418 Melting Steel.docxSharon Liu
 

More from Sharon Liu (20)

20231102 Plan for Ice Skating.docx
20231102 Plan for Ice Skating.docx20231102 Plan for Ice Skating.docx
20231102 Plan for Ice Skating.docx
 
20231017 xy view of Rotated 45 degrees down and 45 left Sphere.docx
20231017 xy view of Rotated 45 degrees down and 45 left Sphere.docx20231017 xy view of Rotated 45 degrees down and 45 left Sphere.docx
20231017 xy view of Rotated 45 degrees down and 45 left Sphere.docx
 
20231006 Sphere rotated 45 degrees down.docx
20231006 Sphere rotated 45 degrees down.docx20231006 Sphere rotated 45 degrees down.docx
20231006 Sphere rotated 45 degrees down.docx
 
20230904 Recycling Clay.docx
20230904 Recycling Clay.docx20230904 Recycling Clay.docx
20230904 Recycling Clay.docx
 
20230831 a of the equator - Rotated sphere.docx
20230831 a of the equator - Rotated sphere.docx20230831 a of the equator - Rotated sphere.docx
20230831 a of the equator - Rotated sphere.docx
 
20230829 Rotated Ellipse.docx
20230829 Rotated Ellipse.docx20230829 Rotated Ellipse.docx
20230829 Rotated Ellipse.docx
 
20230819 Recall Tests.pptx
20230819 Recall Tests.pptx20230819 Recall Tests.pptx
20230819 Recall Tests.pptx
 
20230810 Radial Plot of an Ellipse.docx
20230810 Radial Plot of an Ellipse.docx20230810 Radial Plot of an Ellipse.docx
20230810 Radial Plot of an Ellipse.docx
 
20230809 South Pole of the Rotated Sphere.docx
20230809 South Pole of the Rotated Sphere.docx20230809 South Pole of the Rotated Sphere.docx
20230809 South Pole of the Rotated Sphere.docx
 
20230804 Rotated Sphere with new North Pole.docx
20230804 Rotated Sphere with new North Pole.docx20230804 Rotated Sphere with new North Pole.docx
20230804 Rotated Sphere with new North Pole.docx
 
20230802 Horizontal Sphere.docx
20230802 Horizontal Sphere.docx20230802 Horizontal Sphere.docx
20230802 Horizontal Sphere.docx
 
20230727 Upright Sphere from North Pole.docx
20230727 Upright Sphere from North Pole.docx20230727 Upright Sphere from North Pole.docx
20230727 Upright Sphere from North Pole.docx
 
20230724 3D Off Centre Line.docx
20230724 3D Off Centre Line.docx20230724 3D Off Centre Line.docx
20230724 3D Off Centre Line.docx
 
20230710 Skewed Ellipse.docx
20230710 Skewed Ellipse.docx20230710 Skewed Ellipse.docx
20230710 Skewed Ellipse.docx
 
20230704 Torus Polar Plots.docx
20230704 Torus Polar Plots.docx20230704 Torus Polar Plots.docx
20230704 Torus Polar Plots.docx
 
20230623 Torus Tangent Typeup.docx
20230623 Torus Tangent Typeup.docx20230623 Torus Tangent Typeup.docx
20230623 Torus Tangent Typeup.docx
 
20230613 ACMJ Diagrams.docx
20230613 ACMJ Diagrams.docx20230613 ACMJ Diagrams.docx
20230613 ACMJ Diagrams.docx
 
20230512 Torus Equations.docx
20230512 Torus Equations.docx20230512 Torus Equations.docx
20230512 Torus Equations.docx
 
20230503 Talking Constantly.pptx
20230503 Talking Constantly.pptx20230503 Talking Constantly.pptx
20230503 Talking Constantly.pptx
 
20230418 Melting Steel.docx
20230418 Melting Steel.docx20230418 Melting Steel.docx
20230418 Melting Steel.docx
 

Recently uploaded

Lucknow Call girls - 8800925952 - 24x7 service with hotel room
Lucknow Call girls - 8800925952 - 24x7 service with hotel roomLucknow Call girls - 8800925952 - 24x7 service with hotel room
Lucknow Call girls - 8800925952 - 24x7 service with hotel roomdiscovermytutordmt
 
Call Girls Service Surat Samaira ❤️🍑 8250192130 👄 Independent Escort Service ...
Call Girls Service Surat Samaira ❤️🍑 8250192130 👄 Independent Escort Service ...Call Girls Service Surat Samaira ❤️🍑 8250192130 👄 Independent Escort Service ...
Call Girls Service Surat Samaira ❤️🍑 8250192130 👄 Independent Escort Service ...CALL GIRLS
 
♛VVIP Hyderabad Call Girls Chintalkunta🖕7001035870🖕Riya Kappor Top Call Girl ...
♛VVIP Hyderabad Call Girls Chintalkunta🖕7001035870🖕Riya Kappor Top Call Girl ...♛VVIP Hyderabad Call Girls Chintalkunta🖕7001035870🖕Riya Kappor Top Call Girl ...
♛VVIP Hyderabad Call Girls Chintalkunta🖕7001035870🖕Riya Kappor Top Call Girl ...astropune
 
Call Girls Bangalore Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Bangalore Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Bangalore Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Bangalore Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
Call Girls Nagpur Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Nagpur Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Nagpur Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Nagpur Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
Call Girls Siliguri Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Siliguri Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Siliguri Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Siliguri Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
(👑VVIP ISHAAN ) Russian Call Girls Service Navi Mumbai🖕9920874524🖕Independent...
(👑VVIP ISHAAN ) Russian Call Girls Service Navi Mumbai🖕9920874524🖕Independent...(👑VVIP ISHAAN ) Russian Call Girls Service Navi Mumbai🖕9920874524🖕Independent...
(👑VVIP ISHAAN ) Russian Call Girls Service Navi Mumbai🖕9920874524🖕Independent...Taniya Sharma
 
Bangalore Call Girls Nelamangala Number 7001035870 Meetin With Bangalore Esc...
Bangalore Call Girls Nelamangala Number 7001035870  Meetin With Bangalore Esc...Bangalore Call Girls Nelamangala Number 7001035870  Meetin With Bangalore Esc...
Bangalore Call Girls Nelamangala Number 7001035870 Meetin With Bangalore Esc...narwatsonia7
 
Chandrapur Call girls 8617370543 Provides all area service COD available
Chandrapur Call girls 8617370543 Provides all area service COD availableChandrapur Call girls 8617370543 Provides all area service COD available
Chandrapur Call girls 8617370543 Provides all area service COD availableDipal Arora
 
Call Girls Jabalpur Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Jabalpur Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Jabalpur Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Jabalpur Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
💎VVIP Kolkata Call Girls Parganas🩱7001035870🩱Independent Girl ( Ac Rooms Avai...
💎VVIP Kolkata Call Girls Parganas🩱7001035870🩱Independent Girl ( Ac Rooms Avai...💎VVIP Kolkata Call Girls Parganas🩱7001035870🩱Independent Girl ( Ac Rooms Avai...
💎VVIP Kolkata Call Girls Parganas🩱7001035870🩱Independent Girl ( Ac Rooms Avai...Taniya Sharma
 
Premium Call Girls Cottonpet Whatsapp 7001035870 Independent Escort Service
Premium Call Girls Cottonpet Whatsapp 7001035870 Independent Escort ServicePremium Call Girls Cottonpet Whatsapp 7001035870 Independent Escort Service
Premium Call Girls Cottonpet Whatsapp 7001035870 Independent Escort Servicevidya singh
 
Call Girls Ooty Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Ooty Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Ooty Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Ooty Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
Call Girls Bareilly Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Bareilly Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Bareilly Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Bareilly Just Call 9907093804 Top Class Call Girl Service AvailableDipal Arora
 
VIP Mumbai Call Girls Hiranandani Gardens Just Call 9920874524 with A/C Room ...
VIP Mumbai Call Girls Hiranandani Gardens Just Call 9920874524 with A/C Room ...VIP Mumbai Call Girls Hiranandani Gardens Just Call 9920874524 with A/C Room ...
VIP Mumbai Call Girls Hiranandani Gardens Just Call 9920874524 with A/C Room ...Garima Khatri
 
Top Rated Hyderabad Call Girls Erragadda ⟟ 6297143586 ⟟ Call Me For Genuine ...
Top Rated  Hyderabad Call Girls Erragadda ⟟ 6297143586 ⟟ Call Me For Genuine ...Top Rated  Hyderabad Call Girls Erragadda ⟟ 6297143586 ⟟ Call Me For Genuine ...
Top Rated Hyderabad Call Girls Erragadda ⟟ 6297143586 ⟟ Call Me For Genuine ...chandars293
 
Top Rated Bangalore Call Girls Richmond Circle ⟟ 8250192130 ⟟ Call Me For Gen...
Top Rated Bangalore Call Girls Richmond Circle ⟟ 8250192130 ⟟ Call Me For Gen...Top Rated Bangalore Call Girls Richmond Circle ⟟ 8250192130 ⟟ Call Me For Gen...
Top Rated Bangalore Call Girls Richmond Circle ⟟ 8250192130 ⟟ Call Me For Gen...narwatsonia7
 
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escorts
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore EscortsCall Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escorts
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escortsvidya singh
 
Low Rate Call Girls Kochi Anika 8250192130 Independent Escort Service Kochi
Low Rate Call Girls Kochi Anika 8250192130 Independent Escort Service KochiLow Rate Call Girls Kochi Anika 8250192130 Independent Escort Service Kochi
Low Rate Call Girls Kochi Anika 8250192130 Independent Escort Service KochiSuhani Kapoor
 

Recently uploaded (20)

Lucknow Call girls - 8800925952 - 24x7 service with hotel room
Lucknow Call girls - 8800925952 - 24x7 service with hotel roomLucknow Call girls - 8800925952 - 24x7 service with hotel room
Lucknow Call girls - 8800925952 - 24x7 service with hotel room
 
Call Girls Service Surat Samaira ❤️🍑 8250192130 👄 Independent Escort Service ...
Call Girls Service Surat Samaira ❤️🍑 8250192130 👄 Independent Escort Service ...Call Girls Service Surat Samaira ❤️🍑 8250192130 👄 Independent Escort Service ...
Call Girls Service Surat Samaira ❤️🍑 8250192130 👄 Independent Escort Service ...
 
♛VVIP Hyderabad Call Girls Chintalkunta🖕7001035870🖕Riya Kappor Top Call Girl ...
♛VVIP Hyderabad Call Girls Chintalkunta🖕7001035870🖕Riya Kappor Top Call Girl ...♛VVIP Hyderabad Call Girls Chintalkunta🖕7001035870🖕Riya Kappor Top Call Girl ...
♛VVIP Hyderabad Call Girls Chintalkunta🖕7001035870🖕Riya Kappor Top Call Girl ...
 
Call Girls Bangalore Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Bangalore Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Bangalore Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Bangalore Just Call 9907093804 Top Class Call Girl Service Available
 
Call Girls Nagpur Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Nagpur Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Nagpur Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Nagpur Just Call 9907093804 Top Class Call Girl Service Available
 
Call Girls Siliguri Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Siliguri Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Siliguri Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Siliguri Just Call 9907093804 Top Class Call Girl Service Available
 
(👑VVIP ISHAAN ) Russian Call Girls Service Navi Mumbai🖕9920874524🖕Independent...
(👑VVIP ISHAAN ) Russian Call Girls Service Navi Mumbai🖕9920874524🖕Independent...(👑VVIP ISHAAN ) Russian Call Girls Service Navi Mumbai🖕9920874524🖕Independent...
(👑VVIP ISHAAN ) Russian Call Girls Service Navi Mumbai🖕9920874524🖕Independent...
 
Russian Call Girls in Delhi Tanvi ➡️ 9711199012 💋📞 Independent Escort Service...
Russian Call Girls in Delhi Tanvi ➡️ 9711199012 💋📞 Independent Escort Service...Russian Call Girls in Delhi Tanvi ➡️ 9711199012 💋📞 Independent Escort Service...
Russian Call Girls in Delhi Tanvi ➡️ 9711199012 💋📞 Independent Escort Service...
 
Bangalore Call Girls Nelamangala Number 7001035870 Meetin With Bangalore Esc...
Bangalore Call Girls Nelamangala Number 7001035870  Meetin With Bangalore Esc...Bangalore Call Girls Nelamangala Number 7001035870  Meetin With Bangalore Esc...
Bangalore Call Girls Nelamangala Number 7001035870 Meetin With Bangalore Esc...
 
Chandrapur Call girls 8617370543 Provides all area service COD available
Chandrapur Call girls 8617370543 Provides all area service COD availableChandrapur Call girls 8617370543 Provides all area service COD available
Chandrapur Call girls 8617370543 Provides all area service COD available
 
Call Girls Jabalpur Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Jabalpur Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Jabalpur Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Jabalpur Just Call 9907093804 Top Class Call Girl Service Available
 
💎VVIP Kolkata Call Girls Parganas🩱7001035870🩱Independent Girl ( Ac Rooms Avai...
💎VVIP Kolkata Call Girls Parganas🩱7001035870🩱Independent Girl ( Ac Rooms Avai...💎VVIP Kolkata Call Girls Parganas🩱7001035870🩱Independent Girl ( Ac Rooms Avai...
💎VVIP Kolkata Call Girls Parganas🩱7001035870🩱Independent Girl ( Ac Rooms Avai...
 
Premium Call Girls Cottonpet Whatsapp 7001035870 Independent Escort Service
Premium Call Girls Cottonpet Whatsapp 7001035870 Independent Escort ServicePremium Call Girls Cottonpet Whatsapp 7001035870 Independent Escort Service
Premium Call Girls Cottonpet Whatsapp 7001035870 Independent Escort Service
 
Call Girls Ooty Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Ooty Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Ooty Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Ooty Just Call 9907093804 Top Class Call Girl Service Available
 
Call Girls Bareilly Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Bareilly Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Bareilly Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Bareilly Just Call 9907093804 Top Class Call Girl Service Available
 
VIP Mumbai Call Girls Hiranandani Gardens Just Call 9920874524 with A/C Room ...
VIP Mumbai Call Girls Hiranandani Gardens Just Call 9920874524 with A/C Room ...VIP Mumbai Call Girls Hiranandani Gardens Just Call 9920874524 with A/C Room ...
VIP Mumbai Call Girls Hiranandani Gardens Just Call 9920874524 with A/C Room ...
 
Top Rated Hyderabad Call Girls Erragadda ⟟ 6297143586 ⟟ Call Me For Genuine ...
Top Rated  Hyderabad Call Girls Erragadda ⟟ 6297143586 ⟟ Call Me For Genuine ...Top Rated  Hyderabad Call Girls Erragadda ⟟ 6297143586 ⟟ Call Me For Genuine ...
Top Rated Hyderabad Call Girls Erragadda ⟟ 6297143586 ⟟ Call Me For Genuine ...
 
Top Rated Bangalore Call Girls Richmond Circle ⟟ 8250192130 ⟟ Call Me For Gen...
Top Rated Bangalore Call Girls Richmond Circle ⟟ 8250192130 ⟟ Call Me For Gen...Top Rated Bangalore Call Girls Richmond Circle ⟟ 8250192130 ⟟ Call Me For Gen...
Top Rated Bangalore Call Girls Richmond Circle ⟟ 8250192130 ⟟ Call Me For Gen...
 
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escorts
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore EscortsCall Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escorts
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escorts
 
Low Rate Call Girls Kochi Anika 8250192130 Independent Escort Service Kochi
Low Rate Call Girls Kochi Anika 8250192130 Independent Escort Service KochiLow Rate Call Girls Kochi Anika 8250192130 Independent Escort Service Kochi
Low Rate Call Girls Kochi Anika 8250192130 Independent Escort Service Kochi
 

Simple Kaplan-Meier Chart in plain JavaScript and HTML 20171031

  • 1. Simple Kaplan-Meier chart in plain JavaScript and HTML SharonXiaoLiu. 2017/10/31. <!DOCTYPE html> <html> <head> <title>PlainJavaScriptKaplan-Meierchart</title> </head> <body> <!-- Use of librarypart. --> <script> var kaplanMeierData={ "treated":{
  • 2. "xMonths":[0,50, 100, 150, 200, 250, 300, 350, 400, 450, 500], "yPeople":[0,50, 100, 150, 200, 250, 300, 350, 400, 450, 500] }, "treatedCensorMarks":{ "xMonths":[45, 245], "yPeople":[50,250] }, "untreated":{ "xMonths":[0,25, 50, 75, 100, 125, 150, 175, 200, 225, 250], "yPeople":[0,50, 100, 150, 200, 250, 300, 350, 400, 450, 500] } }; </script> <!-- Library part. --> <p>Kaplan-Meierchart,withblackastreated, blue asuntreated,x-axismonthsandy-axis people.</p> <p>There is a censormark if deathdoesnot occur. Stepsare whendeathoccurs.</p> <svg height="500" width="500"id="kaplanMeierSvg"> <line x1="0" y1="500" x2="500" y2="500" style="stroke:rgb(0,0,0);stroke-width:2" id="xAxis"/> <line x1="0" y1="0" x2="0" y2="500" style="stroke:rgb(0,0,0);stroke-width:2"id="yAxis"/> <polyline id="treated_steps_svg"/> <polyline id="nonTreatedStepsSvg"/> </svg> <script> window.onload=function(){ var getKaplanMeierSvg=document.getElementById('kaplanMeierSvg'); var kaplanMeierSvgHeight=kaplanMeierData.treated.yPeople[10]; var kaplanMeierSvgWidthTreated=kaplanMeierData.treated.xMonths[10]; var kaplanMeierSvgWidthUntreated=kaplanMeierData.untreated.xMonths[10]; if (kaplanMeierSvgWidthTreated>=kaplanMeierSvgWidthUntreated) { var kaplanMeierSvgWidth=kaplanMeierSvgWidthTreated; } else { var kaplanMeierSvgWidth=kaplanMeierSvgWidthUntreated; } var getXAxis=document.getElementById('xAxis'); //The heightandwidthof the graph are determinedbythe data. getXAxis.setAttribute("x2",kaplanMeierSvgWidth); getXAxis.setAttribute("y1",kaplanMeierSvgHeight); getXAxis.setAttribute("y2",kaplanMeierSvgHeight); var getYAxis=document.getElementById('yAxis'); getYAxis.setAttribute("y2",kaplanMeierSvgHeight); //Above all working. var treatedSteps="";
  • 3. for (vari = 0; i < kaplanMeierData.treated.xMonths.length;i++) { treatedSteps+=kaplanMeierData.treated.xMonths[i] +","+ kaplanMeierData.treated.yPeople[i] +" "; if (i != kaplanMeierData.treated.xMonths.length-1){ treatedSteps+=kaplanMeierData.treated.xMonths[i] +"," + kaplanMeierData.treated.yPeople[i+1] + " "; } } get_treated_steps_svg=document.getElementById('treated_steps_svg'); get_treated_steps_svg.setAttribute("points",treatedSteps); get_treated_steps_svg.setAttribute("style","fill:none;stroke:black;stroke-width:1"); //0,0 0,50 50,50 50,100 100,100 var untreatedSteps=""; for (varj = 0; j < kaplanMeierData.untreated.xMonths.length;j++) { untreatedSteps+=kaplanMeierData.untreated.xMonths[j] +","+ kaplanMeierData.untreated.yPeople[j] +" "; if (j != kaplanMeierData.untreated.xMonths.length-1){ untreatedSteps+=kaplanMeierData.untreated.xMonths[j] +"," + kaplanMeierData.untreated.yPeople[j+1] +" "; } } document.getElementById("nonTreatedStepsSvg").setAttribute("points",untreatedSteps); document.getElementById("nonTreatedStepsSvg").setAttribute("style", "fill:none;stroke:blue;stroke-width:1"); //(0,0) 0,50 (25,50) 25,100 (50,100) var censorMarksLength= kaplanMeierData.treatedCensorMarks.xMonths.length; var censorMarks= ""; for (vari = 0; i<censorMarksLength;i++) { censorMarks += "<line x1=""; var verticalCensorMarkX =kaplanMeierData.treatedCensorMarks.xMonths[i]; censorMarks+= verticalCensorMarkX; censorMarks+= "" y1=""; var verticalCensorMarkYStart=kaplanMeierData.treatedCensorMarks.yPeople[i]-10; censorMarks+= verticalCensorMarkYStart; censorMarks+= "" x2=""; censorMarks+= verticalCensorMarkX; censorMarks+= "" y2=""; var verticalCensorMarkYFinish=kaplanMeierData.treatedCensorMarks.yPeople[i]+10; censorMarks+= verticalCensorMarkYFinish; censorMarks+= "" style="stroke:black;stroke-width:2;"/>"; } //Appendthe censormarkstogetKaplanMeierSvg. getKaplanMeierSvg.innerHTML+= censorMarks; }; </script>