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

<head>
  <!-- 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/dist/canvasXpress.min.js"></script>
</head>

<body>

  <!-- 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" : [
            [30,58,87,115,120,142,145],
            [33,69,111,156,172,203,203],
            [30,51,75,108,115,139,140],
            [32,62,112,167,179,209,214],
            [30,49,81,125,142,174,177]
          ],
          "smps" : [118,484,664,1004,1231,1372,1582],
          "vars" : [1,2,3,4,5]
       }
    }
    
    
    // Create the configuration for the graph
    var config = {
       "backgroundType":"panel",
       "blockContrast":true,
       "evenColor":"rgb(226,236,248)",
       "graphOrientation":"vertical",
       "graphType":"Line",
       "legendInside":true,
       "legendKeyBackgroundBorderColor":"rgba(255,255,255,0)",
       "legendKeyBackgroundColor":"rgba(255,255,255,0)",
       "legendPosition":"topLeft",
       "panelBackgroundColor":"rgb(226,236,248)",
       "smpTextRotate":"90",
       "smpTitle":"Days Old",
       "theme":"GGPlot",
       "title":"Growth of Orange Trees",
       "xAxisTitle":"Circumference (mm)"
    }
    

    // Call the CanvasXpress function to create the graph
    var cX = new CanvasXpress("canvasId", data, config);


  </script>

</body>
library(canvasXpress)
y=read.table("https://www.canvasxpress.org/data/cX-oranges-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
  data=y,
  backgroundType="panel",
  blockContrast=TRUE,
  evenColor="rgb(226,236,248)",
  graphOrientation="vertical",
  graphType="Line",
  legendInside=TRUE,
  legendKeyBackgroundBorderColor="rgba(255,255,255,0)",
  legendKeyBackgroundColor="rgba(255,255,255,0)",
  legendPosition="topLeft",
  panelBackgroundColor="rgb(226,236,248)",
  smpTextRotate=90,
  smpTitle="Days Old",
  theme="GGPlot",
  title="Growth of Orange Trees",
  xAxisTitle="Circumference (mm)"
)