Certainly! Below is an all-in-one HTML file that creates an interactive and visually appealing mind map for Self-Induction (الحث الذاتي) and Mutual Induction (الحث المتبادل). This mind map breaks down the concepts, rules, and related principles using HTML, CSS, and JavaScript. The design leverages the D3.js library for dynamic and interactive visuals.
You can copy the following code into a .html file and open it in your web browser to see the mind map in action.
<!DOCTYPE html>
<html lang="ar">
<head>
<meta charset="UTF-8">
<title>Mind Map: الحث الذاتي والحث المتبادل</title>
<!-- Include D3.js from CDN -->
<script src="https://d3js.org/d3.v7.min.js"></script>
<style>
body {
font-family: 'Arial, sans-serif';
background-color: #1e1e1e;
margin: 0;
padding: 0;
overflow: hidden;
direction: rtl; /* For Arabic language support */
}
.node circle {
fill: #69b3a2;
stroke: #fff;
stroke-width: 2px;
}
.node text {
font: 14px sans-serif;
fill: #fff;
pointer-events: none;
}
.link {
fill: none;
stroke: #ccc;
stroke-width: 2px;
}
.tooltip {
position: absolute;
text-align: right;
width: auto;
padding: 10px;
font: 14px sans-serif;
background: rgba(0,0,0,0.7);
color: #fff;
border: 0px;
border-radius: 8px;
pointer-events: none;
visibility: hidden;
z-index: 10;
}
</style>
</head>
<body>
<!-- Container for the mind map -->
<svg width="100%" height="100%"></svg>
<!-- Tooltip for node details -->
<div class="tooltip" id="tooltip"></div>
<script>
// Define the data for the mind map
const data = {
"name": "الحث الذاتي والحث المتبادل",
"children": [
{
"name": "الحث الذاتي",
"children": [
{
"name": "تعريف",
"details": "العملية التي يخلق فيها محرك كهربائي قوة ضد القوة المتغيرة التي تسببت في توليد الحث."
},
{
"name": "الصيغة",
"details": "E = -L (dI/dt)"
},
{
"name": "التطبيقات",
"children": [
{
"name": "المحركات الكهربائية"
},
{
"name": "المولدات"
}
]
}
]
},
{
"name": "الحث المتبادل",
"children": [
{
"name": "تعريف",
"details": "عملية توليد قوة محركة كهربائية في دائرة بسبب تغير التيار في دائرة أخرى."
},
{
"name": "الصيغة",
"details": "E₂ = -M (dI₁/dt)"
},
{
"name": "التطبيقات",
"children": [
{
"name": "المحولات"
},
{
"name": "الدوائر اللاسلكية"
}
]
}
]
},
{
"name": "القوانين",
"children": [
{
"name": "قانون فاراداي",
"details": "التغير في التدفق المغناطيسي عبر دائرة يؤدي إلى توليد قوة كهربائية محركة."
},
{
"name": "قانون لورنتز",
"details": "القوة المحركة الكهربائية تتناسب عكسياً مع معدل تغير التيار."
}
]
},
{
"name": "أمثلة وحلول",
"children": [
{
"name": "حل مسائل الحث الذاتي"
},
{
"name": "حل مسائل الحث المتبادل"
}
]
}
]
};
const width = window.innerWidth;
const height = window.innerHeight;
const svg = d3.select("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(40,0)"); // Shift right to avoid clipping
const tooltip = d3.select("#tooltip");
const tree = d3.tree()
.size([height, width - 160]);
const root = d3.hierarchy(data, d => d.children);
tree(root);
const link = svg.selectAll(".link")
.data(root.links())
.enter().append("path")
.attr("class", "link")
.attr("d", d3.linkHorizontal()
.x(d => d.y)
.y(d => d.x));
const node = svg.selectAll(".node")
.data(root.descendants())
.enter().append("g")
.attr("class", "node")
.attr("transform", d => `translate(${d.y},${d.x})`)
.on("mouseover", function(event, d) {
if (d.data.details) {
tooltip.style("visibility", "visible")
.html(`<strong>${d.data.name}</strong><br>${d.data.details}`);
}
})
.on("mousemove", function(event) {
tooltip.style("top", (event.pageY + 15) + "px")
.style("left", (event.pageX + 15) + "px");
})
.on("mouseout", function() {
tooltip.style("visibility", "hidden");
});
node.append("circle")
.attr("r", 20)
.style("fill", d => d.children ? "#ff8c00" : "#69b3a2");
node.append("text")
.attr("dy", ".35em")
.attr("x", d => d.children ? -25 : 25)
.style("text-anchor", d => d.children ? "end" : "start")
.style("fill", "#fff")
.text(d => d.data.name)
.clone(true).lower()
.attr("stroke", "white");
// Zoom and Pan functionality
const zoom = d3.zoom()
.scaleExtent([0.5, 3])
.on("zoom", (event) => {
svg.attr("transform", event.transform);
});
d3.select("svg").call(zoom);
</script>
</body>
</html>
Explanation of the Code
-
Structure & Libraries:
- The HTML file includes the D3.js library via CDN, which is a powerful tool for creating dynamic and interactive data visualizations in the browser.
-
Styles (<style> Section):
- The CSS styles define the appearance of the nodes, links, text, and tooltips. The background is set to a dark color to make the mind map visually striking.
- The
.tooltip class styles the tooltip that appears when you hover over nodes with additional details.
-
Data Definition:
- The
data object outlines the hierarchy of the mind map, including main topics like الحث الذاتي (Self-Induction) and الحث المتبادل (Mutual Induction), their definitions, formulas, applications, related laws, and examples.
-
D3.js Visualization:
- Tree Layout: Utilizes D3's
tree layout to position nodes in a hierarchical structure.
- Links: Drawn as paths connecting nodes using
d3.linkHorizontal.
- Nodes: Represented as groups (
<g>) containing a circle and text. Nodes with children have a different color for distinction.
- Interactivity:
- Tooltips: Appear when hovering over nodes that have additional details.
- Zoom & Pan: Users can zoom in/out and pan around the mind map for better navigation.
-
Responsive Design:
- The SVG scales to fit the entire browser window, ensuring that the mind map is viewable on different screen sizes.
Customization
- Adding More Nodes: To expand the mind map, you can add more objects to the
children arrays within the data object.
- Styling: Modify the CSS section to change colors, fonts, sizes, and other stylistic elements to suit your preferences.
- Interactivity: Enhance interactivity by adding click events, transitions, or animations as needed.
Viewing the Mind Map
- Save the Code: Copy the above code into a text editor and save it with a
.html extension, for example, mindmap.html.
- Open in Browser: Double-click the saved file or open it using any web browser (e.g., Chrome, Firefox, Edge).
- Interact: Hover over the nodes to see tooltips with additional information. Use your mouse to zoom and pan around the mind map.
Further Enhancements
- Responsive Design: Make the mind map responsive to window resizing events for better mobile compatibility.
- Enhanced Styling: Incorporate CSS animations or transitions for smoother interactions.
- Additional Data: Include more detailed information, images, or links within the tooltips for an enriched learning experience.
This mind map serves as a comprehensive visual tool to understand and explore the concepts of self-induction and mutual induction, their underlying principles, applications, and related laws. Feel free to modify and expand it to better fit your educational needs!