line chart

What is a Line Chart ?

  • Profile picture of Mcs
  • by Mcs July 1, 2025

A Line Chart is a type of graph that displays information as a series of data points connected by straight lines. It is commonly used to show trends over time.

Key Features:

  1. X-axis: Usually shows time (days, months, years, etc.)
  2. Y-axis: Shows the value (temperature, sales, etc.)
  3. Points connected: Each point represents a value at a specific time

Example Use Cases:

  1. Temperature changes during the day
  2. Stock price movements
  3. Website traffic over weeks
  4. Monthly sales growth
Line Chart Example using Chart.js:

<canvas id="myChart" width="400" height="200"></canvas>

<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
const ctx = document.getElementById('myChart').getContext('2d');

const myChart = new Chart(ctx, {
 type: 'line',
 data: {
   labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
   datasets: [{
     label: 'Sales',
     data: [150, 200, 180, 220, 300],
     borderColor: 'blue',
     fill: false,
     tension: 0.3
   }]
 },
 options: {
   responsive: true,
   scales: {
     y: {
       beginAtZero: true
     }
   }
 }
});
</script>

Comments

Add new comment

Restricted HTML

  • Allowed HTML tags: <br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <cite> <dl> <dt> <dd> <a hreflang href> <blockquote cite> <ul type> <ol type start> <strong> <em> <code> <li>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.