Line Chart

A line chart or line graph displays the evolution of one or several numeric variables. Data points are connected by straight line segments. It is similar to a scatter plot except that the measurement points are ordered (typically by their x-axis value) and joined with straight line segments. A line chart is often used to visualize a trend in data over intervals of time – a time series – thus the line is often drawn chronologically. When several values are available for each time stamp, data can be aggregated and a confidence zone is generally added around the trend.


Example Color Themes

Example Fonts



Show Code

Tools

<!-- Include the CanvasXpress library in your HTML file -->
<link rel="stylesheet" href="https://www.canvasxpress.org/dist/canvasXpress.css" type="text/css"/>
<script src="https://www.canvasxpress.org/canvasXpress.min.js"></script>


<!-- Create a canvas element for the chart with the desired dimensions -->
<div>
  <canvas id="canvasId" width="600" height="600"</canvas>
</div>


<!-- Create a script to initialize the chart -->
<script>

  <!-- Create the data for the graph -->
  var data = {
     "y" : {
        "data" : [
          [118,30],
          [484,58],
          [664,87],
          [1004,115],
          [1231,120],
          [1372,142],
          [1582,145],
          [118,33],
          [484,69],
          [664,111],
          [1004,156],
          [1231,172],
          [1372,203],
          [1582,203],
          [118,30],
          [484,51],
          [664,75],
          [1004,108],
          [1231,115],
          [1372,139],
          [1582,140],
          [118,32],
          [484,62],
          [664,112],
          [1004,167],
          [1231,179],
          [1372,209],
          [1582,214],
          [118,30],
          [484,49],
          [664,81],
          [1004,125],
          [1231,142],
          [1372,174],
          [1582,177]
        ],
        "smps" : ["Days Old","Circumference (mm)"],
        "vars" : [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35]
     },
     "z" : {
        "Tree" : ["Tree-1","Tree-1","Tree-1","Tree-1","Tree-1","Tree-1","Tree-1","Tree-2","Tree-2","Tree-2","Tree-2","Tree-2","Tree-2","Tree-2","Tree-3","Tree-3","Tree-3","Tree-3","Tree-3","Tree-3","Tree-3","Tree-4","Tree-4","Tree-4","Tree-4","Tree-4","Tree-4","Tree-4","Tree-5","Tree-5","Tree-5","Tree-5","Tree-5","Tree-5","Tree-5"]
     }
  }
  
  
  <-- Create the configuration for the graph -->
  var config = {
     "colorBy":"Tree",
     "graphOrientation":"horizontal",
     "graphType":"Scatter2D",
     "lineBy":"Tree",
     "showLegend":"false",
     "title":"Growth of Orange Trees"
  }
  

  <!-- Call the CanvasXpress function to create the graph -->
  var cX = new CanvasXpress("canvasId", data, config);


</script>
library(canvasXpress)
y=read.table("https://www.canvasxpress.org/data/cX-oranges2-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
z=read.table("https://www.canvasxpress.org/data/cX-oranges2-var.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
  data=y,
  varAnnot=z,
  colorBy="Tree",
  graphOrientation="horizontal",
  graphType="Scatter2D",
  lineBy="Tree",
  showLegend=FALSE,
  title="Growth of Orange Trees"
)