PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.9.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.9.1
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
ablocks / includes / blocks / chart / attributes.php

attributes.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.9.1, at includes/blocks/chart/attributes.php

163 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 use ABlocks\Controls\Alignment;
8 use ABlocks\Controls\Range;
9
10 $attributes = [
11 'block_id' => array(
12 'type' => 'string',
13 'default' => '',
14 ),
15 'chartType' => [
16 'type' => 'string',
17 'default' => 'bar',
18 ],
19 'chartBG' => [
20 'type' => 'string',
21 'default' => '#fff',
22 ],
23 'data' => [
24 'type' => 'object',
25 'default' => [
26 'labels' => [ 'January', 'February', 'March', 'April', 'May', 'June' ],
27 'datasets' => [
28 [
29 'label' => 'Sales',
30 'data' => [ 300, 500, 200, 800, 700, 900 ],
31 'backgroundColor' => 'rgba(75, 192, 192, 0.6)',
32 'borderColor' => 'rgba(75, 192, 192, 1)',
33 'borderWidth' => 1,
34 'pointStyle' => 'star',
35 'pointRadius' => 8,
36 'pointHoverRadius' => 12,
37 ],
38 [
39 'label' => 'buys',
40 'data' => [ 400, 600, 300, 900, 800, 800 ],
41 'backgroundColor' => 'yellow',
42 'borderColor' => 'red',
43 'borderWidth' => 1,
44 'pointStyle' => 'triangle',
45 'pointRadius' => 8,
46 'pointHoverRadius' => 12,
47 ],
48 ],
49 ],
50 ],
51 'options' => [
52 'type' => 'object',
53 'default' => [
54 'responsive' => true,
55 'aspectRatio' => 1,
56 'maintainAspectRatio' => true,
57 'scales' => [
58 'x' => [
59 'ticks' => [
60 'color' => 'blue',
61 'font' => [
62 'size' => 14,
63 ],
64 ],
65 'grid' => [
66 'display' => true,
67 'color' => 'lightgray',
68 'lineWidth' => 1,
69 ],
70 'title' => [
71 'display' => true,
72 'text' => 'X-Axis Label',
73 'color' => 'darkblue',
74 'align' => 'center',
75 'font' => [
76 'size' => 16,
77 'weight' => 'bold',
78 ],
79 ],
80 ],
81 'y' => [
82 'ticks' => [
83 'color' => 'green',
84 'font' => [
85 'size' => 14,
86 ],
87 ],
88 'grid' => [
89 'display' => true,
90 'color' => 'gray',
91 'lineWidth' => 1,
92 ],
93 'title' => [
94 'display' => true,
95 'text' => 'Y-Axis Label',
96 'color' => 'darkgreen',
97 'align' => 'center',
98 'font' => [
99 'size' => 16,
100 'weight' => 'bold',
101 ],
102 ],
103 ],
104 ],
105 'plugins' => [
106 'legend' => [
107 'position' => 'top',
108 'labels' => [
109 'usePointStyle' => true,
110 ],
111 ],
112 'title' => [
113 'display' => true,
114 'text' => 'Monthly Sales',
115 'position' => 'top',
116 'align' => 'center',
117 'padding' => 10,
118 'font' => [
119 'size' => 20,
120 'weight' => 'bold',
121 ],
122 ],
123 'subtitle' => [
124 'display' => false,
125 'text' => 'Custom Chart Subtitle',
126 'position' => 'top',
127 'align' => 'center',
128 'padding' => 10,
129 'font' => [
130 'size' => 12,
131 'weight' => 'bold',
132 ],
133 ],
134 ],
135 ],
136 ],
137
138 ];
139
140 $attributes = array_merge(
141 $attributes,
142 Alignment::get_attribute( 'alignment', true, [ 'value' => 'left' ] ),
143 Range::get_attribute([
144 'attributeName' => 'chartHeight',
145 'attributeObjectKey' => 'value',
146 'isResponsive' => false,
147 'defaultValue' => 620,
148 'hasUnit' => true,
149 'unitDefaultValue' => 'px',
150 ]),
151 Range::get_attribute([
152 'attributeName' => 'chartWidth',
153 'attributeObjectKey' => 'value',
154 'isResponsive' => false,
155 'defaultValue' => 95,
156 'hasUnit' => true,
157 'unitDefaultValue' => '%',
158 ]),
159 );
160
161 return array_merge( $attributes, \ABlocks\Classes\BlockGlobal::get_attributes() );
162
163