matestack-ui-bootstrap 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +8 -0
- data/README.md +26 -0
- data/Rakefile +43 -0
- data/app/assets/images/avatar-placeholder.png +0 -0
- data/app/assets/images/icons/bootstrap-icons.svg +1 -0
- data/app/concepts/matestack/ui/bootstrap/apps/admin_template.rb +85 -0
- data/app/concepts/matestack/ui/bootstrap/components/accordion.rb +53 -0
- data/app/concepts/matestack/ui/bootstrap/components/alert.js +53 -0
- data/app/concepts/matestack/ui/bootstrap/components/alert.rb +34 -0
- data/app/concepts/matestack/ui/bootstrap/components/avatar.rb +27 -0
- data/app/concepts/matestack/ui/bootstrap/components/badge.rb +30 -0
- data/app/concepts/matestack/ui/bootstrap/components/breadcrumb.rb +46 -0
- data/app/concepts/matestack/ui/bootstrap/components/button.rb +54 -0
- data/app/concepts/matestack/ui/bootstrap/components/button_group.rb +36 -0
- data/app/concepts/matestack/ui/bootstrap/components/card.rb +100 -0
- data/app/concepts/matestack/ui/bootstrap/components/carousel.js +79 -0
- data/app/concepts/matestack/ui/bootstrap/components/carousel.rb +85 -0
- data/app/concepts/matestack/ui/bootstrap/components/chart.js +232 -0
- data/app/concepts/matestack/ui/bootstrap/components/chart.rb +71 -0
- data/app/concepts/matestack/ui/bootstrap/components/close.rb +30 -0
- data/app/concepts/matestack/ui/bootstrap/components/collapse.js +84 -0
- data/app/concepts/matestack/ui/bootstrap/components/collapse.rb +43 -0
- data/app/concepts/matestack/ui/bootstrap/components/dropdown.js +14 -0
- data/app/concepts/matestack/ui/bootstrap/components/dropdown.rb +116 -0
- data/app/concepts/matestack/ui/bootstrap/components/icon.rb +19 -0
- data/app/concepts/matestack/ui/bootstrap/components/list_group.rb +83 -0
- data/app/concepts/matestack/ui/bootstrap/components/modal.js +90 -0
- data/app/concepts/matestack/ui/bootstrap/components/modal.rb +106 -0
- data/app/concepts/matestack/ui/bootstrap/components/navbar.rb +120 -0
- data/app/concepts/matestack/ui/bootstrap/components/page_heading.rb +28 -0
- data/app/concepts/matestack/ui/bootstrap/components/pagination.rb +40 -0
- data/app/concepts/matestack/ui/bootstrap/components/popover.js +26 -0
- data/app/concepts/matestack/ui/bootstrap/components/popover.rb +92 -0
- data/app/concepts/matestack/ui/bootstrap/components/progress.rb +65 -0
- data/app/concepts/matestack/ui/bootstrap/components/scrollspy.rb +33 -0
- data/app/concepts/matestack/ui/bootstrap/components/section_card.rb +31 -0
- data/app/concepts/matestack/ui/bootstrap/components/spinner.rb +31 -0
- data/app/concepts/matestack/ui/bootstrap/components/tab_nav.rb +81 -0
- data/app/concepts/matestack/ui/bootstrap/components/tab_nav_content.rb +32 -0
- data/app/concepts/matestack/ui/bootstrap/components/toast.js +79 -0
- data/app/concepts/matestack/ui/bootstrap/components/toast.rb +99 -0
- data/app/concepts/matestack/ui/bootstrap/components/tooltip.js +26 -0
- data/app/concepts/matestack/ui/bootstrap/components/tooltip.rb +82 -0
- data/app/concepts/matestack/ui/bootstrap/content/collection/collection.rb +112 -0
- data/app/concepts/matestack/ui/bootstrap/content/collection/collection.scss +10 -0
- data/app/concepts/matestack/ui/bootstrap/content/collection/content.rb +101 -0
- data/app/concepts/matestack/ui/bootstrap/content/collection/filter.rb +33 -0
- data/app/concepts/matestack/ui/bootstrap/content/collection/paginate.rb +92 -0
- data/app/concepts/matestack/ui/bootstrap/content/figure.rb +7 -0
- data/app/concepts/matestack/ui/bootstrap/form/checkbox.rb +90 -0
- data/app/concepts/matestack/ui/bootstrap/form/date.js +38 -0
- data/app/concepts/matestack/ui/bootstrap/form/date.rb +98 -0
- data/app/concepts/matestack/ui/bootstrap/form/input.rb +123 -0
- data/app/concepts/matestack/ui/bootstrap/form/radio.rb +65 -0
- data/app/concepts/matestack/ui/bootstrap/form/select.haml +11 -0
- data/app/concepts/matestack/ui/bootstrap/form/select.rb +74 -0
- data/app/concepts/matestack/ui/bootstrap/form/submit.rb +20 -0
- data/app/concepts/matestack/ui/bootstrap/form/switch.rb +90 -0
- data/app/concepts/matestack/ui/bootstrap/layout/column.rb +47 -0
- data/app/concepts/matestack/ui/bootstrap/layout/container.rb +25 -0
- data/app/concepts/matestack/ui/bootstrap/layout/row.rb +15 -0
- data/app/concepts/matestack/ui/bootstrap/layout/sidebar.js +64 -0
- data/app/concepts/matestack/ui/bootstrap/layout/sidebar.rb +45 -0
- data/app/concepts/matestack/ui/bootstrap/layout/sidebar.scss +57 -0
- data/app/concepts/matestack/ui/bootstrap/pages/devise/sign_in.rb +40 -0
- data/app/concepts/matestack/ui/bootstrap/registry.rb +63 -0
- data/app/helpers/matestack/ui/bootstrap/application_helper.rb +13 -0
- data/app/javascript/matestack-ui-bootstrap/index.js +26 -0
- data/app/javascript/matestack-ui-bootstrap/stylesheets/matestack-ui-bootstrap.scss +65 -0
- data/app/javascript/packs/matestack-ui-bootstrap.js +2 -0
- data/config/routes.rb +2 -0
- data/config/webpack/development.js +5 -0
- data/config/webpack/environment.js +29 -0
- data/config/webpack/production.js +33 -0
- data/config/webpack/test.js +5 -0
- data/config/webpacker.yml +96 -0
- data/lib/matestack/ui/bootstrap.rb +27 -0
- data/lib/matestack/ui/bootstrap/engine.rb +26 -0
- data/lib/matestack/ui/bootstrap/version.rb +7 -0
- data/lib/tasks/matestack/ui/bootstrap_tasks.rake +66 -0
- metadata +137 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
class Matestack::Ui::Bootstrap::Components::ButtonGroup < Matestack::Ui::Component
|
2
|
+
|
3
|
+
optional class: { as: :bs_class }
|
4
|
+
optional label: { as: :bs_label }
|
5
|
+
optional :toolbar, :size, :vertical
|
6
|
+
|
7
|
+
def response
|
8
|
+
div buttongroup_attributes do
|
9
|
+
yield_components
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
def buttongroup_attributes
|
16
|
+
attributes = {}.tap do |hash|
|
17
|
+
hash[:class] = buttongroup_classes
|
18
|
+
hash[:attributes] = {
|
19
|
+
role: "#{toolbar ? :toolbar : :group}",
|
20
|
+
'aria-label': bs_label
|
21
|
+
}
|
22
|
+
end
|
23
|
+
html_attributes.merge(
|
24
|
+
attributes
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
def buttongroup_classes
|
29
|
+
[].tap do |classes|
|
30
|
+
classes << ("btn-#{toolbar ? :toolbar : :group}#{'-vertical' if vertical}")
|
31
|
+
classes << "btn-group-#{size}" if size.present?
|
32
|
+
classes << bs_class
|
33
|
+
end.join(' ').strip
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
class Matestack::Ui::Bootstrap::Components::Card < Matestack::Ui::Component
|
2
|
+
|
3
|
+
optional class: { as: :bs_class }
|
4
|
+
|
5
|
+
# header attributes, expects a hash or string
|
6
|
+
# possible keys `:class, :text`
|
7
|
+
optional :header
|
8
|
+
# footer attributes, expects a hash or string
|
9
|
+
# possible keys `:class, :text`
|
10
|
+
optional :footer
|
11
|
+
|
12
|
+
optional :title, :body, :subtitle # body attributes
|
13
|
+
optional :img_path, :img_pos, :alt_text # image attributes
|
14
|
+
|
15
|
+
optional :content_wrapper_class # class for content wrapper -> useful for content padding without affecting top image
|
16
|
+
|
17
|
+
optional :slots # passed in slots for card header or footer
|
18
|
+
|
19
|
+
def response
|
20
|
+
div card_attributes do
|
21
|
+
if header || slots && slots[:header]
|
22
|
+
header_partial
|
23
|
+
end
|
24
|
+
|
25
|
+
img_partial :top unless img_pos == :bottom
|
26
|
+
div class: content_wrapper_class do
|
27
|
+
body_partial if title || body || slots && slots[:body]
|
28
|
+
|
29
|
+
# custom body components
|
30
|
+
# needed a div otherwise it will be displayed below footer
|
31
|
+
div class: "p-3 pt-1" do yield_components end
|
32
|
+
|
33
|
+
img_partial :bottom if img_pos == :bottom
|
34
|
+
|
35
|
+
footer_partial if footer || slots && slots[:footer]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
|
42
|
+
def header_partial
|
43
|
+
header = self.header.is_a?(Hash) ? self.header : { text: self.header }
|
44
|
+
div class: "card-header #{header[:class]}" do
|
45
|
+
plain header[:text] if header[:text].present?
|
46
|
+
slot slots[:header] if slots && slots[:header]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def body_partial
|
51
|
+
div class: "card-body" do
|
52
|
+
# title
|
53
|
+
card_title(title, "card-title")
|
54
|
+
# subtitle
|
55
|
+
card_title(subtitle, 6, "card-subtitle text-muted")
|
56
|
+
# body
|
57
|
+
if body.is_a? Hash
|
58
|
+
paragraph class: "card-text #{body[:class]}", text: body[:text]
|
59
|
+
elsif body
|
60
|
+
paragraph class: "card-text", text: body
|
61
|
+
end
|
62
|
+
slot slots[:body] if slots && slots[:body]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def footer_partial
|
67
|
+
footer = self.footer.is_a?(Hash) ? self.footer : { text: self.footer }
|
68
|
+
div class: "card-footer #{footer[:class]}" do
|
69
|
+
plain footer[:text] if footer[:text].present?
|
70
|
+
slot slots[:footer] if slots && slots[:footer]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def img_partial pos
|
75
|
+
img class: "card-img-#{pos}", path: img_path, alt: alt_text if img_path.present?
|
76
|
+
end
|
77
|
+
|
78
|
+
def card_attributes
|
79
|
+
html_attributes.except(:title).merge(
|
80
|
+
class: card_classes
|
81
|
+
)
|
82
|
+
end
|
83
|
+
|
84
|
+
def card_classes
|
85
|
+
[].tap do |classes|
|
86
|
+
classes << 'card'
|
87
|
+
classes << bs_class
|
88
|
+
end.join(' ').strip
|
89
|
+
end
|
90
|
+
|
91
|
+
def card_title(options, default_size = 5, title_class)
|
92
|
+
if options.is_a? Hash
|
93
|
+
heading size: (options[:size] || default_size), class: "#{options[:class]} #{title_class}",
|
94
|
+
text: options[:text]
|
95
|
+
elsif options
|
96
|
+
heading size: default_size, class: title_class, text: options
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import * as bootstrap from 'bootstrap'
|
2
|
+
|
3
|
+
MatestackUiCore.Vue.component('matestack-ui-bootstrap-carousel', {
|
4
|
+
mixins: [MatestackUiCore.componentMixin],
|
5
|
+
data() {
|
6
|
+
return {
|
7
|
+
carouselInstance: undefined
|
8
|
+
};
|
9
|
+
},
|
10
|
+
|
11
|
+
methods: {
|
12
|
+
cycle: function(){
|
13
|
+
const self = this;
|
14
|
+
self.carouselInstance.cycle()
|
15
|
+
},
|
16
|
+
pause: function(){
|
17
|
+
const self = this;
|
18
|
+
self.carouselInstance.pause()
|
19
|
+
},
|
20
|
+
prev: function(){
|
21
|
+
const self = this;
|
22
|
+
self.carouselInstance.prev()
|
23
|
+
},
|
24
|
+
next: function(){
|
25
|
+
const self = this;
|
26
|
+
self.carouselInstance.next()
|
27
|
+
}
|
28
|
+
},
|
29
|
+
|
30
|
+
mounted: function() {
|
31
|
+
const self = this;
|
32
|
+
var myCarousel = self.$el;
|
33
|
+
self.carouselInstance = new bootstrap.Carousel(myCarousel, {
|
34
|
+
interval: (self.componentConfig['interval'] || 5000)
|
35
|
+
})
|
36
|
+
},
|
37
|
+
|
38
|
+
created: function() {
|
39
|
+
const self = this
|
40
|
+
if(self.componentConfig["cycle_on"] != undefined){
|
41
|
+
var cycle_events = self.componentConfig["cycle_on"].split(",")
|
42
|
+
cycle_events.forEach(cycle_event => MatestackUiCore.matestackEventHub.$on(cycle_event.trim(), self.cycle));
|
43
|
+
}
|
44
|
+
if(self.componentConfig["pause_on"] != undefined){
|
45
|
+
var pause_events = self.componentConfig["pause_on"].split(",")
|
46
|
+
pause_events.forEach(pause_event => MatestackUiCore.matestackEventHub.$on(pause_event.trim(), self.pause));
|
47
|
+
}
|
48
|
+
if(self.componentConfig["prev_on"] != undefined){
|
49
|
+
var prev_events = self.componentConfig["prev_on"].split(",")
|
50
|
+
prev_events.forEach(prev_event => MatestackUiCore.matestackEventHub.$on(prev_event.trim(), self.prev));
|
51
|
+
}
|
52
|
+
if(self.componentConfig["next_on"] != undefined){
|
53
|
+
var next_events = self.componentConfig["next_on"].split(",")
|
54
|
+
next_events.forEach(next_event => MatestackUiCore.matestackEventHub.$on(next_event.trim(), self.next));
|
55
|
+
}
|
56
|
+
},
|
57
|
+
|
58
|
+
beforeDestroy: function() {
|
59
|
+
const self = this
|
60
|
+
if(self.componentConfig["cycle_on"] != undefined){
|
61
|
+
var cycle_events = self.componentConfig["cycle_on"].split(",")
|
62
|
+
cycle_events.forEach(cycle_event => MatestackUiCore.matestackEventHub.$off(cycle_event.trim(), self.cycle));
|
63
|
+
}
|
64
|
+
|
65
|
+
if(self.componentConfig["pause_on"] != undefined){
|
66
|
+
var pause_events = self.componentConfig["pause_on"].split(",")
|
67
|
+
pause_events.forEach(pause_event => MatestackUiCore.matestackEventHub.$off(pause_event.trim(), self.pause));
|
68
|
+
}
|
69
|
+
|
70
|
+
if(self.componentConfig["prev_on"] != undefined){
|
71
|
+
var prev_events = self.componentConfig["prev_on"].split(",")
|
72
|
+
prev_events.forEach(prev_event => MatestackUiCore.matestackEventHub.$off(prev_event.trim(), self.prev));
|
73
|
+
}
|
74
|
+
if(self.componentConfig["next_on"] != undefined){
|
75
|
+
var next_events = self.componentConfig["next_on"].split(",")
|
76
|
+
next_events.forEach(next_event => MatestackUiCore.matestackEventHub.$off(next_event.trim(), self.next));
|
77
|
+
}
|
78
|
+
},
|
79
|
+
});
|
@@ -0,0 +1,85 @@
|
|
1
|
+
class Matestack::Ui::Bootstrap::Components::Carousel < Matestack::Ui::VueJsComponent
|
2
|
+
vue_js_component_name "matestack-ui-bootstrap-carousel"
|
3
|
+
|
4
|
+
optional :start, :controls, :indicators, :fade, :interval
|
5
|
+
optional :items, class: { as: :bs_class }
|
6
|
+
# possible keys for items: path, title, text, interval
|
7
|
+
# event trigger
|
8
|
+
optional :cycle_on, :pause_on, :prev_on, :next_on
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@component_config["carousel-id"] = carousel_id
|
12
|
+
end
|
13
|
+
|
14
|
+
def response
|
15
|
+
div carousel_attributes do
|
16
|
+
# carousel indicator
|
17
|
+
indicator_partial if indicators.present?
|
18
|
+
# carousel content
|
19
|
+
div class: "carousel-inner" do
|
20
|
+
yield_components
|
21
|
+
carousel_partial if items
|
22
|
+
end
|
23
|
+
controls_partial if controls
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def indicator_partial
|
30
|
+
ol class: "carousel-indicators" do
|
31
|
+
items.size.times do |index|
|
32
|
+
li data: { target: carousel_id, 'slide-to': index },
|
33
|
+
class: "#{'active' if index == (start || 0) }"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def carousel_partial
|
39
|
+
items.each_with_index do |item, index|
|
40
|
+
div class: "carousel-item #{'active' if index == (start || 0) } #{item[:class]}".strip,
|
41
|
+
data: { interval: item[:interval] } do
|
42
|
+
img class: "d-block w-100", path: item[:path]
|
43
|
+
if item[:title] || item[:text]
|
44
|
+
div class: "carousel-caption d-none d-md-block #{item[:title_class]}" do
|
45
|
+
heading size: 5, text: item[:title]
|
46
|
+
paragraph text: item[:text]
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def controls_partial
|
54
|
+
link class: "carousel-control-prev", path: "##{carousel_id}", data: { slide: :prev }, attributes: { 'role': "button" } do
|
55
|
+
span class: "carousel-control-prev-icon", attributes: { 'aria-hidden': "true" }
|
56
|
+
span class: "sr-only", text: "Previous"
|
57
|
+
end
|
58
|
+
link class: "carousel-control-next", path: "##{carousel_id}", data: { slide: :next }, attributes: { 'role': "button" } do
|
59
|
+
span class: "carousel-control-next-icon", attributes: { 'aria-hidden': "true" }
|
60
|
+
span class: "sr-only", text: "Next"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def carousel_attributes
|
65
|
+
html_attributes.merge(
|
66
|
+
id: carousel_id,
|
67
|
+
class: carousel_classes,
|
68
|
+
data: { ride: 'carousel', interval: (interval || 5000) }
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
def carousel_classes
|
73
|
+
[].tap do |classes|
|
74
|
+
classes << 'carousel slide'
|
75
|
+
classes << 'carousel-fade' if fade
|
76
|
+
#custom classes
|
77
|
+
classes << bs_class
|
78
|
+
end.join(' ').strip
|
79
|
+
end
|
80
|
+
|
81
|
+
def carousel_id
|
82
|
+
@carousel_id ||= "matestack-carousel-#{SecureRandom.hex}"
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,232 @@
|
|
1
|
+
import Chart from 'chart.js';
|
2
|
+
|
3
|
+
MatestackUiCore.Vue.component('matestack-ui-bootstrap-chart', {
|
4
|
+
mixins: [MatestackUiCore.componentMixin],
|
5
|
+
|
6
|
+
data() {
|
7
|
+
return {
|
8
|
+
chartJsInstance: undefined,
|
9
|
+
defaultColor: undefined,
|
10
|
+
fontColor: undefined,
|
11
|
+
fontFamily: undefined
|
12
|
+
};
|
13
|
+
},
|
14
|
+
|
15
|
+
methods: {
|
16
|
+
getThemeColor: function(key){
|
17
|
+
const style = getComputedStyle(document.body);
|
18
|
+
return style.getPropertyValue('--bs-'+key);
|
19
|
+
},
|
20
|
+
getThemeColorArray: function(keysArray){
|
21
|
+
let result = []
|
22
|
+
const style = getComputedStyle(document.body);
|
23
|
+
keysArray.forEach(function(key){
|
24
|
+
result.push(style.getPropertyValue('--bs-'+key))
|
25
|
+
})
|
26
|
+
return result;
|
27
|
+
},
|
28
|
+
drawBarChart: function(chartElement){
|
29
|
+
const self = this;
|
30
|
+
this.componentConfig["datasets"].forEach(function(item){
|
31
|
+
if (item["backgroundColor"] === undefined){
|
32
|
+
item["backgroundColor"] = self.getThemeColor("primary")
|
33
|
+
}else{
|
34
|
+
if(Array.isArray(item["backgroundColor"])){
|
35
|
+
item["backgroundColor"] = self.getThemeColorArray(item["backgroundColor"])
|
36
|
+
}else{
|
37
|
+
item["backgroundColor"] = self.getThemeColor(item["backgroundColor"])
|
38
|
+
}
|
39
|
+
}
|
40
|
+
item["hoverBackgroundColor"] = "rgba(0, 0, 0, 0.1)"
|
41
|
+
if (item["barThickness"] === undefined){
|
42
|
+
item["barThickness"] = 10;
|
43
|
+
}
|
44
|
+
})
|
45
|
+
this.chartJsInstance = new Chart(chartElement, {
|
46
|
+
type: 'bar',
|
47
|
+
data: {
|
48
|
+
labels: this.componentConfig["labels"],
|
49
|
+
datasets: this.componentConfig["datasets"]
|
50
|
+
},
|
51
|
+
options: {
|
52
|
+
legend: {
|
53
|
+
display: this.componentConfig["display_legend"],
|
54
|
+
},
|
55
|
+
scales: {
|
56
|
+
yAxes: [{
|
57
|
+
display: this.componentConfig["display_y_axes"],
|
58
|
+
gridLines: {
|
59
|
+
display: false,
|
60
|
+
},
|
61
|
+
ticks: {
|
62
|
+
beginAtZero: true
|
63
|
+
}
|
64
|
+
}],
|
65
|
+
xAxes: [{
|
66
|
+
display: this.componentConfig["display_x_axes"],
|
67
|
+
gridLines: {
|
68
|
+
display: false,
|
69
|
+
},
|
70
|
+
ticks: {
|
71
|
+
beginAtZero: true
|
72
|
+
}
|
73
|
+
}]
|
74
|
+
}
|
75
|
+
}
|
76
|
+
});
|
77
|
+
},
|
78
|
+
drawLineChart: function(chartElement){
|
79
|
+
const self = this;
|
80
|
+
this.componentConfig["datasets"].forEach(function(item){
|
81
|
+
if (item["borderColor"] === undefined){
|
82
|
+
item["borderColor"] = self.getThemeColor("primary")
|
83
|
+
}else{
|
84
|
+
item["borderColor"] = self.getThemeColor(item["borderColor"])
|
85
|
+
}
|
86
|
+
item["hoverBackgroundColor"] = "rgba(0, 0, 0, 0.1)"
|
87
|
+
if (item["fill"] === undefined){
|
88
|
+
item["fill"] = false;
|
89
|
+
}
|
90
|
+
})
|
91
|
+
this.chartJsInstance = new Chart(chartElement, {
|
92
|
+
type: 'line',
|
93
|
+
data: {
|
94
|
+
labels: this.componentConfig["labels"],
|
95
|
+
datasets: this.componentConfig["datasets"]
|
96
|
+
},
|
97
|
+
options: {
|
98
|
+
legend: {
|
99
|
+
display: this.componentConfig["display_legend"],
|
100
|
+
},
|
101
|
+
scales: {
|
102
|
+
yAxes: [{
|
103
|
+
display: this.componentConfig["display_y_axes"],
|
104
|
+
gridLines: {
|
105
|
+
display: false,
|
106
|
+
},
|
107
|
+
ticks: {
|
108
|
+
beginAtZero: true
|
109
|
+
}
|
110
|
+
}],
|
111
|
+
xAxes: [{
|
112
|
+
display: this.componentConfig["display_x_axes"],
|
113
|
+
gridLines: {
|
114
|
+
display: false,
|
115
|
+
},
|
116
|
+
ticks: {
|
117
|
+
beginAtZero: true
|
118
|
+
}
|
119
|
+
}]
|
120
|
+
}
|
121
|
+
}
|
122
|
+
});
|
123
|
+
},
|
124
|
+
drawDoughnutChart: function(chartElement){
|
125
|
+
const self = this;
|
126
|
+
this.componentConfig["datasets"].forEach(function(item){
|
127
|
+
if (item["backgroundColor"] === undefined){
|
128
|
+
item["backgroundColor"] = self.getThemeColor("primary")
|
129
|
+
}else{
|
130
|
+
if(Array.isArray(item["backgroundColor"])){
|
131
|
+
item["backgroundColor"] = self.getThemeColorArray(item["backgroundColor"])
|
132
|
+
}else{
|
133
|
+
item["backgroundColor"] = self.getThemeColor(item["backgroundColor"])
|
134
|
+
}
|
135
|
+
}
|
136
|
+
item["hoverBackgroundColor"] = "rgba(0, 0, 0, 0.1)"
|
137
|
+
if (item["borderColor"] === undefined){
|
138
|
+
item["borderColor"] = self.getThemeColor("white")
|
139
|
+
}else{
|
140
|
+
item["borderColor"] = self.getThemeColor(item["borderColor"])
|
141
|
+
}
|
142
|
+
if (item["hoverBorderColor"] === undefined){
|
143
|
+
item["hoverBorderColor"] = self.getThemeColor("white")
|
144
|
+
}else{
|
145
|
+
item["hoverBorderColor"] = self.getThemeColor(item["hoverBorderColor"])
|
146
|
+
}
|
147
|
+
if (item["borderWidth"] === undefined){
|
148
|
+
item["borderWidth"] = 10
|
149
|
+
}
|
150
|
+
if (item["weight"] === undefined){
|
151
|
+
item["weight"] = 1
|
152
|
+
}
|
153
|
+
})
|
154
|
+
this.chartJsInstance = new Chart(chartElement, {
|
155
|
+
type: 'doughnut',
|
156
|
+
data: {
|
157
|
+
labels: this.componentConfig["labels"],
|
158
|
+
datasets: this.componentConfig["datasets"]
|
159
|
+
},
|
160
|
+
options: {
|
161
|
+
legend: {
|
162
|
+
display: this.componentConfig["display_legend"],
|
163
|
+
},
|
164
|
+
cutoutPercentage: this.componentConfig["cutout_percentage"]
|
165
|
+
}
|
166
|
+
});
|
167
|
+
},
|
168
|
+
drawPieChart: function(chartElement){
|
169
|
+
const self = this;
|
170
|
+
this.componentConfig["datasets"].forEach(function(item){
|
171
|
+
if (item["backgroundColor"] === undefined){
|
172
|
+
item["backgroundColor"] = self.getThemeColor("primary")
|
173
|
+
}else{
|
174
|
+
if(Array.isArray(item["backgroundColor"])){
|
175
|
+
item["backgroundColor"] = self.getThemeColorArray(item["backgroundColor"])
|
176
|
+
}else{
|
177
|
+
item["backgroundColor"] = self.getThemeColor(item["backgroundColor"])
|
178
|
+
}
|
179
|
+
}
|
180
|
+
item["hoverBackgroundColor"] = "rgba(0, 0, 0, 0.1)"
|
181
|
+
})
|
182
|
+
this.chartJsInstance = new Chart(chartElement, {
|
183
|
+
type: 'pie',
|
184
|
+
data: {
|
185
|
+
labels: this.componentConfig["labels"],
|
186
|
+
datasets: this.componentConfig["datasets"]
|
187
|
+
},
|
188
|
+
options: {
|
189
|
+
legend: {
|
190
|
+
display: this.componentConfig["display_legend"],
|
191
|
+
}
|
192
|
+
}
|
193
|
+
});
|
194
|
+
},
|
195
|
+
},
|
196
|
+
|
197
|
+
mounted: function() {
|
198
|
+
const style = getComputedStyle(document.body);
|
199
|
+
|
200
|
+
this.defaultColor = style.getPropertyValue('--bs-primary');
|
201
|
+
this.fontColor = style.getPropertyValue('--bs-secondary');
|
202
|
+
this.fontFamily = style.getPropertyValue('--bs-font-sans-serif');
|
203
|
+
|
204
|
+
Chart.defaults.global.defaultFontColor = this.fontColor
|
205
|
+
Chart.defaults.global.defaultFontFamily = this.fontFamily
|
206
|
+
Chart.defaults.global.defaultColor = this.fontFamily
|
207
|
+
|
208
|
+
const chartElement = this.$refs.chart
|
209
|
+
|
210
|
+
if(this.componentConfig["type"] == "bar"){
|
211
|
+
this.drawBarChart(chartElement);
|
212
|
+
}
|
213
|
+
if(this.componentConfig["type"] == "line"){
|
214
|
+
this.drawLineChart(chartElement);
|
215
|
+
}
|
216
|
+
if(this.componentConfig["type"] == "doughnut"){
|
217
|
+
this.drawDoughnutChart(chartElement);
|
218
|
+
}
|
219
|
+
if(this.componentConfig["type"] == "pie"){
|
220
|
+
this.drawPieChart(chartElement);
|
221
|
+
}
|
222
|
+
|
223
|
+
},
|
224
|
+
|
225
|
+
created: function() {
|
226
|
+
|
227
|
+
},
|
228
|
+
|
229
|
+
beforeDestroy: function() {
|
230
|
+
|
231
|
+
},
|
232
|
+
});
|