Implement a feature in html/css that takes a sample text and fits it into a shape. there are simple shapes built in, or you can do custom shapes with a polygon tool. You can choose what shape to make.
Code:
<!DOCTYPE html>
<html>
<head>
<style>
.shape {
height: 150px;
width: 150px;
background-color: #0074d9;
border-radius: 80px;
text-align:center;
margin: auto;
font-family:arial
}
h2{
margin-top:55px;
}
.shape2 {
border-radius: 30px;
}
.shape3 {
border-radius: 5px;
}
body, html {
height: 100%;
}
#canvas{
width:200px;
height:100px;
border-radius: 5px;
background-color: #0074d9;
margin:10px;
}
body {
background-color: #001f3f;
display: flex;
justify-content: center;
align-items: center;
}
</style>
</head>
<body>
<canvas id="canvas"></canvas> <!-- draw rectange shape using canvas-->
<script>
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.font = "30px Arial ";
ctx.fillText("Sample",100,80);
</script>
<!-- draw custom shapes using css -->
<div class="shape"><h2>Sample</h2></div>
<div class="shape shape2"><h2>Sample</h2></div>
<div class="shape shape3"><h2>Sample</h2></div>
</body>
</html>
Output:
WordCloud of student result
<!DOCTYPE html>
<html>
<head>
<title>Word Cloud</title>
<script src="https://cdn.anychart.com/releases/v8/js/anychart-base.min.js"></script>
<script src="https://cdn.anychart.com/releases/v8/js/anychart-tag-cloud.min.js"></script>
<style>
html, body, #mycloud {
width: 100%;
height: 100%;
background-color: #0074d9;
}
</style>
</head>
<body>
<div id="mycloud"></div>
<script>
anychart.onDocumentReady(function() {
var data = [
{"x": "Student7", "value": 89, category: "Maths"},
{"x": "Student1", "value": 20, category: "Physics"},
{"x": "Student12", "value": 69, category: "Biology"},
{"x": "Student3", "value": 30, category: "Biology"},
{"x": "Student4", "value": 56, category: "Chemistry"},
{"x": "Student5", "value": 80, category: "Chemistry"},
{"x": "Student6", "value": 56, category: "Physics"},
{"x": "Student8", "value": 34, category: "Maths"},
{"x": "Student9", "value": 67, category: "Maths"},
{"x": "Student10", "value": 80, category: "Maths"},
{"x": "Student11", "value": 45, category: "Physics"},
{"x": "Student2", "value": 87, category: "Biology"},
{"x": "Student13", "value": 100, category: "Chemistry"},
{"x": "Student14", "value": 34, category: "Chemistry"}
];
// create cloud chart of given JSON data
var chart = anychart.tagCloud(data);
// set a chart title
chart.title('Student Result')
// set an array of angles at which the words will be laid out
chart.angles([0, -45, 90])
// enable a color range
chart.colorRange(true);
// set the color range length
chart.colorRange().length('80%');
// display word cloud chart
chart.container("mycloud");
chart.draw();
});
</script>
</body>
</html>
Output:
Get Answers For Free
Most questions answered within 1 hours.