PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.8.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.8.0
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 1.2.0 1.2.1 All 78 releases
ablocks / includes / blocks / chart / attributes.php

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

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