@@ -4,7 +4,9 @@ | |||
color: #fff; | |||
padding: 2em 0; | |||
} | |||
.jumbotron { | |||
padding: 2rem 2rem; | |||
} | |||
.project-name { | |||
padding-top: 1.8em; | |||
font-size: 2.5em; | |||
@@ -37,7 +39,7 @@ hr { | |||
margin-bottom: 2rem; | |||
} | |||
.chart-container { | |||
.graphics-container { | |||
border: 1px solid #ddd; | |||
border-radius: 3px; | |||
} | |||
@@ -47,7 +49,7 @@ pre.highlight { | |||
border-radius: 3px; | |||
} | |||
.btn-group>.btn { | |||
.btn { | |||
outline: none !important; | |||
} | |||
.dashboard-section h1 { | |||
@@ -56,4 +58,14 @@ pre.highlight { | |||
.hero .gantt-container { | |||
text-align: left; | |||
} | |||
.hero { | |||
/*font-size: 1.4rem;*/ | |||
} | |||
.margin-vertical-px { | |||
margin: 15px 0px; | |||
} | |||
.margin-vertical-rem { | |||
margin: 2em 0 1em 0; | |||
} |
@@ -1,113 +1,176 @@ | |||
let bar_data = { | |||
// "labels": ["Oct", "Nov", "Dec", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep"], | |||
let bar_composite_data = { | |||
"labels": ["Oct", "Nov", "Dec", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug"], | |||
"datasets": [{ | |||
"color": "orange", | |||
// "values": [50804, 10000, 20000, -61500, 82936.88, 24010, 4000, 6000, 25840, 50804.82, 116820, 6000], | |||
"values": [50804, 10000, 20000, 61500, 82936.88, 24010, 40000, 60000, 25840, 50804.82, 116820], | |||
// "values": [-108048, 0, 0, -101500, -50000.88, 24010, 0, 0, 25840, 108048.82, 51682, 0], | |||
"formatted": ["₹ 0.00", "₹ 0.00", "₹ 0.00", "₹ 61,500.00", "₹ 82,936.88", "₹ 24,010.00", "₹ 0.00", "₹ 0.00", "₹ 25,840.00", "₹ 5,08,048.82", "₹ 1,16,820.00", "₹ 0.00"], | |||
} | |||
, | |||
{ | |||
"color": "blue", | |||
// "values": [-108048, 0, 0, -101500, -50000.88, 24010, 0, 0, 25840, 108048.82, 51682, 0], | |||
"values": [108048, 0, 0, 101500, 50000.88, 24010, 0, 0, 25840, 108048.82, 51682], | |||
"formatted": ["₹ 0.00", "₹ 0.00", "₹ 0.00", "₹ 61,500.00", "₹ 82,936.88", "₹ 24,010.00", "₹ 0.00", "₹ 0.00", "₹ 25,840.00", "₹ 5,08,048.82", "₹ 1,16,820.00", "₹ 0.00"], | |||
} | |||
] | |||
} | |||
let line_data = { | |||
let line_composite_data = { | |||
"labels": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], | |||
"datasets": [{ | |||
"color": "green", | |||
"values": [25, 40, 30, 35, 48, 52, 17], | |||
// "values": [25, -90, -30, 35, 48, 52, -17] | |||
"values": [25, 40, 30, 35, 48, 52, 17] | |||
} | |||
] | |||
}; | |||
let more_line_data = { | |||
0: {values: [25, -90, -30, 35, 48, 52, -17]}, | |||
1: {values: [25, -40, -30, 35, 48, 52, 30]}, | |||
2: {values: [5, 48, -52, 17, -25, 40, 30]}, | |||
3: { | |||
values: [25, 40, 30, 35, 48, 52, 17] | |||
}, | |||
4: { | |||
values: [35, 48, 40, 30, 52, 17, 72] | |||
}, | |||
5: { | |||
values: [5, 48, 52, 17, 72, 40, 30] | |||
}, | |||
6: { | |||
values: [72, 40, 30, 35, 48, 52, 17] | |||
}, | |||
7: { | |||
values: [35, 48, 40, 30, 52, 17, 25] | |||
}, | |||
8: { | |||
values: [5, 48, 52, 17, 25, 40, 30] | |||
}, | |||
9: { | |||
values: [25, 40, 30, 35, 48, 52, 17] | |||
}, | |||
10: { | |||
values: [35, 48, 40, 30, 52, 17, 25] | |||
}, | |||
11: { | |||
values: [5, 48, 52, 17, 25, 40, 30] | |||
} | |||
} | |||
let type_data = { | |||
"labels": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], | |||
"datasets": [{ | |||
"color": "light-blue", | |||
"values": [25, 40, 30, 35, 8, 52, 17] | |||
}, | |||
{ | |||
"color": "violet", | |||
"values": [25, 50, -10, 15, 18, 32, 27] | |||
}, | |||
// { | |||
// "color": "yellow", | |||
// // "values": [25, 40, 30, 35, 48, 52, 17], | |||
// "values": [25, -90, -30, 35, 48, 52, -17] | |||
{ | |||
"color": "blue", | |||
"values": [15, 20, -3, -15, 58, 12, -17] | |||
// } | |||
} | |||
] | |||
}; | |||
let more_line_data = { | |||
0: [{values: [25, -90, -30, 35, 48, 52, -17]}, ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]], | |||
1: [{values: [25, -40, -30, 35, 48, 52]}, ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri"]], | |||
2: [{values: [5, 48, -52, 17, -25, 40, 30, 20, -25, 40, 30, 20]}, ["Thu", "Fri", "Sat", "Sun", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]], | |||
// 3: { | |||
// values: [25, 40, 30, 35, 48, 52, 17, 20, 30, 40] | |||
// }, | |||
// 4: { | |||
// values: [35, 48, 40, 30, 52, 17, 72] | |||
// }, | |||
// 5: { | |||
// values: [5, 48, 52, 17, 72, 40, 30] | |||
// }, | |||
// 6: { | |||
// values: [72, 40, 30, 35, 48, 52, 17] | |||
// }, | |||
// 7: { | |||
// values: [35, 48, 40, 30, 52, 17, 25] | |||
// }, | |||
// 8: { | |||
// values: [5, 48, 52, 17, 25, 40, 30] | |||
// }, | |||
// 9: { | |||
// values: [25, 40, 30, 35, 48, 52, 17] | |||
// }, | |||
// 10: { | |||
// values: [35, 48, 40, 30, 52, 17, 25] | |||
// }, | |||
// 11: { | |||
// values: [5, 48, 52, 17, 25, 40, 30] | |||
// } | |||
} | |||
let update_data = { | |||
"labels": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], | |||
"datasets": [{ | |||
"color": "red", | |||
"values": [25, 40, 30, 35, 48, 52, 17] | |||
} | |||
] | |||
}; | |||
let line_chart = new frappe.chart.FrappeChart ({ | |||
parent: "#charts-2", | |||
data: line_data, | |||
type: 'line', | |||
height: 340, | |||
region_fill: 1, | |||
// y_axis_mode: 'tick' | |||
}) | |||
let events_data = { | |||
"labels": ["Sun", "Mon", "Tue", "Wed", "Thu"], | |||
"datasets": [{ | |||
"color": "light-green", | |||
"values": [25, 40, 30, 35, 48] | |||
} | |||
] | |||
}; | |||
let aggr_data = { | |||
"labels": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], | |||
"datasets": [{ | |||
"color": "purple", | |||
"values": [25, 40, 30, 35, 8, 52, 17] | |||
}, | |||
{ | |||
"color": "orange", | |||
"values": [25, 50, -10, 15, 18, 32, 27] | |||
let bar_chart = new frappe.chart.FrappeChart ({ | |||
parent: "#charts-1", | |||
data: bar_data, | |||
} | |||
] | |||
}; | |||
let heatmap_data = { | |||
1479753000.0: 1, | |||
1498588200.0: 1, | |||
1499193000.0: 1, | |||
1499625000.0: 2, | |||
1500921000.0: 1, | |||
1501612200.0: 1, | |||
1502994600.0: 1, | |||
1503858600.0: 1, | |||
1504809000.0: 3, | |||
1505241000.0: 1, | |||
1506277800.0: 2 | |||
}; | |||
let bar_composite_chart = new frappe.chart.FrappeChart ({ | |||
parent: "#chart-composite-1", | |||
data: bar_composite_data, | |||
type: 'bar', | |||
height: 140, | |||
is_navigable: 1, | |||
height: 180, | |||
is_navigable: 1 | |||
// region_fill: 1 | |||
}) | |||
bar_chart.parent.addEventListener('data-select', (e) => { | |||
line_chart.update_values([more_line_data[e.index][0]], more_line_data[e.index][1]); | |||
let line_composite_chart = new frappe.chart.FrappeChart ({ | |||
parent: "#chart-composite-2", | |||
data: line_composite_data, | |||
type: 'line', | |||
height: 180 | |||
}) | |||
bar_composite_chart.parent.addEventListener('data-select', (e) => { | |||
line_composite_chart.update_values([more_line_data[e.index]]); | |||
}); | |||
// console.log("chart", bar_chart); | |||
let type_chart = new frappe.chart.FrappeChart({ | |||
parent: "#chart-types", | |||
data: type_data, | |||
type: 'bar', | |||
height: 250, | |||
// region_fill: 1, | |||
// y_axis_mode: 'tick' | |||
}); | |||
let percentage_data = {}; | |||
let update_chart = new frappe.chart.FrappeChart({ | |||
parent: "#chart-update", | |||
data: update_data, | |||
type: 'line', | |||
height: 250, | |||
region_fill: 1 | |||
}); | |||
let heatmap_data = {}; | |||
let events_chart = new frappe.chart.FrappeChart({ | |||
parent: "#chart-events", | |||
data: events_data, | |||
type: 'bar', | |||
height: 250, | |||
is_navigable: 1, | |||
}); | |||
// update_test() { | |||
// setTimeout(() => { | |||
// this.update_values([{values: [0, 0, 0, 21500, 50000.88, 24010, 0, 0, 25840, 108048.82, 516820, 0]}, | |||
// {values: [0, 0, 0, 21500, 80000.88, 24010, 20000, 20000, 15840, 508048.82, 116820, 0]}]); | |||
// setTimeout(() => { | |||
// this.update_values([{values: [0, 0, 0, 21500, 80000.88, 24010, 20000, 20000, 15840, 508048.82, 116820, 0]}, | |||
// {values: [0, 0, 0, 21500, 50000.88, 24010, 0, 0, 25840, 108048.82, 516820, 0]}]); | |||
// setTimeout(() => { | |||
// this.update_values([{values: [0, 0, 0, 101500, 50000.88, 24010, 0, 0, 25840, 108048.82, 516820, 0]}, | |||
// {values: [0, 0, 0, 21500, 80000.88, 24010, 20000, 20000, 15840, 508048.82, 116820, 0]}]); | |||
let aggr_chart = new frappe.chart.FrappeChart({ | |||
parent: "#chart-aggr", | |||
data: aggr_data, | |||
type: 'line', | |||
height: 250 | |||
}); | |||
// }, 300); | |||
// }, 300); | |||
// }, 300); | |||
// } | |||
let heatmap = new frappe.chart.FrappeChart({ | |||
parent: "#chart-heatmap", | |||
data: heatmap_data, | |||
type: 'heatmap', | |||
height: 100, | |||
// discrete_domains: 1 | |||
}); |
@@ -8,11 +8,12 @@ | |||
<meta name="description" content="A simple, responsive, modern charts library for the web."> | |||
<link rel="stylesheet" type="text/css" href="assets/css/normalize.css" media="screen"> | |||
<!--<link href='https://fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'>--> | |||
<link href='https://fonts.googleapis.com/css?family=Roboto:400,700' rel='stylesheet' type='text/css'> | |||
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css" media="screen"> | |||
<link rel="stylesheet" type="text/css" href="assets/css/frappe_theme.css" media="screen"> | |||
<link rel="stylesheet" type="text/css" href="assets/css/index.css" media="screen"> | |||
<link rel="stylesheet" type="text/css" href="assets/css/default.css" media="screen"> | |||
<!--<link rel="stylesheet" type="text/css" href="assets/css/vs.css" media="screen">--> | |||
<link rel="stylesheet" type="text/css" href="../src/charts.css" media="screen"> | |||
<script src="assets/js/highlight.pack.js"></script> | |||
<script>hljs.initHighlightingOnLoad();</script> | |||
@@ -28,21 +29,119 @@ | |||
<h1>Frappé Charts</h1> | |||
<p class="mt-2">GitHub-inspired simple and modern charts for the web</p> | |||
<p class="mt-2">with zero dependencies.</p> | |||
<p class="mt-2">Because dumb charts are hard to come by.</p> | |||
<!--<p class="mt-2">Because dumb charts are hard to come by.</p>--> | |||
</div> | |||
<div class="col-sm-10 push-sm-1 later" style="font-size: 14px;"> | |||
<div id="charts-1" class="chart-container"></div> | |||
<div id="chart-composite-1" class="graphics-container"></div> | |||
<p class="mt-1">Use arrow keys to navigate data points</p> | |||
</div> | |||
<div class="col-sm-10 push-sm-1 later" style="font-size: 14px;"> | |||
<div id="charts-2" class="chart-container"></div> | |||
<div id="chart-composite-2" class="graphics-container"></div> | |||
</div> | |||
</div> | |||
<div class="group later"> | |||
<div class="row section"> | |||
<div class="col-sm-10 push-sm-1"> | |||
<div class="dashboard-section"> | |||
<h6 class="margin-vertical-rem"> | |||
Bars, Lines or <a href="http://www.storytellingwithdata.com/blog/2011/07/death-to-pie-charts" target="_blank">Percentages</a> | |||
</h6> | |||
<div id="chart-types" class="graphics-container"></div> | |||
<div class="mt-1 mx-auto" role="group"> | |||
<button type="button" class="btn btn-sm btn-secondary active">Bar Chart</button> | |||
<button type="button" class="btn btn-sm btn-secondary">Line Chart</button> | |||
<button type="button" class="btn btn-sm btn-secondary">Percentage Chart</button> | |||
</div> | |||
<pre><code class="hljs html margin-vertical-px"><div id="chart"></div></code></pre> | |||
</div> | |||
</div> | |||
<div class="col-sm-10 push-sm-1"> | |||
<div class="dashboard-section"> | |||
<h6 class="margin-vertical-rem"> | |||
Update Values | |||
</h6> | |||
<div id="chart-update" class="graphics-container"></div> | |||
<div class="mt-1 mx-auto" role="group"> | |||
<button type="button" class="btn btn-sm btn-secondary">Random Reset</button> | |||
<button type="button" class="btn btn-sm btn-secondary">Add Value</button> | |||
<button type="button" class="btn btn-sm btn-secondary">Remove Value</button> | |||
</div> | |||
<pre><code class="hljs html margin-vertical-px"><div id="chart"></div></code></pre> | |||
</div> | |||
</div> | |||
<div class="col-sm-10 push-sm-1"> | |||
<div class="dashboard-section"> | |||
<h6 class="margin-vertical-rem"> | |||
Listen to state change | |||
</h6> | |||
<div id="chart-events" class="graphics-container"></div> | |||
<pre><code class="hljs html margin-vertical-px"><div id="chart"></div></code></pre> | |||
</div> | |||
</div> | |||
<div class="col-sm-10 push-sm-1"> | |||
<div class="dashboard-section"> | |||
<h6 class="margin-vertical-rem"> | |||
Simple Aggregations | |||
</h6> | |||
<div id="chart-aggr" class="graphics-container"></div> | |||
<div class="mt-1 mx-auto" role="group"> | |||
<button type="button" class="btn btn-sm btn-secondary">Show Sums</button> | |||
<button type="button" class="btn btn-sm btn-secondary">Show Average</button> | |||
</div> | |||
<pre><code class="hljs html margin-vertical-px"><div id="chart"></div></code></pre> | |||
</div> | |||
</div> | |||
<div class="col-sm-10 push-sm-1"> | |||
<div class="dashboard-section"> | |||
<h6 class="margin-vertical-rem"> | |||
Oh, and a complementary annual Heatmap | |||
</h6> | |||
<div id="chart-heatmap" class="graphics-container" | |||
style="overflow: scroll; text-align: center; padding: 20px;"></div> | |||
<div class="mt-1 mx-auto" role="group"> | |||
<button type="button" class="btn btn-sm btn-secondary active">Dicrete</button> | |||
<button type="button" class="btn btn-sm btn-secondary">Continuous</button> | |||
</div> | |||
<pre><code class="hljs html margin-vertical-px"><div id="chart"></div></code></pre> | |||
</div> | |||
</div> | |||
<div class="col-sm-10 push-sm-1"> | |||
<div class="dashboard-section"> | |||
<!-- Closing --> | |||
<div class="text-center" style="margin-top: 70px"> | |||
<a href="https://github.com/frappe/charts/archive/master.zip"><button class="large blue button">Download</button></a> | |||
<p class="mt-2"><a href="https://github.com/frappe/charts" target="_blank">View on GitHub</a></p> | |||
<p>License: MIT</p> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="built-with-frappe text-center" style="margin-top: -20px"> | |||
<img style="padding: 5px; width: 40px; background: #fff" class="frappe-bird" src="https://frappe.github.io/frappe/assets/img/frappe-bird-grey.svg"> | |||
<p style="margin: 24px 0 80px 0; font-size: 15px">Made by <a href="https://github.com/pratu16x7" target="_blank">pratu16x7</a>. Used in <a href="https://erpnext.com" target="_blank">ERPNext</a>.</p> | |||
</div> | |||
<a href="https://github.com/frappe/charts" target="_blank" class="github-corner" aria-label="View source on Github"> | |||
<svg width="80" height="80" viewBox="0 0 250 250" style="fill:#9a9a9a; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"> | |||
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path> | |||
<path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path> | |||
<path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path> | |||
</svg> | |||
</a> | |||
<script src="../src/charts.js"></script> | |||
<script src="assets/js/index.js"></script> | |||
</body> | |||
@@ -410,3 +410,47 @@ | |||
.border-top.magenta { | |||
border-top: 3px solid #ffa3ef; | |||
} | |||
.stop-color.grey { | |||
stop-color: #bdd3e6; | |||
} | |||
.stop-color.light-grey { | |||
stop-color: #F0F4F7; | |||
} | |||
.stop-color.blue { | |||
stop-color: #5e64ff; | |||
} | |||
.stop-color.red { | |||
stop-color: #ff5858; | |||
} | |||
.stop-color.light-green { | |||
stop-color: #98d85b; | |||
} | |||
.stop-color.green { | |||
stop-color: #28a745; | |||
} | |||
.stop-color.orange { | |||
stop-color: #ffa00a; | |||
} | |||
.stop-color.violet { | |||
stop-color: #743ee2; | |||
} | |||
.stop-color.darkgrey { | |||
stop-color: #b8c2cc; | |||
} | |||
.stop-color.black { | |||
stop-color: #36414C; | |||
} | |||
.stop-color.yellow { | |||
stop-color: #FEEF72; | |||
} | |||
.stop-color.light-blue { | |||
stop-color: #7CD6FD; | |||
} | |||
.stop-color.purple { | |||
stop-color: #b554ff; | |||
} | |||
.stop-color.magenta { | |||
stop-color: #ffa3ef; | |||
} | |||
@@ -556,18 +556,6 @@ frappe.chart.AxisChart = class AxisChart extends frappe.chart.FrappeChart { | |||
this.animate_graphs(); | |||
// if(this.y[0].path) { | |||
// this.animate_paths(); | |||
// setTimeout(() => { | |||
// if(!this.updating) this.make_paths(); | |||
// }, 300) | |||
// } | |||
// this.animate_units(); | |||
// setTimeout(() => { | |||
// if(!this.updating) this.make_new_units(); | |||
// }, 300) | |||
// Trigger animation with the animatable elements in this.elements_to_animate | |||
this.run_animation(); | |||
@@ -1231,9 +1219,9 @@ frappe.chart.LineChart = class LineChart extends frappe.chart.AxisChart { | |||
function set_gradient_stop(grad_elem, offset, color, opacity) { | |||
$$.createSVG('stop', { | |||
'className': 'stop-color ' + color, | |||
'inside': grad_elem, | |||
'offset': offset, | |||
'stop-color': color, | |||
'stop-opacity': opacity | |||
}); | |||
} | |||
@@ -1393,7 +1381,7 @@ frappe.chart.PercentageChart = class PercentageChart extends frappe.chart.Frappe | |||
frappe.chart.HeatMap = class HeatMap extends frappe.chart.FrappeChart { | |||
constructor({ | |||
start = new Date(moment().subtract(1, 'year').toDate()), | |||
start = '', | |||
domain = '', | |||
subdomain = '', | |||
data = {}, | |||
@@ -1406,11 +1394,13 @@ frappe.chart.HeatMap = class HeatMap extends frappe.chart.FrappeChart { | |||
this.domain = domain; | |||
this.subdomain = subdomain; | |||
this.start = start; | |||
this.data = data; | |||
this.discrete_domains = discrete_domains; | |||
this.count_label = count_label; | |||
let today = new Date(); | |||
this.start = start || this.add_days(today, 365); | |||
this.legend_colors = ['#ebedf0', '#c6e48b', '#7bc96f', '#239a3b', '#196127']; | |||
this.translate_x = 0; | |||
@@ -1437,6 +1427,10 @@ frappe.chart.HeatMap = class HeatMap extends frappe.chart.FrappeChart { | |||
set_width() { | |||
this.base_width = (this.no_of_cols) * 12; | |||
if(this.discrete_domains) { | |||
this.base_width += (12 * 12); | |||
} | |||
} | |||
setup_components() { | |||