Merge pull request 'Add chart line to display stock as well as price.' (#15) from feature/display-stock-in-chart into master
Reviewed-on: #15
This commit was merged in pull request #15.
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
<nav aria-label="breadcrumb" style="--bs-breadcrumb-divider: '>';" >
|
||||
<ol class="breadcrumb">
|
||||
{% for category in product.categories %}
|
||||
<li class="breadcrumb-item" aria-current="page"><a class="breadcrumb-item text-decoration-none" href="{{ path('app_category', {'category': category}) }}">{{ category }}</a></li></li>
|
||||
<li class="breadcrumb-item" aria-current="page"><a class="breadcrumb-item text-decoration-none" href="{{ path('app_category', {'category': category}) }}">{{ category }}</a></li>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
</nav>
|
||||
@@ -55,26 +55,32 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
|
||||
<script>
|
||||
const ctx = document.getElementById('price');
|
||||
const ctx = document.getElementById('price').getContext('2d');
|
||||
|
||||
new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: ['{{ price_dates|raw }}'],
|
||||
datasets: [{
|
||||
label: 'Price (PLN)',
|
||||
data: [{{ price_list }}],
|
||||
borderWidth: 1
|
||||
}]
|
||||
datasets: [
|
||||
{
|
||||
label: 'Price (PLN)',
|
||||
data: {{ price_list|raw }},
|
||||
yAxisID: 'yPrice',
|
||||
tension: 0.1,
|
||||
borderWidth: 1
|
||||
},
|
||||
{
|
||||
label: 'Stock (units)',
|
||||
data: {{ stock_list|raw }},
|
||||
yAxisID: 'yStock',
|
||||
tension: 0.1,
|
||||
borderWidth: 1
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
animation: false,
|
||||
plugins: {
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Price in time'
|
||||
},
|
||||
},
|
||||
scales: {
|
||||
x: {
|
||||
title: {
|
||||
@@ -82,13 +88,40 @@
|
||||
text: 'Date'
|
||||
}
|
||||
},
|
||||
y: {
|
||||
yPrice: {
|
||||
type: 'linear',
|
||||
position: 'left',
|
||||
beginAtZero: true,
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Price'
|
||||
text: 'Price (PLN)'
|
||||
},
|
||||
grid: {
|
||||
drawOnChartArea: false
|
||||
}
|
||||
},
|
||||
yStock: {
|
||||
type: 'linear',
|
||||
position: 'right',
|
||||
beginAtZero: true,
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Stock (units)'
|
||||
},
|
||||
grid: {
|
||||
drawOnChartArea: false
|
||||
}
|
||||
}
|
||||
},
|
||||
plugins: {
|
||||
legend: {
|
||||
display: true,
|
||||
position: 'top'
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Price and Stock in time'
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user