1
0
mirror of https://github.com/tabler/tabler.git synced 2026-07-28 14:04:38 +04:00

charts extend, new params

This commit is contained in:
codecalm
2019-12-19 22:47:40 +01:00
parent fb841faf02
commit ba1e1fefb4
4 changed files with 70 additions and 14 deletions
+27
View File
@@ -6,6 +6,33 @@ completion-tasks:
- name: Tasks completion - name: Tasks completion
data: [155, 65, 465, 265, 225, 325, 80] data: [155, 65, 465, 265, 225, 325, 80]
completion-tasks2:
extend: completion-tasks
type: line
completion-tasks3:
extend: completion-tasks
type: area
completion-tasks4:
extend: completion-tasks
stroke-curve: straight
type: line
completion-tasks5:
extend: completion-tasks
stroke-curve: stepline
type: line
completion-tasks6:
extend: completion-tasks
type: bar
horizontal: true
completion-tasks7:
extend: completion-tasks
type: line
datalabels: true
tasks-overview: tasks-overview:
type: bar type: bar
+22 -7
View File
@@ -1,7 +1,7 @@
{% assign data = site.data.charts[include.chart-id] %} {% assign data = site.data.charts[include.chart-id] %}
{% assign id = include.id | default: include.chart-id %} {% assign id = include.id | default: include.chart-id %}
{% assign height = include.height | default: 10 %} {% assign height = include.height | default: 10 %}
{% assign class = include.class | default: '' %} {% assign class = include.class %}
{% if include['size'] == 'sm' %} {% if include['size'] == 'sm' %}
{% assign class = class | append: ' chart-sm' | strip %} {% assign class = class | append: ' chart-sm' | strip %}
@@ -9,8 +9,11 @@
{% endif %} {% endif %}
{% if data %} {% if data %}
<div id="chart-{{ id }}" {% if class %} class="{{ class }}" {% endif %}{% if data.debug %} {% if data.extend %}
style="outline: 1px solid red" {% endif %}></div> {% assign data = site.data.charts[data.extend] | concat_objects: site.data.charts[include.chart-id] %}
{% endif %}
<div id="chart-{{ id }}" {% if class %} class="{{ class }}" {% endif %}{% if data.debug %} style="outline: 1px solid red" {% endif %}></div>
{% append_lib apexcharts %} {% append_lib apexcharts %}
{% capture script %} {% capture script %}
@@ -21,12 +24,10 @@
window.tabler_chart = window.tabler_chart || {}; window.tabler_chart = window.tabler_chart || {};
{% endif %} {% endif %}
window.ApexCharts && ({% if jekyll.environment == 'development' %} window.ApexCharts && ({% if jekyll.environment == 'development' %}window.tabler_chart["chart-{{ include.chart-id }}"] = {% endif %}new ApexCharts(document.getElementById('chart-{{ id }}'), {
window.tabler_chart["chart-{{ include.chart-id }}"] = {% endif %}
new ApexCharts(document.getElementById('chart-{{ id }}'), {
chart: { chart: {
type: "{{ data.type }}", type: "{{ data.type }}",
{% if data.title %} {% if data.title or data.type == "bar" or data.type == "line" %}
fontFamily: 'inherit', fontFamily: 'inherit',
{% endif %} {% endif %}
height: {{ height | times: 16 }}, height: {{ height | times: 16 }},
@@ -52,6 +53,20 @@
{% endif %} {% endif %}
}, },
{% if data.type == 'bar' and data.horizontal %}
plotOptions: {
bar: {
horizontal: true,
}
},
{% endif %}
{% if data.datalabels %}
dataLabels: {
enabled: true,
},
{% endif %}
fill: { fill: {
opacity: {% if data.type == 'area' %}.16{% else %}1{% endif %}, opacity: {% if data.type == 'area' %}.16{% else %}1{% endif %},
{% if data.type == 'area' %}type: 'solid'{% endif %} {% if data.type == 'area' %}type: 'solid'{% endif %}
+8
View File
@@ -80,6 +80,14 @@ module Jekyll
"rgb(#{r.hex}, #{g.hex}, #{b.hex})" "rgb(#{r.hex}, #{g.hex}, #{b.hex})"
end end
def concat_objects(object, object2)
if object and object2 and object.is_a?(Hash) and object2.is_a?(Hash)
return object.merge(object2)
end
object
end
def tabler_color(color, variation = false) def tabler_color(color, variation = false)
if variation if variation
color = color + '-' + variation color = color + '-' + variation
+13 -7
View File
@@ -3,13 +3,19 @@ tmp: true
--- ---
<div class="row"> <div class="row">
<div class="col-md-6 col-lg-4">
<div class="card"> {% assign charts = 'completion-tasks,completion-tasks2,completion-tasks3,completion-tasks4,completion-tasks5,completion-tasks6,completion-tasks7' | split: ',' %}
<div class="card-body"> {% for chart in charts %}
{% include ui/chart.html chart-id="completion-tasks" height=15 %} <div class="col-md-6 col-lg-4">
</div> <div class="card">
</div> <div class="card-body">
</div> {% include ui/chart.html chart-id=chart height=15 %}
</div>
</div>
</div>
{% endfor %}
<div class="col-12"> <div class="col-12">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">