1
0
mirror of https://github.com/tabler/tabler.git synced 2025-12-22 01:44:25 +04:00

homepage charts

This commit is contained in:
codecalm
2019-10-28 22:23:38 +01:00
parent 8588911b32
commit 1e9d17c1c2
20 changed files with 80 additions and 64 deletions

View File

@@ -72,7 +72,6 @@ if (window.Apex) {
dataLabels: { dataLabels: {
enabled: false, enabled: false,
offsetY: -6,
dropShadow: { dropShadow: {
enabled: false, enabled: false,
}, },
@@ -83,7 +82,6 @@ if (window.Apex) {
customScale: 1, customScale: 1,
expandOnClick: false, expandOnClick: false,
dataLabels: { dataLabels: {
offset: -8,
minAngleToShowLabel: 10, minAngleToShowLabel: 10,
}, },
}, },
@@ -145,6 +143,12 @@ if (window.Apex) {
colors: mutedColor, colors: mutedColor,
fontSize: '12px', fontSize: '12px',
}, },
datetimeFormatter: {
year: 'yyyy',
month: 'MMM \'yy',
day: 'd MMM',
hour: 'HH:mm'
}
}, },
tooltip: { tooltip: {
enabled: false, enabled: false,

View File

@@ -25,14 +25,14 @@ development-activity:
type: area type: area
groups: [1, 2, 3] groups: [1, 2, 3]
hide-points: true hide-points: true
hide-tooltip: true
remove-padding: true remove-padding: true
legend-position: 'top' legend-position: 'top'
sparkline: true sparkline: true
days-labels-count: 30
series: series:
- name: 'Purchases' - name: 'Purchases'
color: blue color: blue
data: [0, 5, 1, 2, 7, 5, 6, 8, 24, 7, 12, 5, 6, 3, 2, 2, 6, 30, 10, 10, 15, 14, 47, 65, 55] data: [3, 5, 4, 6, 7, 5, 6, 8, 24, 7, 12, 5, 6, 3, 8, 4, 14, 30, 17, 19, 15, 14, 25, 32, 40, 55, 60, 48, 52, 70]
line: line:
name: Employment Growth name: Employment Growth
@@ -256,6 +256,7 @@ donut:
name: Lorem ipsum name: Lorem ipsum
display: true display: true
type: donut type: donut
sparkline: true
hide-legend: true hide-legend: true
series: series:
- name: Maximum - name: Maximum

View File

@@ -1,7 +1,7 @@
{% assign chart-type = include.chart-type | default: 'line' %} {% assign chart-type = include.chart-type | default: 'line' %}
{% assign chart-position = include.chart-position | default: 'right' %} {% assign chart-position = include.chart-position | default: 'right' %}
<div class="card"> <div class="card">
<div class="card-body p-3 d-flex align-items-center leading-tight"> <div class="card-body p-3 d-flex align-items-center">
{% if include.icon %} {% if include.icon %}
<span class="{% if include.color %}bg-{{ include.color }} text-white{% endif %} stamp mr-3">{% include ui/icon.html icon=include.icon %}</span> <span class="{% if include.color %}bg-{{ include.color }} text-white{% endif %} stamp mr-3">{% include ui/icon.html icon=include.icon %}</span>
{% elsif include.person-id %} {% elsif include.person-id %}
@@ -21,7 +21,7 @@
{% include ui/icon.html icon=include.small-icon color=include.color class="icon-sm ml-1" %} {% include ui/icon.html icon=include.small-icon color=include.color class="icon-sm ml-1" %}
{% endif %} {% endif %}
</div> </div>
<div class="text-muted">{{ include.description | default: "Users" }}</div> <div class="text-muted text-h5">{{ include.description | default: "Users" }}</div>
</div> </div>
{% if include.second-icon %} {% if include.second-icon %}

View File

@@ -3,17 +3,17 @@
{% assign height = include.height %} {% assign height = include.height %}
{% if data %} {% if data %}
<div id="chart-{{ id }}"{% if include.class %} class="{{ include.class }}"{% endif %}{% if height %} style="height: {{ height }}rem"{% endif %}></div> <div id="chart-{{ id }}"{% if include.class %} class="{{ include.class }}"{% endif %}{% if height %} style="height: {% if height == '100%' %}100%{% else %}{{ height }}rem{% endif %}"{% endif %}></div>
{% capture_global scripts %} {% capture_global scripts %}
<script> <script>
document.addEventListener("DOMContentLoaded", function(event) { document.addEventListener("DOMContentLoaded", function(event) {
{% if jekyll.environment == 'development' %}window.tabler_chart = window.tabler_chart || {};{% endif %} {% if jekyll.environment == 'development' %}window.tabler_chart = window.tabler_chart || {};{% endif %}
var el; var chartElement = document.getElementById('chart-{{ id }}');
window.ApexCharts && ({% if jekyll.environment == 'development' %}window.tabler_chart["chart-{{ include.chart-id }}"] = {% endif %}new ApexCharts((el = document.getElementById('chart-{{ id }}')), { window.ApexCharts && ({% if jekyll.environment == 'development' %}window.tabler_chart["chart-{{ include.chart-id }}"] = {% endif %}new ApexCharts(chartElement, {
chart: { chart: {
type: '{{ data.type }}', type: '{{ data.type }}',
height: el.offsetHeight, height: chartElement.offsetHeight,
{% if data.sparkline %} {% if data.sparkline %}
sparkline: { sparkline: {
enabled: true enabled: true
@@ -61,7 +61,7 @@ document.addEventListener("DOMContentLoaded", function(event) {
{% if data.type == 'pie' or data.type == 'donut' %} {% if data.type == 'pie' or data.type == 'donut' %}
pie: { pie: {
height: el.offsetHeight height: chartElement.offsetHeight
}, },
{% endif %} {% endif %}
@@ -91,7 +91,7 @@ document.addEventListener("DOMContentLoaded", function(event) {
{% endif %} {% endif %}
{% if data.days-labels-count %} {% if data.days-labels-count %}
labels: [...Array({{ data.days-labels-count }}).keys()].map(n => `2019-05-${n+1}`), labels: [...Array({{ data.days-labels-count }}).keys()].map(n => `2019-09-${n+1}`),
{% endif %} {% endif %}
{% if data.rotated %} {% if data.rotated %}
@@ -132,6 +132,8 @@ document.addEventListener("DOMContentLoaded", function(event) {
}, },
{% endif %} {% endif %}
})).render(); })).render();
console.log('chartElement.offsetHeight', chartElement.offsetHeight);
}); });
</script> </script>
{% endcapture_global %} {% endcapture_global %}

View File

@@ -53,6 +53,7 @@
@import "vendor/selectize"; @import "vendor/selectize";
@import "vendor/jqvmap"; @import "vendor/jqvmap";
@import "vendor/apexcharts"; @import "vendor/apexcharts";
@import "vendor/sparkline";
@import "utils/border"; @import "utils/border";
@import "utils/background"; @import "utils/background";

View File

@@ -22,54 +22,3 @@
background-size: 14.14px 14.14px; background-size: 14.14px 14.14px;
} }
.sparkline {
position: relative;
width: 4rem;
height: 2.5rem;
line-height: 1;
}
.sparkline-square {
width: 2.5rem;
}
.sparkline-wide {
width: 6rem;
}
.sparkline-label {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: flex;
align-items: center;
justify-content: center;
font-size: px2rem(11px);
.icon {
width: 1rem;
height: 1rem;
}
}
// stylelint-disable declaration-no-important
.apexcharts-tooltip {
line-height: 1;
color: #fff;
background: $dark !important;
border: 0 !important;
border-radius: 3px !important;
}
.apexcharts-tooltip-title {
margin: 0 !important;
background: transparent !important;
border: 0 !important;
}
.apexcharts-tooltip-series-group {
padding: 0 8px !important;
}

View File

@@ -1,3 +1,31 @@
.apexcharts-title-text { .apexcharts-title-text {
font-weight: 600; font-weight: 600 !important;
}
.apexcharts-tooltip-title {
font-weight: 600 !important;
padding-bottom: .25rem !important;
}
.apexcharts-tooltip {
line-height: 1;
color: #fff;
background: $dark !important;
border: 0 !important;
border-radius: 3px !important;
}
.apexcharts-tooltip-title {
margin: 0 !important;
background: transparent !important;
border: 0 !important;
}
.apexcharts-tooltip-series-group {
padding: 0 8px !important;
}
.apexcharts-tooltip-marker {
width: .5rem;
height: .5rem;
} }

31
scss/vendor/_sparkline.scss vendored Normal file
View File

@@ -0,0 +1,31 @@
.sparkline {
position: relative;
width: 4rem;
height: 2.5rem;
line-height: 1;
}
.sparkline-square {
width: 2.5rem;
}
.sparkline-wide {
width: 6rem;
}
.sparkline-label {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: flex;
align-items: center;
justify-content: center;
font-size: px2rem(11px);
.icon {
width: 1rem;
height: 1rem;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB