<html>
<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>
// Use a data frame (2D-array) for the graph
var data =
// Create the configuration for the graph
var config = {
"graphType" : "Sparklines",
"sparklineType" : "line",
"sparklineBaseline" : "mean",
"sparklineMarkers" : "endpoints",
"title" : "Monthly sessions by channel"
}
// Event used to create graph (optional)
var events = false
// Call the CanvasXpress function to create the graph
var cX = new CanvasXpress("canvasId", data, config, events);
</script>
</body>
</html>
<html>
<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" : {
"vars" : [
"Sessions"
],
"smps" : [
"Jan-A",
"Feb-A",
"Mar-A",
"Apr-A",
"May-A",
"Jun-A",
"Jan-B",
"Feb-B",
"Mar-B",
"Apr-B",
"May-B",
"Jun-B",
"Jan-C",
"Feb-C",
"Mar-C",
"Apr-C",
"May-C",
"Jun-C",
"Jan-D",
"Feb-D",
"Mar-D",
"Apr-D",
"May-D",
"Jun-D"
],
"data" : [
[
120,
135,
128,
150,
162,
158,
60,
58,
64,
70,
69,
74,
210,
205,
230,
225,
248,
260,
44,
52,
49,
58,
55,
63
]
]
},
"x" : {
"Channel" : [
"Organic",
"Organic",
"Organic",
"Organic",
"Organic",
"Organic",
"Email",
"Email",
"Email",
"Email",
"Email",
"Email",
"Paid",
"Paid",
"Paid",
"Paid",
"Paid",
"Paid",
"Referral",
"Referral",
"Referral",
"Referral",
"Referral",
"Referral"
]
}
}
// Create the configuration for the graph
var config = {
"graphType" : "Sparklines",
"sparklineType" : "line",
"sparklineBaseline" : "mean",
"sparklineMarkers" : "endpoints",
"title" : "Monthly sessions by channel"
}
// Event used to create graph (optional)
var events = false
// Call the CanvasXpress function to create the graph
var cX = new CanvasXpress("canvasId", data, config, events);
</script>
</body>
</html>
library(canvasXpress)
y=read.table("https://www.canvasxpress.org/data/r/cX-sparklines1-dat.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
x=read.table("https://www.canvasxpress.org/data/r/cX-sparklines1-smp.txt", header=TRUE, sep="\t", quote="", row.names=1, fill=TRUE, check.names=FALSE, stringsAsFactors=FALSE)
canvasXpress(
data=y,
smpAnnot=x,
graphType="Sparklines",
sparklineBaseline="mean",
sparklineMarkers="endpoints",
sparklineType="line",
title="Monthly sessions by channel"
)
from canvasxpress.canvas import CanvasXpress
from canvasxpress.plot import show_in_browser
if __name__ == "__main__":
# Define the chart with its data and configuration
chart: CanvasXpress = CanvasXpress(
render_to = "sparklines1",
data = {
"y": {
"vars": ["Sessions"],
"smps": ["Jan-A", "Feb-A", "Mar-A", "Apr-A", "May-A", "Jun-A", "Jan-B", "Feb-B", "Mar-B", "Apr-B", "May-B", "Jun-B", "Jan-C", "Feb-C", "Mar-C", "Apr-C", "May-C", "Jun-C", "Jan-D", "Feb-D", "Mar-D", "Apr-D", "May-D", "Jun-D"],
"data": [
[120, 135, 128, 150, 162, 158, 60, 58, 64, 70, 69, 74, 210, 205, 230, 225, 248, 260, 44, 52, 49, 58, 55, 63]
]
},
"x": {
"Channel": ["Organic", "Organic", "Organic", "Organic", "Organic", "Organic", "Email", "Email", "Email", "Email", "Email", "Email", "Paid", "Paid", "Paid", "Paid", "Paid", "Paid", "Referral", "Referral", "Referral", "Referral", "Referral", "Referral"]
}
},
config = {
"graphType": "Sparklines",
"sparklineType": "line",
"sparklineBaseline": "mean",
"sparklineMarkers": "endpoints",
"title": "Monthly sessions by channel"
},
width = 600,
height = 600
)
# Display the chart in its own Web page
show_in_browser(chart)
Run this notebook:
from canvasxpress.canvas import CanvasXpress
from canvasxpress.plot import graph
graph(
CanvasXpress(
render_to = "sparklines1",
data = {
"y": {
"vars": ["Sessions"],
"smps": ["Jan-A", "Feb-A", "Mar-A", "Apr-A", "May-A", "Jun-A", "Jan-B", "Feb-B", "Mar-B", "Apr-B", "May-B", "Jun-B", "Jan-C", "Feb-C", "Mar-C", "Apr-C", "May-C", "Jun-C", "Jan-D", "Feb-D", "Mar-D", "Apr-D", "May-D", "Jun-D"],
"data": [
[120, 135, 128, 150, 162, 158, 60, 58, 64, 70, 69, 74, 210, 205, 230, 225, 248, 260, 44, 52, 49, 58, 55, 63]
]
},
"x": {
"Channel": ["Organic", "Organic", "Organic", "Organic", "Organic", "Organic", "Email", "Email", "Email", "Email", "Email", "Email", "Paid", "Paid", "Paid", "Paid", "Paid", "Paid", "Referral", "Referral", "Referral", "Referral", "Referral", "Referral"]
}
},
config = {
"graphType": "Sparklines",
"sparklineType": "line",
"sparklineBaseline": "mean",
"sparklineMarkers": "endpoints",
"title": "Monthly sessions by channel"
},
width = 600,
height = 600
)
)
using CanvasXpress
canvasxpress(Dict(
"y" => Dict(
"vars" => ["Sessions"],
"smps" => ["Jan-A", "Feb-A", "Mar-A", "Apr-A", "May-A", "Jun-A", "Jan-B", "Feb-B", "Mar-B", "Apr-B", "May-B", "Jun-B", "Jan-C", "Feb-C", "Mar-C", "Apr-C", "May-C", "Jun-C", "Jan-D", "Feb-D", "Mar-D", "Apr-D", "May-D", "Jun-D"],
"data" => [
[120, 135, 128, 150, 162, 158, 60, 58, 64, 70, 69, 74, 210, 205, 230, 225, 248, 260, 44, 52, 49, 58, 55, 63]
]
),
"x" => Dict(
"Channel" => ["Organic", "Organic", "Organic", "Organic", "Organic", "Organic", "Email", "Email", "Email", "Email", "Email", "Email", "Paid", "Paid", "Paid", "Paid", "Paid", "Paid", "Referral", "Referral", "Referral", "Referral", "Referral", "Referral"]
)
);
graphType = "Sparklines",
sparklineType = "line",
sparklineBaseline = "mean",
sparklineMarkers = "endpoints",
title = "Monthly sessions by channel"
)