From beff8d6b8f89530c67a95abf43852df238f7e126 Mon Sep 17 00:00:00 2001 From: Malebestia Date: Fri, 1 Sep 2023 16:06:14 +0200 Subject: [PATCH 1/8] Initial commit --- .gitignore | 23 +++++++++++++++++++++++ LICENSE | 21 +++++++++++++++++++++ README.md | 1 + 3 files changed, 45 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..297959a19 --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ +/vendor/ +node_modules/ +npm-debug.log +yarn-error.log + +# Laravel 4 specific +bootstrap/compiled.php +app/storage/ + +# Laravel 5 & Lumen specific +public/storage +public/hot + +# Laravel 5 & Lumen specific with changed public path +public_html/storage +public_html/hot + +storage/*.key +.env +Homestead.yaml +Homestead.json +/.vagrant +.phpunit.result.cache diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..4369e2ab1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 laraxot + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 000000000..a6e9f788a --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# module_chart_fila3 \ No newline at end of file From 2d3ea1ca61a37e8c6c3a149d394f89fd89d0c115 Mon Sep 17 00:00:00 2001 From: marco76tv Date: Mon, 4 Sep 2023 09:11:25 +0000 Subject: [PATCH 2/8] Dusting --- .php-cs-fixer.cache | 2 +- Actions/JpGraph/ApplyGraphStyleAction.php | 4 ++-- Actions/JpGraph/ApplyPlotStyleAction.php | 4 ++-- Actions/JpGraph/GetGraphAction.php | 2 +- Actions/JpGraph/V1/Bar2Action.php | 7 ++++--- Actions/JpGraph/V1/Bar3Action.php | 3 ++- Actions/JpGraph/V1/Horizbar1Action.php | 2 +- Actions/JpGraph/V1/Pie1Action.php | 5 +++-- Actions/JpGraph/V1/PieAvgAction.php | 9 +++++---- Datas/AnswersChartData.php | 11 ++++++----- Models/Chart.php | 9 +++++---- Tables/Columns/ChartColumn.php | 2 ++ docs/config.php | 1 + phpinsights.php | 12 +++++------- 14 files changed, 40 insertions(+), 33 deletions(-) diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache index 15672e814..bfef08c1b 100644 --- a/.php-cs-fixer.cache +++ b/.php-cs-fixer.cache @@ -1 +1 @@ -{"php":"8.2.9","version":"3.22.0","indent":" ","lineEnding":"\n","rules":{"align_multiline_comment":true,"array_syntax":{"syntax":"short"},"backtick_to_shell_exec":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["return"]},"cast_spaces":true,"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":true,"class_reference_name_casing":true,"clean_namespace":true,"concat_space":true,"curly_braces_position":{"allow_single_line_anonymous_functions":true,"allow_single_line_empty_anonymous_classes":true},"declare_parentheses":true,"echo_tag_syntax":true,"empty_loop_body":{"style":"braces"},"empty_loop_condition":true,"fully_qualified_strict_types":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"global_namespace_import":{"import_classes":false,"import_constants":false,"import_functions":false},"include":true,"increment_style":true,"integer_literal_case":true,"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":{"on_multiline":"ignore"},"native_function_casing":true,"native_function_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["attribute","case","continue","curly_brace_block","default","extra","parenthesis_brace_block","square_brace_block","switch","throw","use"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_null_property_initialization":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"remove_inheritdoc":true},"no_trailing_comma_in_singleline":true,"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","others","return","switch_case","yield","yield_from"]},"no_unneeded_curly_braces":{"namespaces":true},"no_unneeded_import_alias":true,"no_unset_cast":true,"no_unused_imports":true,"no_useless_concat_operator":true,"no_useless_nullsafe_operator":true,"no_whitespace_before_comma_in_array":true,"normalize_index_brace":true,"nullable_type_declaration_for_default_null_value":{"use_nullable_type_declaration":false},"object_operator_without_whitespace":true,"operator_linebreak":{"only_booleans":true},"ordered_imports":true,"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_order":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"semicolon_after_instruction":true,"simple_to_complex_string_variable":true,"single_class_element_per_statement":true,"single_import_per_statement":true,"single_line_comment_spacing":true,"single_line_comment_style":{"comment_types":["hash"]},"single_line_throw":true,"single_quote":true,"single_space_around_construct":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"switch_continue_to_break":true,"trailing_comma_in_multiline":true,"trim_array_spaces":true,"type_declaration_spaces":true,"types_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":true,"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"return_type_declaration":true,"short_scalar_cast":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_line_after_imports":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_indentation":true,"function_typehint_space":true,"declare_strict_types":true,"combine_consecutive_unsets":true,"not_operator_with_successor_space":true,"braces":{"position_after_functions_and_oop_constructs":"same"}},"hashes":{"Models\/Chart.php":"e1a0bfb3276bda149e70a4b0fb2acd76","Models\/BaseModel.php":"a5e5fac12535033db8d5861703e99519","Models\/MixedChart.php":"7867dfb1b803e374d13cd3a97d9e59fb","Providers\/RouteServiceProvider.php":"c62b9048288ce5bf3cd9e487014582c6","Providers\/ChartServiceProvider.php":"382e54a95faa1de143c4c36967305e30","Actions\/Chart\/GetTypeOptions.php":"1977c9cce4a478e7026d6e79702a25d1","Actions\/Chart\/GetFontFamilyOptions.php":"3c7b5576bf288b7cc8b7cf77885ffe5b","Actions\/Chart\/GetFontStyleOptions.php":"0e3183628f3e8e7a81c90c8c72861750","Actions\/JpGraph\/ApplyGraphStyleAction.php":"4520c1aeaaf48eacc0b862eab5e9f09d","Actions\/JpGraph\/V1\/Bar2Action.php":"a5b3759333579e2a397486f4b1f00a7a","Actions\/JpGraph\/V1\/Horizbar1Action.php":"51c9acacfe45372e4d7fe8c64248df2b","Actions\/JpGraph\/V1\/PieAvgAction.php":"0ff2a347e36ae6511173bd6d005bc0b8","Actions\/JpGraph\/V1\/Bar3Action.php":"911d8b152a2d35fbbe32ff40e3bdd6aa","Actions\/JpGraph\/V1\/Pie1Action.php":"6c63693ba738cf06aa70dc5983db6e51","Actions\/JpGraph\/V1\/LineSubQuestionAction.php":"32a00d6aa31be891d327e15a0f891f5b","Actions\/JpGraph\/GetGraphAction.php":"a90c2fbcf920fe4c8c44642688b52cdf","Actions\/JpGraph\/ApplyPlotStyleAction.php":"b64d4ebd5ba250d0a2e4696edde6923b","Datas\/AnswerData.php":"d8966e9e66da960868a02d8543286de9","Datas\/AnswersChartData.php":"f0a875671bfa5c376ee7c412f01c1d8c","Datas\/ChartData.php":"1802002cd1008c0be28ccbbc0c99da31","Tables\/Columns\/ChartColumn.php":"3c227257f39138235d1a9f1ba0ae9aa0","docs\/config.php":"a797f4b644f37748cceff11c2ce84559","docs\/config.production.php":"0389bfdb2066feea5487831e25c2aa1b","docs\/navigation.php":"4b48df06bfed09cf256c9ffa7a2346c0","docs\/bootstrap.php":"08c7c136892cf6aadd94bcdb6f64ca34","docs\/listeners\/GenerateSitemap.php":"47198e7919271856d36b88e921c7d3eb","Database\/Seeders\/ChartDatabaseSeeder.php":"e9a0cbed13c138e24cd6a3d2722d2507","Database\/Factories\/ChartFactory.php":"a52492954bc2000b2a3f223ba92f5ae2","Database\/Factories\/MixedChartFactory.php":"94a428c20b3c40b93a285610d4338559","Routes\/web.php":"d8b57a2739d10acaa69603aca186a4f7","Routes\/api.php":"905e49cc806f2d11cc4698d1532d7b04","Config\/config.php":"24af6b51b9bb0cb3795f130d93ec5bd3","phpinsights.php":"a903fc759ac88dad061accf0899a2622"}} \ No newline at end of file +{"php":"8.2.10","version":"3.25.0","indent":" ","lineEnding":"\n","rules":{"align_multiline_comment":true,"array_syntax":{"syntax":"short"},"backtick_to_shell_exec":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["return"]},"cast_spaces":true,"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":true,"class_reference_name_casing":true,"clean_namespace":true,"concat_space":true,"curly_braces_position":{"allow_single_line_anonymous_functions":true,"allow_single_line_empty_anonymous_classes":true},"declare_parentheses":true,"echo_tag_syntax":true,"empty_loop_body":{"style":"braces"},"empty_loop_condition":true,"fully_qualified_strict_types":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"global_namespace_import":{"import_classes":false,"import_constants":false,"import_functions":false},"include":true,"increment_style":true,"integer_literal_case":true,"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":{"on_multiline":"ignore"},"native_function_casing":true,"native_function_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["attribute","case","continue","curly_brace_block","default","extra","parenthesis_brace_block","square_brace_block","switch","throw","use"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_null_property_initialization":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"remove_inheritdoc":true},"no_trailing_comma_in_singleline":true,"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","others","return","switch_case","yield","yield_from"]},"no_unneeded_curly_braces":{"namespaces":true},"no_unneeded_import_alias":true,"no_unset_cast":true,"no_unused_imports":true,"no_useless_concat_operator":true,"no_useless_nullsafe_operator":true,"no_whitespace_before_comma_in_array":true,"normalize_index_brace":true,"nullable_type_declaration_for_default_null_value":{"use_nullable_type_declaration":false},"object_operator_without_whitespace":true,"operator_linebreak":{"only_booleans":true},"ordered_imports":true,"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_order":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"semicolon_after_instruction":true,"simple_to_complex_string_variable":true,"single_class_element_per_statement":true,"single_import_per_statement":true,"single_line_comment_spacing":true,"single_line_comment_style":{"comment_types":["hash"]},"single_line_throw":true,"single_quote":true,"single_space_around_construct":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"switch_continue_to_break":true,"trailing_comma_in_multiline":true,"trim_array_spaces":true,"type_declaration_spaces":true,"types_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":true,"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"return_type_declaration":true,"short_scalar_cast":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_indentation":true,"function_typehint_space":true,"declare_strict_types":true,"combine_consecutive_unsets":true,"not_operator_with_successor_space":true,"braces":{"position_after_functions_and_oop_constructs":"same"}},"hashes":{"Database\/Seeders\/ChartDatabaseSeeder.php":"e9a0cbed13c138e24cd6a3d2722d2507","Database\/Factories\/MixedChartFactory.php":"94a428c20b3c40b93a285610d4338559","Database\/Factories\/ChartFactory.php":"a52492954bc2000b2a3f223ba92f5ae2","phpinsights.php":"a903fc759ac88dad061accf0899a2622","Config\/config.php":"24af6b51b9bb0cb3795f130d93ec5bd3","docs\/config.production.php":"0389bfdb2066feea5487831e25c2aa1b","docs\/bootstrap.php":"08c7c136892cf6aadd94bcdb6f64ca34","docs\/listeners\/GenerateSitemap.php":"47198e7919271856d36b88e921c7d3eb","docs\/navigation.php":"4b48df06bfed09cf256c9ffa7a2346c0","docs\/config.php":"9e368edbeff720f8f929e3f83bf443b7","Datas\/ChartData.php":"1802002cd1008c0be28ccbbc0c99da31","Datas\/AnswersChartData.php":"f0a875671bfa5c376ee7c412f01c1d8c","Datas\/AnswerData.php":"d8966e9e66da960868a02d8543286de9","Providers\/RouteServiceProvider.php":"c62b9048288ce5bf3cd9e487014582c6","Providers\/ChartServiceProvider.php":"382e54a95faa1de143c4c36967305e30","Tables\/Columns\/ChartColumn.php":"bc89dac863afe46ac771a2947eeffa3f","Actions\/Chart\/GetFontStyleOptions.php":"0e3183628f3e8e7a81c90c8c72861750","Actions\/Chart\/GetFontFamilyOptions.php":"3c7b5576bf288b7cc8b7cf77885ffe5b","Actions\/Chart\/GetTypeOptions.php":"1977c9cce4a478e7026d6e79702a25d1","Actions\/JpGraph\/V1\/PieAvgAction.php":"0ff2a347e36ae6511173bd6d005bc0b8","Actions\/JpGraph\/V1\/Horizbar1Action.php":"51c9acacfe45372e4d7fe8c64248df2b","Actions\/JpGraph\/V1\/Bar2Action.php":"a5b3759333579e2a397486f4b1f00a7a","Actions\/JpGraph\/V1\/LineSubQuestionAction.php":"32a00d6aa31be891d327e15a0f891f5b","Actions\/JpGraph\/V1\/Pie1Action.php":"6c63693ba738cf06aa70dc5983db6e51","Actions\/JpGraph\/V1\/Bar3Action.php":"911d8b152a2d35fbbe32ff40e3bdd6aa","Actions\/JpGraph\/ApplyPlotStyleAction.php":"b64d4ebd5ba250d0a2e4696edde6923b","Actions\/JpGraph\/GetGraphAction.php":"a90c2fbcf920fe4c8c44642688b52cdf","Actions\/JpGraph\/ApplyGraphStyleAction.php":"4520c1aeaaf48eacc0b862eab5e9f09d","Models\/MixedChart.php":"7867dfb1b803e374d13cd3a97d9e59fb","Models\/BaseModel.php":"a5e5fac12535033db8d5861703e99519","Models\/Chart.php":"e1a0bfb3276bda149e70a4b0fb2acd76","Routes\/web.php":"d8b57a2739d10acaa69603aca186a4f7","Routes\/api.php":"905e49cc806f2d11cc4698d1532d7b04"}} \ No newline at end of file diff --git a/Actions/JpGraph/ApplyGraphStyleAction.php b/Actions/JpGraph/ApplyGraphStyleAction.php index fb002e812..e1ddea80b 100644 --- a/Actions/JpGraph/ApplyGraphStyleAction.php +++ b/Actions/JpGraph/ApplyGraphStyleAction.php @@ -22,10 +22,10 @@ public function execute(Graph &$graph, ChartData $chart): Graph $graph->footer->right->SetFont($chart->font_family, $chart->font_style); // $graph->footer->right->Set('Totale Risposte '.$this->vars['tot']); - if ($graph->xaxis !== null) { + if (null !== $graph->xaxis) { $this->applyGraphXStyle($graph->xaxis, $chart); } - if ($graph->yaxis !== null) { + if (null !== $graph->yaxis) { $this->applyGraphYStyle($graph->yaxis, $chart); } diff --git a/Actions/JpGraph/ApplyPlotStyleAction.php b/Actions/JpGraph/ApplyPlotStyleAction.php index 5e4a021c8..0b4308e94 100644 --- a/Actions/JpGraph/ApplyPlotStyleAction.php +++ b/Actions/JpGraph/ApplyPlotStyleAction.php @@ -42,7 +42,7 @@ public function execute(BarPlot $plot, ChartData $data): BarPlot $plot->value->SetAlign('left', 'center'); // colore del font che scrivi - if ($data->plot_value_color !== null) { + if (null !== $data->plot_value_color) { $plot->value->SetColor($data->plot_value_color); } else { $plot->value->SetColor('black', 'darkred'); @@ -67,7 +67,7 @@ public function execute(BarPlot $plot, ChartData $data): BarPlot // Center the values in the bar // if (null == $data->plot_value_pos || 0 == $data->plot_value_pos) { - if ($data->plot_value_pos === 0) { + if (0 === $data->plot_value_pos) { $plot->SetValuePos('center'); } diff --git a/Actions/JpGraph/GetGraphAction.php b/Actions/JpGraph/GetGraphAction.php index d5ebf5a23..b4a865e44 100644 --- a/Actions/JpGraph/GetGraphAction.php +++ b/Actions/JpGraph/GetGraphAction.php @@ -19,7 +19,7 @@ public function execute(ChartData $data): Graph $graph = new Graph($data->width, $data->height, 'auto'); $graph->SetScale('textlin'); $graph->SetShadow(); - $theme_class = new UniversalTheme(); + $theme_class = new UniversalTheme; $graph->SetTheme($theme_class); diff --git a/Actions/JpGraph/V1/Bar2Action.php b/Actions/JpGraph/V1/Bar2Action.php index e3c8d0024..fa760c295 100644 --- a/Actions/JpGraph/V1/Bar2Action.php +++ b/Actions/JpGraph/V1/Bar2Action.php @@ -8,12 +8,13 @@ use Amenadiel\JpGraph\Plot\BarPlot; use Amenadiel\JpGraph\Plot\GroupBarPlot; use Amenadiel\JpGraph\Text\Text; -use function count; use Modules\Chart\Actions\JpGraph\ApplyPlotStyleAction; use Modules\Chart\Actions\JpGraph\GetGraphAction; use Modules\Chart\Datas\AnswersChartData; use Spatie\QueueableAction\QueueableAction; +use function count; + class Bar2Action { use QueueableAction; @@ -62,7 +63,7 @@ public function execute(AnswersChartData $answerChartData): Graph $bplot = []; foreach ($legends as $i => $legend) { - if ($legend === 0) { + if (0 === $legend) { $tmp_data = $data; } else { $tmp_data = array_column($data, $legend); @@ -81,7 +82,7 @@ public function execute(AnswersChartData $answerChartData): Graph $tmp->SetLegend($str); } */ - if ($legend !== 0) { + if (0 !== $legend) { $tmp->SetLegend($legend); } diff --git a/Actions/JpGraph/V1/Bar3Action.php b/Actions/JpGraph/V1/Bar3Action.php index 7fbd5c6c8..e228c9d63 100644 --- a/Actions/JpGraph/V1/Bar3Action.php +++ b/Actions/JpGraph/V1/Bar3Action.php @@ -8,7 +8,6 @@ use Amenadiel\JpGraph\Plot\AccBarPlot; use Amenadiel\JpGraph\Plot\BarPlot; use Amenadiel\JpGraph\Text\Text; -use function count; use Modules\Chart\Actions\JpGraph\ApplyPlotStyleAction; use Modules\Chart\Actions\JpGraph\GetGraphAction; use Modules\Chart\Datas\AnswerData; @@ -16,6 +15,8 @@ use Spatie\QueueableAction\QueueableAction; use Webmozart\Assert\Assert; +use function count; + class Bar3Action { use QueueableAction; diff --git a/Actions/JpGraph/V1/Horizbar1Action.php b/Actions/JpGraph/V1/Horizbar1Action.php index fea8d1c02..bd2ba45f7 100644 --- a/Actions/JpGraph/V1/Horizbar1Action.php +++ b/Actions/JpGraph/V1/Horizbar1Action.php @@ -48,7 +48,7 @@ public function execute(AnswersChartData $answerChartData): Graph $colors = []; foreach ($labels as $k => $label) { - if ($label === 'NR') { + if ('NR' === $label) { $colors[$k] = $chart->getColors()[1] . '@' . $chart->transparency; } else { $colors[$k] = $chart->getColors()[0] . '@' . $chart->transparency; diff --git a/Actions/JpGraph/V1/Pie1Action.php b/Actions/JpGraph/V1/Pie1Action.php index 8a0a37a62..dfdada783 100644 --- a/Actions/JpGraph/V1/Pie1Action.php +++ b/Actions/JpGraph/V1/Pie1Action.php @@ -7,10 +7,11 @@ use Amenadiel\JpGraph\Graph\Graph; use Amenadiel\JpGraph\Graph\PieGraph; use Amenadiel\JpGraph\Plot\PiePlotC; -use function count; use Modules\Chart\Actions\JpGraph\ApplyGraphStyleAction; use Modules\Chart\Datas\AnswersChartData; use Spatie\QueueableAction\QueueableAction; + +use function count; use function strlen; class Pie1Action @@ -33,7 +34,7 @@ public function execute(AnswersChartData $answerChartData): Graph $data[] = $other; $labels[] = $chart->answer_value_no_txt; - if (count($labels) === 2 && strlen($labels[0]) < 3) { + if (2 === count($labels) && strlen($labels[0]) < 3) { $labels[0] = $chart->answer_value_txt; } } diff --git a/Actions/JpGraph/V1/PieAvgAction.php b/Actions/JpGraph/V1/PieAvgAction.php index 0a9efbf43..54c5baed2 100644 --- a/Actions/JpGraph/V1/PieAvgAction.php +++ b/Actions/JpGraph/V1/PieAvgAction.php @@ -7,12 +7,13 @@ use Amenadiel\JpGraph\Graph\Graph; use Amenadiel\JpGraph\Graph\PieGraph; use Amenadiel\JpGraph\Plot\PiePlotC; -use function count; -use function is_array; -use function is_numeric; use Modules\Chart\Actions\JpGraph\ApplyGraphStyleAction; use Modules\Chart\Datas\AnswersChartData; use Spatie\QueueableAction\QueueableAction; + +use function count; +use function is_array; +use function is_numeric; use function strlen; class PieAvgAction @@ -33,7 +34,7 @@ public function execute(AnswersChartData $answerChartData): Graph // $color_array[1] = 'white'; $data[] = $other; $labels[] = $chart->answer_value_no_txt ?? 'answer_value_no_txt'; - if (count($labels) === 2 && strlen((string) $labels[0]) < 3) { + if (2 === count($labels) && strlen((string) $labels[0]) < 3) { $labels[0] = $chart->answer_value_txt; } } diff --git a/Datas/AnswersChartData.php b/Datas/AnswersChartData.php index 704b758ff..f131797d4 100644 --- a/Datas/AnswersChartData.php +++ b/Datas/AnswersChartData.php @@ -4,9 +4,10 @@ namespace Modules\Chart\Datas; -use function count; use Spatie\LaravelData\Data; use Spatie\LaravelData\DataCollection; + +use function count; use function strlen; class AnswersChartData extends Data @@ -74,7 +75,7 @@ public function getChartJsData(): array if ($other > 0.01) { $data[] = $other; $labels[] = $this->chart->answer_value_no_txt ?? 'answer_value_no_txt'; - if (count($labels) === 2 && strlen((string) $labels[0]) < 3) { + if (2 === count($labels) && strlen((string) $labels[0]) < 3) { $labels[0] = $this->chart->answer_value_txt; } } @@ -101,7 +102,7 @@ public function getChartJsData(): array if ($other > 0.01) { $data[] = $other; $labels[] = $this->chart->answer_value_no_txt ?? 'answer_value_no_txt'; - if (count($labels) === 2 && strlen((string) $labels[0]) < 3) { + if (2 === count($labels) && strlen((string) $labels[0]) < 3) { $labels[0] = $this->chart->answer_value_txt; } } @@ -136,7 +137,7 @@ public function getChartJsOptions(): array $legend_display = true; $title = []; - if ($this->title !== 'no_set') { + if ('no_set' !== $this->title) { $title = [ 'display' => true, 'text' => $this->title, @@ -146,7 +147,7 @@ public function getChartJsOptions(): array ]; } - if ($this->footer !== 'no_set') { + if ('no_set' !== $this->footer) { $title = [ 'display' => true, 'text' => $this->footer, diff --git a/Models/Chart.php b/Models/Chart.php index f25f92989..067b89c99 100644 --- a/Models/Chart.php +++ b/Models/Chart.php @@ -4,11 +4,12 @@ namespace Modules\Chart\Models; -use function array_slice; use ErrorException; use Illuminate\Support\Str; use Webmozart\Assert\Assert; +use function array_slice; + /** * Modules\Chart\Models\Chart. * @@ -273,7 +274,7 @@ public function getPanelRow(string $parent_field, string $my_field): int|string| public function getTypeAttribute(?string $value): ?string { - if ($value !== null) { + if (null !== $value) { return $value; } if (isset($this->attributes['type'])) { @@ -285,7 +286,7 @@ public function getTypeAttribute(?string $value): ?string public function getWidthAttribute(?string $value): ?int { - if ($value !== null && $value !== 0) { + if (null !== $value && 0 !== $value) { return (int) $value; } @@ -294,7 +295,7 @@ public function getWidthAttribute(?string $value): ?int public function getHeightAttribute(?string $value): ?int { - if ($value !== null && $value !== 0) { + if (null !== $value && 0 !== $value) { return (int) $value; } diff --git a/Tables/Columns/ChartColumn.php b/Tables/Columns/ChartColumn.php index e06f7d22b..641937d68 100644 --- a/Tables/Columns/ChartColumn.php +++ b/Tables/Columns/ChartColumn.php @@ -7,6 +7,7 @@ use Filament\Tables\Columns\Column; use Illuminate\Contracts\View\View; use Modules\Chart\Datas\AnswersChartData; + use function Safe\json_encode; // use Illuminate\Session\SessionManager; @@ -50,6 +51,7 @@ public function setAnswersChartData(AnswersChartData $answersData): self $this->chartType = $answersData->getChartJsType(); $this->chartOptions = $answersData->getChartJsOptions(); $this->cachedData = null; + // dddx([$this->getCachedData(),$this->getData()]); // $this->emit('refreshChartColumn'); // filterChartData diff --git a/docs/config.php b/docs/config.php index 54850388d..5b7b1c70e 100644 --- a/docs/config.php +++ b/docs/config.php @@ -48,6 +48,7 @@ if (Str::startsWith($path, 'http')) { return $path; } + // return Str::startsWith($path, 'http') ? $path : '/' . trimPath($path); return url('/' . $page->lang . '/' . trimPath($path)); }, diff --git a/phpinsights.php b/phpinsights.php index f0393edec..231ee0797 100644 --- a/phpinsights.php +++ b/phpinsights.php @@ -17,7 +17,6 @@ use SlevomatCodingStandard\Sniffs\TypeHints\ReturnTypeHintSniff; return [ - /* |-------------------------------------------------------------------------- | Default Preset @@ -105,11 +104,11 @@ */ 'requirements' => [ -// 'min-quality' => 0, -// 'min-complexity' => 0, -// 'min-architecture' => 0, -// 'min-style' => 0, -// 'disable-security-check' => false, + // 'min-quality' => 0, + // 'min-complexity' => 0, + // 'min-architecture' => 0, + // 'min-style' => 0, + // 'disable-security-check' => false, ], /* @@ -124,5 +123,4 @@ */ 'threads' => null, - ]; From 96efb7540797a2538c001da60263116842b1d610 Mon Sep 17 00:00:00 2001 From: marco76tv Date: Mon, 4 Sep 2023 09:11:27 +0000 Subject: [PATCH 3/8] Ignore Dusting commit in git blame --- .git-blame-ignore-revs | 1 + 1 file changed, 1 insertion(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index c69e9ef1d..a99ff0a92 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -6,3 +6,4 @@ a0b67dc4e05712dc2a577a5c380880385527e4e1 6b5a93806f0bd2d5a5e30addfde94b7dd30e21e3 8ad1d9b8ff0e8c7e8f0825622a2c3c03af8faee5 d5f15a52d72f12a30680a701a795783606dffd21 +2d3ea1ca61a37e8c6c3a149d394f89fd89d0c115 From 3bc447608b7aed93ad5d7ac22a8bc765f4704c5e Mon Sep 17 00:00:00 2001 From: marco76tv Date: Tue, 5 Sep 2023 11:05:22 +0200 Subject: [PATCH 4/8] rector --- .github/workflows/rector.yaml | 31 ++++++++++ Actions/Chart/GetTypeOptions.php | 2 +- Actions/JpGraph/ApplyGraphStyleAction.php | 32 +++++----- Actions/JpGraph/ApplyPlotStyleAction.php | 42 ++++++------- Actions/JpGraph/GetGraphAction.php | 64 ++++++++++---------- Actions/JpGraph/V1/Bar2Action.php | 26 ++++---- Actions/JpGraph/V1/Bar3Action.php | 14 ++--- Actions/JpGraph/V1/Horizbar1Action.php | 12 ++-- Actions/JpGraph/V1/LineSubQuestionAction.php | 6 +- Actions/JpGraph/V1/Pie1Action.php | 40 ++++++------ Actions/JpGraph/V1/PieAvgAction.php | 24 ++++---- Datas/AnswerData.php | 12 ++-- Datas/AnswersChartData.php | 11 +--- Datas/ChartData.php | 26 ++++---- Models/BaseModel.php | 9 +-- Models/Chart.php | 5 +- Models/MixedChart.php | 4 +- Routes/api.php | 4 +- Tables/Columns/ChartColumn.php | 8 +-- 19 files changed, 190 insertions(+), 182 deletions(-) create mode 100644 .github/workflows/rector.yaml diff --git a/.github/workflows/rector.yaml b/.github/workflows/rector.yaml new file mode 100644 index 000000000..e41c939fb --- /dev/null +++ b/.github/workflows/rector.yaml @@ -0,0 +1,31 @@ +# Inspiration https://github.com/symplify/symplify/blob/main/.github/workflows/rector.yaml +name: Rector + +on: + pull_request: null + +jobs: + rector: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + token: "${{ secrets.ACCESS_TOKEN || secrets.GITHUB_TOKEN }}" + + - uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + + - uses: "ramsey/composer-install@v2" + + - run: vendor/bin/rector --ansi + + - uses: EndBug/add-and-commit@v5.1.0 + with: + add: . + message: "[ci-review] Rector Rectify" + author_name: "GitHub Action" + author_email: "action@github.com" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Actions/Chart/GetTypeOptions.php b/Actions/Chart/GetTypeOptions.php index 027e29998..dfc74e575 100644 --- a/Actions/Chart/GetTypeOptions.php +++ b/Actions/Chart/GetTypeOptions.php @@ -44,6 +44,6 @@ public function execute(): array $data[$k1] = 'mixed:' . $v; } - return array_merge($options, $data); + return [...$options, ...$data]; } } diff --git a/Actions/JpGraph/ApplyGraphStyleAction.php b/Actions/JpGraph/ApplyGraphStyleAction.php index e1ddea80b..67f5ecfa5 100644 --- a/Actions/JpGraph/ApplyGraphStyleAction.php +++ b/Actions/JpGraph/ApplyGraphStyleAction.php @@ -13,51 +13,51 @@ class ApplyGraphStyleAction { use QueueableAction; - public function execute(Graph &$graph, ChartData $chart): Graph + public function execute(Graph &$graph, ChartData $chartData): Graph { // Nice shadow $graph->SetShadow(); - $graph->SetBox($chart->show_box); + $graph->SetBox($chartData->show_box); - $graph->footer->right->SetFont($chart->font_family, $chart->font_style); + $graph->footer->right->SetFont($chartData->font_family, $chartData->font_style); // $graph->footer->right->Set('Totale Risposte '.$this->vars['tot']); if (null !== $graph->xaxis) { - $this->applyGraphXStyle($graph->xaxis, $chart); + $this->applyGraphXStyle($graph->xaxis, $chartData); } if (null !== $graph->yaxis) { - $this->applyGraphYStyle($graph->yaxis, $chart); + $this->applyGraphYStyle($graph->yaxis, $chartData); } return $graph; } - public function applyGraphXStyle(Axis &$xaxis, ChartData $data): void + public function applyGraphXStyle(Axis &$axis, ChartData $chartData): void { - $xaxis->SetFont($data->font_family, $data->font_style, $data->font_size); - $xaxis->SetLabelAngle($data->x_label_angle); + $axis->SetFont($chartData->font_family, $chartData->font_style, $chartData->font_size); + $axis->SetLabelAngle($chartData->x_label_angle); // Some extra margin looks nicer - $xaxis->SetLabelMargin($data->x_label_margin); + $axis->SetLabelMargin($chartData->x_label_margin); // Label align for X-axis // $graph->xaxis->SetLabelAlign('right', 'center'); } - public function applyGraphYStyle(Axis &$yaxis, ChartData $data): void + public function applyGraphYStyle(Axis &$axis, ChartData $chartData): void { // Add some grace to y-axis so the bars doesn't go // all the way to the end of the plot area // "restringe" la visualizzazione delle barre - $yaxis->scale->SetGrace($data->y_grace); + $axis->scale->SetGrace($chartData->y_grace); // dddx($style['yaxis_hide']); // We don't want to display Y-axis // visualizza delle colonne verticali "in sottofondo/di riferimento" // if (null == $data->yaxis_hide || 0 == $data->yaxis_hide) { - if ($data->yaxis_hide) { - $yaxis->Hide(); + if ($chartData->yaxis_hide) { + $axis->Hide(); } - $yaxis->HideZeroLabel(); - $yaxis->HideLine(false); - $yaxis->HideTicks(false, false); + $axis->HideZeroLabel(); + $axis->HideLine(false); + $axis->HideTicks(false, false); } } diff --git a/Actions/JpGraph/ApplyPlotStyleAction.php b/Actions/JpGraph/ApplyPlotStyleAction.php index 0b4308e94..090f6ac16 100644 --- a/Actions/JpGraph/ApplyPlotStyleAction.php +++ b/Actions/JpGraph/ApplyPlotStyleAction.php @@ -12,68 +12,66 @@ class ApplyPlotStyleAction { use QueueableAction; - public function execute(BarPlot $plot, ChartData $data): BarPlot + public function execute(BarPlot $barPlot, ChartData $chartData): BarPlot { - $colors = []; - // $plot->SetFillColor($colors); // trasparenza, da 0 a 1 // $plot->SetFillColor($this->data[5]['color'].'@'.$this->vars['transparency']); // trasparenza, da 0 a 1 - $plot->SetFillColor($data->list_color ?? 'red@' . $data->transparency); // trasparenza, da 0 a 1 + $barPlot->SetFillColor($chartData->list_color ?? 'red@' . $chartData->transparency); // trasparenza, da 0 a 1 // $bplot->SetShadow('darkgreen', 1, 1); // dddx([get_defined_vars(), $this->vars]); - $plot->SetColor($data->list_color ?? 'red'); + $barPlot->SetColor($chartData->list_color ?? 'red'); // You can change the width of the bars if you like - $plot->SetWidth($data->plot_perc_width / 100); + $barPlot->SetWidth($chartData->plot_perc_width / 100); // $plot->SetWidth(10); // We want to display the value of each bar at the top // se tolto non mostra i valori // Right side of || is always false. // if (null == $data->plot_value_show || 0 == $data->plot_value_show) { - if ($data->plot_value_show) { - $plot->value->Show(); + if ($chartData->plot_value_show) { + $barPlot->value->Show(); } - $plot->value->SetFont($data->font_family, $data->font_style, $data->font_size); + $barPlot->value->SetFont($chartData->font_family, $chartData->font_style, $chartData->font_size); - $plot->value->SetAlign('left', 'center'); + $barPlot->value->SetAlign('left', 'center'); // colore del font che scrivi - if (null !== $data->plot_value_color) { - $plot->value->SetColor($data->plot_value_color); + if (null !== $chartData->plot_value_color) { + $barPlot->value->SetColor($chartData->plot_value_color); } else { - $plot->value->SetColor('black', 'darkred'); + $barPlot->value->SetColor('black', 'darkred'); } // visualizza il risultato con % oppure no // $plot->value->SetFormat('%.2f %'); // 2f significa 2 cifre decimali, 1f solo una cifra decimale - switch ($data->plot_value_format) { + switch ($chartData->plot_value_format) { case 1: - $plot->value->SetFormat('%.1f %'); + $barPlot->value->SetFormat('%.1f %'); break; case 2: - $plot->value->SetFormat('%.1f'); + $barPlot->value->SetFormat('%.1f'); break; case 3: - $plot->value->SetFormat('%.0f'); + $barPlot->value->SetFormat('%.0f'); break; default: - $plot->value->SetFormat('%.1f %'); + $barPlot->value->SetFormat('%.1f %'); } // Center the values in the bar // if (null == $data->plot_value_pos || 0 == $data->plot_value_pos) { - if (0 === $data->plot_value_pos) { - $plot->SetValuePos('center'); + if (0 === $chartData->plot_value_pos) { + $barPlot->SetValuePos('center'); } - $plot->value->setAngle($data->x_label_angle); + $barPlot->value->setAngle($chartData->x_label_angle); // $plot->value->setAngle(50); - return $plot; + return $barPlot; } } diff --git a/Actions/JpGraph/GetGraphAction.php b/Actions/JpGraph/GetGraphAction.php index b4a865e44..ae852bf33 100644 --- a/Actions/JpGraph/GetGraphAction.php +++ b/Actions/JpGraph/GetGraphAction.php @@ -14,71 +14,71 @@ class GetGraphAction { use QueueableAction; - public function execute(ChartData $data): Graph + public function execute(ChartData $chartData): Graph { - $graph = new Graph($data->width, $data->height, 'auto'); + $graph = new Graph($chartData->width, $chartData->height, 'auto'); $graph->SetScale('textlin'); $graph->SetShadow(); - $theme_class = new UniversalTheme; + $universalTheme = new UniversalTheme; - $graph->SetTheme($theme_class); + $graph->SetTheme($universalTheme); - if (isset($data->min)) { - $graph->yscale->SetAutoMin($data->min); + if (isset($chartData->min)) { + $graph->yscale->SetAutoMin($chartData->min); } - if (isset($data->max)) { - $graph->yscale->SetAutoMax($data->max); + if (isset($chartData->max)) { + $graph->yscale->SetAutoMax($chartData->max); } - if (isset($data->title)) { - $graph->title->Set($data->title); - $graph->title->SetFont($data->font_family, $data->font_style, 11); + if ($chartData->title !== null) { + $graph->title->Set($chartData->title); + $graph->title->SetFont($chartData->font_family, $chartData->font_style, 11); } - if (isset($data->subtitle)) { - $graph->subtitle->Set($data->subtitle); - $graph->subtitle->SetFont($data->font_family, $data->font_style, 11); + if ($chartData->subtitle !== null) { + $graph->subtitle->Set($chartData->subtitle); + $graph->subtitle->SetFont($chartData->font_family, $chartData->font_style, 11); } - if (isset($data->footer)) { - $graph->footer->center->Set($data->footer); - $graph->footer->center->SetFont($data->font_family, $data->font_style, 10); + if ($chartData->footer !== null) { + $graph->footer->center->Set($chartData->footer); + $graph->footer->center->SetFont($chartData->font_family, $chartData->font_style, 10); } - $graph->SetBox($data->show_box); + $graph->SetBox($chartData->show_box); - $graph->footer->right->SetFont($data->font_family, $data->font_style); + $graph->footer->right->SetFont($chartData->font_family, $chartData->font_style); - $this->applyGraphXStyle($graph->xaxis, $data); - $this->applyGraphYStyle($graph->yaxis, $data); + $this->applyGraphXStyle($graph->xaxis, $chartData); + $this->applyGraphYStyle($graph->yaxis, $chartData); return $graph; } - public function applyGraphXStyle(Axis &$xaxis, ChartData $data): void + public function applyGraphXStyle(Axis &$axis, ChartData $chartData): void { - $xaxis->SetFont($data->font_family, $data->font_style, $data->font_size); - $xaxis->SetLabelAngle($data->x_label_angle); + $axis->SetFont($chartData->font_family, $chartData->font_style, $chartData->font_size); + $axis->SetLabelAngle($chartData->x_label_angle); // Some extra margin looks nicer - $xaxis->SetLabelMargin($data->x_label_margin); + $axis->SetLabelMargin($chartData->x_label_margin); // Label align for X-axis // $graph->xaxis->SetLabelAlign('right', 'center'); } - public function applyGraphYStyle(Axis &$yaxis, ChartData $data): void + public function applyGraphYStyle(Axis &$axis, ChartData $chartData): void { // Add some grace to y-axis so the bars doesn't go // all the way to the end of the plot area // "restringe" la visualizzazione delle barre - $yaxis->scale->SetGrace($data->y_grace); + $axis->scale->SetGrace($chartData->y_grace); // dddx($style['yaxis_hide']); // We don't want to display Y-axis // visualizza delle colonne verticali "in sottofondo/di riferimento" // if (null == $data->yaxis_hide || 0 == $data->yaxis_hide) { - if ($data->yaxis_hide) { - $yaxis->Hide(); + if ($chartData->yaxis_hide) { + $axis->Hide(); } - $yaxis->HideZeroLabel(); - $yaxis->HideLine(false); - $yaxis->HideTicks(false, false); + $axis->HideZeroLabel(); + $axis->HideLine(false); + $axis->HideTicks(false, false); } } diff --git a/Actions/JpGraph/V1/Bar2Action.php b/Actions/JpGraph/V1/Bar2Action.php index fa760c295..96fffd55f 100644 --- a/Actions/JpGraph/V1/Bar2Action.php +++ b/Actions/JpGraph/V1/Bar2Action.php @@ -19,19 +19,19 @@ class Bar2Action { use QueueableAction; - public function execute(AnswersChartData $answerChartData): Graph + public function execute(AnswersChartData $answersChartData): Graph { - $data = $answerChartData->answers->toCollection()->pluck('avg')->all(); - $data1 = $answerChartData->answers->toCollection()->pluck('value')->all(); + $data = $answersChartData->answers->toCollection()->pluck('avg')->all(); + $data1 = $answersChartData->answers->toCollection()->pluck('value')->all(); $legends = [0]; if (isset($data1[0]) && is_array($data1[0])) { // questionario multiplo $legends = array_keys($data1[0]); - $data = $answerChartData->answers->toCollection()->pluck('value')->all(); - $data1 = $answerChartData->answers->toCollection()->pluck('avg')->all(); + $data = $answersChartData->answers->toCollection()->pluck('value')->all(); + $data1 = $answersChartData->answers->toCollection()->pluck('avg')->all(); } - $labels = $answerChartData->answers->toCollection()->pluck('label')->all(); - $chart = $answerChartData->chart; + $labels = $answersChartData->answers->toCollection()->pluck('label')->all(); + $chart = $answersChartData->chart; $graph = app(GetGraphAction::class)->execute($chart); $graph->img->SetMargin(50, 50, 50, 100); $graph->ygrid->SetFill(false); @@ -41,7 +41,7 @@ public function execute(AnswersChartData $answerChartData): Graph $graph->yaxis->HideTicks(false, false); $graph->yscale->ticks->SupressZeroLabel(false); - $graph->xaxis->SetTickLabels($labels) + 10; + $graph->xaxis->SetTickLabels($labels); /* $bplot = new BarPlot($data); @@ -63,11 +63,7 @@ public function execute(AnswersChartData $answerChartData): Graph $bplot = []; foreach ($legends as $i => $legend) { - if (0 === $legend) { - $tmp_data = $data; - } else { - $tmp_data = array_column($data, $legend); - } + $tmp_data = 0 === $legend ? $data : array_column($data, $legend); // dddx(['data' => $data, 'tmp_data' => $tmp_data]); $tmp = new BarPlot($tmp_data); @@ -91,9 +87,9 @@ public function execute(AnswersChartData $answerChartData): Graph } // Create the grouped bar plot - $gbplot = new GroupBarPlot($bplot); + $groupBarPlot = new GroupBarPlot($bplot); // ...and add it to the graPH - $graph->Add($gbplot); + $graph->Add($groupBarPlot); // $graph->Add($bplot); diff --git a/Actions/JpGraph/V1/Bar3Action.php b/Actions/JpGraph/V1/Bar3Action.php index e228c9d63..597c56509 100644 --- a/Actions/JpGraph/V1/Bar3Action.php +++ b/Actions/JpGraph/V1/Bar3Action.php @@ -21,10 +21,10 @@ class Bar3Action { use QueueableAction; - public function execute(AnswersChartData $answerChartData): Graph + public function execute(AnswersChartData $answersChartData): Graph { - $chart = $answerChartData->chart; - $answers = $answerChartData->answers; + $chart = $answersChartData->chart; + $answers = $answersChartData->answers; $graph = app(GetGraphAction::class)->execute($chart); $graph->img->SetMargin(50, 50, 50, 100); $labels = $answers->toCollection()->pluck('label')->all(); @@ -67,10 +67,10 @@ public function execute(AnswersChartData $answerChartData): Graph } // Create the grouped bar plot - $gbplot = new AccBarPlot($bplot); - $gbplot->SetWidth($chart->plot_perc_width / 100); + $accBarPlot = new AccBarPlot($bplot); + $accBarPlot->SetWidth($chart->plot_perc_width / 100); // ...and add it to the graPH - $graph->Add($gbplot); + $graph->Add($accBarPlot); if (count($datay) > 1) { // dddx($this->data->first()['title_type']); @@ -82,7 +82,7 @@ public function execute(AnswersChartData $answerChartData): Graph $graph->title->SetFont($chart->font_family, $chart->font_style, 11); } - if (isset($chart->totali)) { + if (property_exists($chart, 'totali') && $chart->totali !== null) { $str = ''; foreach ($chart->totali as $k => $v) { $str .= $k . ' ' . $v . ' - '; diff --git a/Actions/JpGraph/V1/Horizbar1Action.php b/Actions/JpGraph/V1/Horizbar1Action.php index bd2ba45f7..970304285 100644 --- a/Actions/JpGraph/V1/Horizbar1Action.php +++ b/Actions/JpGraph/V1/Horizbar1Action.php @@ -17,19 +17,19 @@ class Horizbar1Action { use QueueableAction; - public function execute(AnswersChartData $answerChartData): Graph + public function execute(AnswersChartData $answersChartData): Graph { - $data = $answerChartData->answers->toCollection()->pluck('avg')->all(); + $data = $answersChartData->answers->toCollection()->pluck('avg')->all(); - $labels = $answerChartData->answers->toCollection() + $labels = $answersChartData->answers->toCollection() ->pluck('label') - ->map(static function ($item) { + ->map(static function ($item): string { Assert::string($item); return wordwrap($item, 25, PHP_EOL); }) ->all(); - $chart = $answerChartData->chart; + $chart = $answersChartData->chart; $graph = app(GetGraphAction::class)->execute($chart); $graph->SetScale('textlin'); @@ -39,7 +39,7 @@ public function execute(AnswersChartData $answerChartData): Graph $graph = app(ApplyGraphStyleAction::class)->execute($graph, $chart); - $graph->xaxis->SetTickLabels($labels) + 10; + $graph->xaxis->SetTickLabels($labels); $bplot = new BarPlot($data); // $bplot = $this->applyPlotStyle($bplot); diff --git a/Actions/JpGraph/V1/LineSubQuestionAction.php b/Actions/JpGraph/V1/LineSubQuestionAction.php index 2d857cdd8..6ca04270d 100644 --- a/Actions/JpGraph/V1/LineSubQuestionAction.php +++ b/Actions/JpGraph/V1/LineSubQuestionAction.php @@ -16,10 +16,10 @@ class LineSubQuestionAction { use QueueableAction; - public function execute(AnswersChartData $answerChartData): Graph + public function execute(AnswersChartData $answersChartData): Graph { - $chart = $answerChartData->chart; - $answers = $answerChartData->answers; + $chart = $answersChartData->chart; + $answers = $answersChartData->answers; $graph = app(GetGraphAction::class)->execute($chart); $labels = $answers->toCollection()->pluck('label')->all(); diff --git a/Actions/JpGraph/V1/Pie1Action.php b/Actions/JpGraph/V1/Pie1Action.php index dfdada783..50c323e46 100644 --- a/Actions/JpGraph/V1/Pie1Action.php +++ b/Actions/JpGraph/V1/Pie1Action.php @@ -18,11 +18,11 @@ class Pie1Action { use QueueableAction; - public function execute(AnswersChartData $answerChartData): Graph + public function execute(AnswersChartData $answersChartData): Graph { - $labels = $answerChartData->answers->toCollection()->pluck('label')->all(); - $data = $answerChartData->answers->toCollection()->pluck('avg')->all(); - $chart = $answerChartData->chart; + $labels = $answersChartData->answers->toCollection()->pluck('label')->all(); + $data = $answersChartData->answers->toCollection()->pluck('avg')->all(); + $chart = $answersChartData->chart; // dddx(['labels' => $labels, 'data' => $data, 'answers' => $answers]); // dddx($chart->max); if (isset($chart->max)) { @@ -34,7 +34,7 @@ public function execute(AnswersChartData $answerChartData): Graph $data[] = $other; $labels[] = $chart->answer_value_no_txt; - if (2 === count($labels) && strlen($labels[0]) < 3) { + if (2 === count($labels) && strlen((string) $labels[0]) < 3) { $labels[0] = $chart->answer_value_txt; } } @@ -47,7 +47,7 @@ public function execute(AnswersChartData $answerChartData): Graph $graph = app(ApplyGraphStyleAction::class)->execute($graph, $chart); // Create the pie plot - $p1 = new PiePlotC($data); + $piePlotC = new PiePlotC($data); // $p1->SetSliceColors(explode(',', $chart->list_color)); // trasparenza da 0 a 1, inserito per ogni colore @@ -55,21 +55,21 @@ public function execute(AnswersChartData $answerChartData): Graph foreach ($color_array as $k => $color) { $color_array[$k] = $color . '@' . $chart->transparency; } - $p1->SetSliceColors($color_array); + $piePlotC->SetSliceColors($color_array); - $p1->SetLegends($labels); + $piePlotC->SetLegends($labels); // $graph->legend->SetPos(0.5,0.98,'center','bottom'); // Enable and set policy for guide-lines. Make labels line up vertically - $p1->SetGuideLines(true, false); - $p1->SetGuideLinesAdjust(1.5); + $piePlotC->SetGuideLines(true, false); + $piePlotC->SetGuideLinesAdjust(1.5); // Use percentage values in the legends values (This is also the default) - $p1->SetLabelType(PIE_VALUE_PER); - $p1->value->Show(); + $piePlotC->SetLabelType(PIE_VALUE_PER); + $piePlotC->value->Show(); // $p1->SetMidSize(0.8); - $p1->SetMidSize($chart->plot_perc_width / 100); + $piePlotC->SetMidSize($chart->plot_perc_width / 100); // $mandatory = $chart->mandatory; // if (null === $chart->mandatory) { @@ -82,19 +82,19 @@ public function execute(AnswersChartData $answerChartData): Graph $graph->subtitle->SetFont($chart->font_family, $chart->font_style, 11); // Label font and color setup - $p1->value->SetFont(FF_ARIAL, FS_BOLD, 10); - $p1->value->SetColor('black'); + $piePlotC->value->SetFont(FF_ARIAL, FS_BOLD, 10); + $piePlotC->value->SetColor('black'); // Setup the title on the center circle - $p1->midtitle->Set(''); - $p1->midtitle->SetFont(FF_ARIAL, FS_NORMAL, 10); - $p1->value->SetFormat('%2.1f%%'); + $piePlotC->midtitle->Set(''); + $piePlotC->midtitle->SetFont(FF_ARIAL, FS_NORMAL, 10); + $piePlotC->value->SetFormat('%2.1f%%'); // Set color for mid circle - $p1->SetMidColor('white'); + $piePlotC->SetMidColor('white'); // Add plot to pie graph - $graph->Add($p1); + $graph->Add($piePlotC); return $graph; } diff --git a/Actions/JpGraph/V1/PieAvgAction.php b/Actions/JpGraph/V1/PieAvgAction.php index 54c5baed2..52e06ac33 100644 --- a/Actions/JpGraph/V1/PieAvgAction.php +++ b/Actions/JpGraph/V1/PieAvgAction.php @@ -20,12 +20,12 @@ class PieAvgAction { use QueueableAction; - public function execute(AnswersChartData $answerChartData): Graph + public function execute(AnswersChartData $answersChartData): Graph { - $labels = $answerChartData->answers->toCollection()->pluck('label')->all(); + $labels = $answersChartData->answers->toCollection()->pluck('label')->all(); - $data = $answerChartData->answers->toCollection()->pluck('avg')->all(); - $chart = $answerChartData->chart; + $data = $answersChartData->answers->toCollection()->pluck('avg')->all(); + $chart = $answersChartData->chart; if (isset($chart->max)) { $sum = collect($data)->sum(); $other = $chart->max - $sum; @@ -47,8 +47,8 @@ public function execute(AnswersChartData $answerChartData): Graph $graph = app(ApplyGraphStyleAction::class)->execute($graph, $chart); // Create the pie plot - $p1 = new PiePlotC($data); - $p1->SetStartAngle(180); + $piePlotC = new PiePlotC($data); + $piePlotC->SetStartAngle(180); // trasparenza da 0 a 1, inserito per ogni colore $color_array = explode(',', $chart->list_color); @@ -57,16 +57,16 @@ public function execute(AnswersChartData $answerChartData): Graph $color_array[$k] = $color . '@0.6'; } // dddx($color_array); - $p1->SetSliceColors($color_array); + $piePlotC->SetSliceColors($color_array); // nasconde i label - $p1->value->Show(false); + $piePlotC->value->Show(false); // Set color for mid circle - $p1->SetMidColor('white'); + $piePlotC->SetMidColor('white'); // $p1->SetMidSize(0.8); - $p1->SetMidSize($chart->plot_perc_width / 100); + $piePlotC->SetMidSize($chart->plot_perc_width / 100); $graph->title->Set($chart->title); $graph->title->SetFont($chart->font_family, $chart->font_style, 11); @@ -89,10 +89,10 @@ public function execute(AnswersChartData $answerChartData): Graph $graph->footer->SetMargin(0, 0, $y); // con 0 metto al centro la percentuale - $p1->SetLabelPos(0); + $piePlotC->SetLabelPos(0); // Add plot to pie graph - $graph->Add($p1); + $graph->Add($piePlotC); return $graph; } diff --git a/Datas/AnswerData.php b/Datas/AnswerData.php index 1a990a917..0c0f17f1e 100644 --- a/Datas/AnswerData.php +++ b/Datas/AnswerData.php @@ -8,13 +8,13 @@ class AnswerData extends Data { - public ?string $label; + public ?string $label = null; public int $gid = 0; public float|array $value = 0; public float|array|string $value1 = ''; - public ?string $_key; - public ?string $key; - public ?string $_sub; + public ?string $_key = null; + public ?string $key = null; + public ?string $_sub = null; public ?string $_sort = null; // public ?array $sub_labels; @@ -22,6 +22,6 @@ class AnswerData extends Data public float|array|string $avg = 0; // public int $tot = 1; // public int $tot_nulled = 0; - public ?string $title; - public ?string $subtitle; + public ?string $title = null; + public ?string $subtitle = null; } diff --git a/Datas/AnswersChartData.php b/Datas/AnswersChartData.php index f131797d4..9e39b09f4 100644 --- a/Datas/AnswersChartData.php +++ b/Datas/AnswersChartData.php @@ -41,11 +41,7 @@ public function getChartJsType(): string $type = 'line'; break; case 'bar2': - $type = 'bar'; - break; case 'bar1': - $type = 'bar'; - break; case 'bar3': $type = 'bar'; break; @@ -75,7 +71,7 @@ public function getChartJsData(): array if ($other > 0.01) { $data[] = $other; $labels[] = $this->chart->answer_value_no_txt ?? 'answer_value_no_txt'; - if (2 === count($labels) && strlen((string) $labels[0]) < 3) { + if (2 === count($labels) && strlen($labels[0]) < 3) { $labels[0] = $this->chart->answer_value_txt; } } @@ -102,7 +98,7 @@ public function getChartJsData(): array if ($other > 0.01) { $data[] = $other; $labels[] = $this->chart->answer_value_no_txt ?? 'answer_value_no_txt'; - if (2 === count($labels) && strlen((string) $labels[0]) < 3) { + if (2 === count($labels) && strlen($labels[0]) < 3) { $labels[0] = $this->chart->answer_value_txt; } } @@ -134,7 +130,6 @@ public function getChartJsData(): array public function getChartJsOptions(): array { - $legend_display = true; $title = []; if ('no_set' !== $this->title) { @@ -159,7 +154,7 @@ public function getChartJsOptions(): array 'title' => $title, ]; - if (in_array($this->chart->type, ['horizbar1'])) { + if ($this->chart->type == 'horizbar1') { $options['indexAxis'] = 'y'; } diff --git a/Datas/ChartData.php b/Datas/ChartData.php index 42cb72480..9c52e2637 100644 --- a/Datas/ChartData.php +++ b/Datas/ChartData.php @@ -15,33 +15,33 @@ class ChartData extends Data public float $min; public int $width; public int $height; - public ?string $title; - public ?string $subtitle; + public ?string $title = null; + public ?string $subtitle = null; public string $list_color; // public string $color; // #000000 // non si deve piĆ¹ usare, sostituito da list_color - public ?string $bg_color; // #000000 + public ?string $bg_color = null; // #000000 public string $font_family; public string $font_size; public string $font_style; - public ?int $y_grace; - public ?int $yaxis_hide; + public ?int $y_grace = null; + public ?int $yaxis_hide = null; public string $x_label_angle; public int $show_box; public int $x_label_margin; public int $plot_perc_width; public bool $plot_value_show; - public ?string $plot_value_format; + public ?string $plot_value_format = null; public ?string $plot_value_color = '#000000'; public string $transparency; - public ?string $engine_type; - public ?string $footer; + public ?string $engine_type = null; + public ?string $footer = null; public int $plot_value_pos = 0; - public ?string $answer_value_no_txt; - public ?string $answer_value_txt; + public ?string $answer_value_no_txt = null; + public ?string $answer_value_txt = null; // public ?string $legend; - public ?array $legend; - public ?array $sublabels; - public ?float $avg; + public ?array $legend = null; + public ?array $sublabels = null; + public ?float $avg = null; public function getColors(): array { diff --git a/Models/BaseModel.php b/Models/BaseModel.php index da1250cb5..d27fd5816 100644 --- a/Models/BaseModel.php +++ b/Models/BaseModel.php @@ -48,14 +48,7 @@ abstract class BaseModel extends Model /** * @var array */ - protected $casts = [ - // 'published_at' => 'datetime:Y-m-d', // da verificare - ]; - - /** - * @var array - */ - protected array $dates = ['published_at', 'created_at', 'updated_at']; + protected $casts = ['published_at' => 'datetime', 'created_at' => 'datetime', 'updated_at' => 'datetime']; /** * @var string diff --git a/Models/Chart.php b/Models/Chart.php index 067b89c99..8e0617c1b 100644 --- a/Models/Chart.php +++ b/Models/Chart.php @@ -277,11 +277,8 @@ public function getTypeAttribute(?string $value): ?string if (null !== $value) { return $value; } - if (isset($this->attributes['type'])) { - return $this->attributes['type']; - } - return (string) $this->getPanelRow('chart_type', 'type'); + return $this->attributes['type'] ?? (string) $this->getPanelRow('chart_type', 'type'); } public function getWidthAttribute(?string $value): ?int diff --git a/Models/MixedChart.php b/Models/MixedChart.php index 1580ee549..77eee1522 100644 --- a/Models/MixedChart.php +++ b/Models/MixedChart.php @@ -51,8 +51,8 @@ class MixedChart extends BaseModel public function charts(): MorphMany { Relation::morphMap([ - 'question_chart' => 'Modules\Quaeris\Models\QuestionChart', - 'mixed_chart' => 'Modules\Chart\Models\MixedChart', + 'question_chart' => \Modules\Quaeris\Models\QuestionChart::class, + 'mixed_chart' => \Modules\Chart\Models\MixedChart::class, ]); return $this->morphMany(Chart::class, 'post'); diff --git a/Routes/api.php b/Routes/api.php index 9ff57db62..0e066c402 100644 --- a/Routes/api.php +++ b/Routes/api.php @@ -15,6 +15,4 @@ | */ -Route::middleware('auth:api')->get('/chart', static function (Request $request) { - return $request->user(); -}); +\Illuminate\Support\Facades\Route::middleware('auth:api')->get('/chart', static fn(Request $request) => $request->user()); diff --git a/Tables/Columns/ChartColumn.php b/Tables/Columns/ChartColumn.php index 641937d68..6cf05f47e 100644 --- a/Tables/Columns/ChartColumn.php +++ b/Tables/Columns/ChartColumn.php @@ -45,11 +45,11 @@ class ChartColumn extends Column protected string $view = 'chart::tables.columns.chart-column'; - public function setAnswersChartData(AnswersChartData $answersData): self + public function setAnswersChartData(AnswersChartData $answersChartData): self { - $this->chartData = $answersData->getChartJsData(); - $this->chartType = $answersData->getChartJsType(); - $this->chartOptions = $answersData->getChartJsOptions(); + $this->chartData = $answersChartData->getChartJsData(); + $this->chartType = $answersChartData->getChartJsType(); + $this->chartOptions = $answersChartData->getChartJsOptions(); $this->cachedData = null; // dddx([$this->getCachedData(),$this->getData()]); From 748e6eb52f1ad7773452e79da50d4bb385040fe6 Mon Sep 17 00:00:00 2001 From: marco76tv Date: Tue, 5 Sep 2023 09:09:00 +0000 Subject: [PATCH 5/8] Dusting --- .php-cs-fixer.cache | 2 +- Actions/JpGraph/GetGraphAction.php | 6 +++--- Actions/JpGraph/V1/Bar3Action.php | 2 +- Datas/AnswersChartData.php | 2 +- Routes/api.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache index bfef08c1b..d65165dd5 100644 --- a/.php-cs-fixer.cache +++ b/.php-cs-fixer.cache @@ -1 +1 @@ -{"php":"8.2.10","version":"3.25.0","indent":" ","lineEnding":"\n","rules":{"align_multiline_comment":true,"array_syntax":{"syntax":"short"},"backtick_to_shell_exec":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["return"]},"cast_spaces":true,"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":true,"class_reference_name_casing":true,"clean_namespace":true,"concat_space":true,"curly_braces_position":{"allow_single_line_anonymous_functions":true,"allow_single_line_empty_anonymous_classes":true},"declare_parentheses":true,"echo_tag_syntax":true,"empty_loop_body":{"style":"braces"},"empty_loop_condition":true,"fully_qualified_strict_types":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"global_namespace_import":{"import_classes":false,"import_constants":false,"import_functions":false},"include":true,"increment_style":true,"integer_literal_case":true,"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":{"on_multiline":"ignore"},"native_function_casing":true,"native_function_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["attribute","case","continue","curly_brace_block","default","extra","parenthesis_brace_block","square_brace_block","switch","throw","use"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_null_property_initialization":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"remove_inheritdoc":true},"no_trailing_comma_in_singleline":true,"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","others","return","switch_case","yield","yield_from"]},"no_unneeded_curly_braces":{"namespaces":true},"no_unneeded_import_alias":true,"no_unset_cast":true,"no_unused_imports":true,"no_useless_concat_operator":true,"no_useless_nullsafe_operator":true,"no_whitespace_before_comma_in_array":true,"normalize_index_brace":true,"nullable_type_declaration_for_default_null_value":{"use_nullable_type_declaration":false},"object_operator_without_whitespace":true,"operator_linebreak":{"only_booleans":true},"ordered_imports":true,"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_order":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"semicolon_after_instruction":true,"simple_to_complex_string_variable":true,"single_class_element_per_statement":true,"single_import_per_statement":true,"single_line_comment_spacing":true,"single_line_comment_style":{"comment_types":["hash"]},"single_line_throw":true,"single_quote":true,"single_space_around_construct":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"switch_continue_to_break":true,"trailing_comma_in_multiline":true,"trim_array_spaces":true,"type_declaration_spaces":true,"types_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":true,"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"return_type_declaration":true,"short_scalar_cast":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_indentation":true,"function_typehint_space":true,"declare_strict_types":true,"combine_consecutive_unsets":true,"not_operator_with_successor_space":true,"braces":{"position_after_functions_and_oop_constructs":"same"}},"hashes":{"Database\/Seeders\/ChartDatabaseSeeder.php":"e9a0cbed13c138e24cd6a3d2722d2507","Database\/Factories\/MixedChartFactory.php":"94a428c20b3c40b93a285610d4338559","Database\/Factories\/ChartFactory.php":"a52492954bc2000b2a3f223ba92f5ae2","phpinsights.php":"a903fc759ac88dad061accf0899a2622","Config\/config.php":"24af6b51b9bb0cb3795f130d93ec5bd3","docs\/config.production.php":"0389bfdb2066feea5487831e25c2aa1b","docs\/bootstrap.php":"08c7c136892cf6aadd94bcdb6f64ca34","docs\/listeners\/GenerateSitemap.php":"47198e7919271856d36b88e921c7d3eb","docs\/navigation.php":"4b48df06bfed09cf256c9ffa7a2346c0","docs\/config.php":"9e368edbeff720f8f929e3f83bf443b7","Datas\/ChartData.php":"1802002cd1008c0be28ccbbc0c99da31","Datas\/AnswersChartData.php":"f0a875671bfa5c376ee7c412f01c1d8c","Datas\/AnswerData.php":"d8966e9e66da960868a02d8543286de9","Providers\/RouteServiceProvider.php":"c62b9048288ce5bf3cd9e487014582c6","Providers\/ChartServiceProvider.php":"382e54a95faa1de143c4c36967305e30","Tables\/Columns\/ChartColumn.php":"bc89dac863afe46ac771a2947eeffa3f","Actions\/Chart\/GetFontStyleOptions.php":"0e3183628f3e8e7a81c90c8c72861750","Actions\/Chart\/GetFontFamilyOptions.php":"3c7b5576bf288b7cc8b7cf77885ffe5b","Actions\/Chart\/GetTypeOptions.php":"1977c9cce4a478e7026d6e79702a25d1","Actions\/JpGraph\/V1\/PieAvgAction.php":"0ff2a347e36ae6511173bd6d005bc0b8","Actions\/JpGraph\/V1\/Horizbar1Action.php":"51c9acacfe45372e4d7fe8c64248df2b","Actions\/JpGraph\/V1\/Bar2Action.php":"a5b3759333579e2a397486f4b1f00a7a","Actions\/JpGraph\/V1\/LineSubQuestionAction.php":"32a00d6aa31be891d327e15a0f891f5b","Actions\/JpGraph\/V1\/Pie1Action.php":"6c63693ba738cf06aa70dc5983db6e51","Actions\/JpGraph\/V1\/Bar3Action.php":"911d8b152a2d35fbbe32ff40e3bdd6aa","Actions\/JpGraph\/ApplyPlotStyleAction.php":"b64d4ebd5ba250d0a2e4696edde6923b","Actions\/JpGraph\/GetGraphAction.php":"a90c2fbcf920fe4c8c44642688b52cdf","Actions\/JpGraph\/ApplyGraphStyleAction.php":"4520c1aeaaf48eacc0b862eab5e9f09d","Models\/MixedChart.php":"7867dfb1b803e374d13cd3a97d9e59fb","Models\/BaseModel.php":"a5e5fac12535033db8d5861703e99519","Models\/Chart.php":"e1a0bfb3276bda149e70a4b0fb2acd76","Routes\/web.php":"d8b57a2739d10acaa69603aca186a4f7","Routes\/api.php":"905e49cc806f2d11cc4698d1532d7b04"}} \ No newline at end of file +{"php":"8.2.10","version":"3.25.0","indent":" ","lineEnding":"\n","rules":{"align_multiline_comment":true,"array_syntax":{"syntax":"short"},"backtick_to_shell_exec":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["return"]},"cast_spaces":true,"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":true,"class_reference_name_casing":true,"clean_namespace":true,"concat_space":true,"curly_braces_position":{"allow_single_line_anonymous_functions":true,"allow_single_line_empty_anonymous_classes":true},"declare_parentheses":true,"echo_tag_syntax":true,"empty_loop_body":{"style":"braces"},"empty_loop_condition":true,"fully_qualified_strict_types":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"global_namespace_import":{"import_classes":false,"import_constants":false,"import_functions":false},"include":true,"increment_style":true,"integer_literal_case":true,"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":{"on_multiline":"ignore"},"native_function_casing":true,"native_function_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["attribute","case","continue","curly_brace_block","default","extra","parenthesis_brace_block","square_brace_block","switch","throw","use"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_null_property_initialization":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"remove_inheritdoc":true},"no_trailing_comma_in_singleline":true,"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","others","return","switch_case","yield","yield_from"]},"no_unneeded_curly_braces":{"namespaces":true},"no_unneeded_import_alias":true,"no_unset_cast":true,"no_unused_imports":true,"no_useless_concat_operator":true,"no_useless_nullsafe_operator":true,"no_whitespace_before_comma_in_array":true,"normalize_index_brace":true,"nullable_type_declaration_for_default_null_value":{"use_nullable_type_declaration":false},"object_operator_without_whitespace":true,"operator_linebreak":{"only_booleans":true},"ordered_imports":true,"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_order":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"semicolon_after_instruction":true,"simple_to_complex_string_variable":true,"single_class_element_per_statement":true,"single_import_per_statement":true,"single_line_comment_spacing":true,"single_line_comment_style":{"comment_types":["hash"]},"single_line_throw":true,"single_quote":true,"single_space_around_construct":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"switch_continue_to_break":true,"trailing_comma_in_multiline":true,"trim_array_spaces":true,"type_declaration_spaces":true,"types_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":true,"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"return_type_declaration":true,"short_scalar_cast":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"array_indentation":true,"function_typehint_space":true,"declare_strict_types":true,"combine_consecutive_unsets":true,"not_operator_with_successor_space":true,"braces":{"position_after_functions_and_oop_constructs":"same"}},"hashes":{"Database\/Seeders\/ChartDatabaseSeeder.php":"e9a0cbed13c138e24cd6a3d2722d2507","Database\/Factories\/MixedChartFactory.php":"94a428c20b3c40b93a285610d4338559","Database\/Factories\/ChartFactory.php":"a52492954bc2000b2a3f223ba92f5ae2","phpinsights.php":"a903fc759ac88dad061accf0899a2622","Config\/config.php":"24af6b51b9bb0cb3795f130d93ec5bd3","docs\/config.production.php":"0389bfdb2066feea5487831e25c2aa1b","docs\/bootstrap.php":"08c7c136892cf6aadd94bcdb6f64ca34","docs\/listeners\/GenerateSitemap.php":"47198e7919271856d36b88e921c7d3eb","docs\/navigation.php":"4b48df06bfed09cf256c9ffa7a2346c0","docs\/config.php":"9e368edbeff720f8f929e3f83bf443b7","Datas\/ChartData.php":"d8163f1114aa3bba106fa528ca6df9a7","Datas\/AnswersChartData.php":"f66bc5211c1849b6cf5ab3f008304535","Datas\/AnswerData.php":"68d1433e7ccc02d4540055c3356a6ff4","Providers\/RouteServiceProvider.php":"c62b9048288ce5bf3cd9e487014582c6","Providers\/ChartServiceProvider.php":"382e54a95faa1de143c4c36967305e30","Tables\/Columns\/ChartColumn.php":"041286361f4594ee413e19fcb2cfa4f6","Actions\/Chart\/GetFontStyleOptions.php":"0e3183628f3e8e7a81c90c8c72861750","Actions\/Chart\/GetFontFamilyOptions.php":"3c7b5576bf288b7cc8b7cf77885ffe5b","Actions\/Chart\/GetTypeOptions.php":"f520c3f5a322ba7ac2045bbb6bf6f2e6","Actions\/JpGraph\/V1\/PieAvgAction.php":"064afd3d7feaeaa177f50e1f83f28f1d","Actions\/JpGraph\/V1\/Horizbar1Action.php":"25232f9270d87d1ab3475dd6ca3d9d01","Actions\/JpGraph\/V1\/Bar2Action.php":"9469492f4ccf1f80b0eab13c3a5d886a","Actions\/JpGraph\/V1\/LineSubQuestionAction.php":"33d60aa04f41933feed1a3c9d469bce5","Actions\/JpGraph\/V1\/Pie1Action.php":"08bb442851d45cef364b220f390fe20f","Actions\/JpGraph\/V1\/Bar3Action.php":"b0f0a531eb971d49715a366537ebf900","Actions\/JpGraph\/ApplyPlotStyleAction.php":"f7445db56c54c924b537051c83787bcf","Actions\/JpGraph\/GetGraphAction.php":"05d80fe817e36a806e09e812762f77ab","Actions\/JpGraph\/ApplyGraphStyleAction.php":"50a2915ac9db23a1b7ce431ab8d76c04","Models\/MixedChart.php":"71a423ad11202ff61ac5a377b45d6865","Models\/BaseModel.php":"02caaecfd04927992c9195cfd08f8287","Models\/Chart.php":"45902a3444c4e264ad8ad7e19dc12712","Routes\/web.php":"d8b57a2739d10acaa69603aca186a4f7","Routes\/api.php":"861be0f4991a190e31920a8c4e8c197f"}} \ No newline at end of file diff --git a/Actions/JpGraph/GetGraphAction.php b/Actions/JpGraph/GetGraphAction.php index ae852bf33..ccd0a9ffe 100644 --- a/Actions/JpGraph/GetGraphAction.php +++ b/Actions/JpGraph/GetGraphAction.php @@ -30,15 +30,15 @@ public function execute(ChartData $chartData): Graph $graph->yscale->SetAutoMax($chartData->max); } - if ($chartData->title !== null) { + if (null !== $chartData->title) { $graph->title->Set($chartData->title); $graph->title->SetFont($chartData->font_family, $chartData->font_style, 11); } - if ($chartData->subtitle !== null) { + if (null !== $chartData->subtitle) { $graph->subtitle->Set($chartData->subtitle); $graph->subtitle->SetFont($chartData->font_family, $chartData->font_style, 11); } - if ($chartData->footer !== null) { + if (null !== $chartData->footer) { $graph->footer->center->Set($chartData->footer); $graph->footer->center->SetFont($chartData->font_family, $chartData->font_style, 10); } diff --git a/Actions/JpGraph/V1/Bar3Action.php b/Actions/JpGraph/V1/Bar3Action.php index 597c56509..64d0a3dfb 100644 --- a/Actions/JpGraph/V1/Bar3Action.php +++ b/Actions/JpGraph/V1/Bar3Action.php @@ -82,7 +82,7 @@ public function execute(AnswersChartData $answersChartData): Graph $graph->title->SetFont($chart->font_family, $chart->font_style, 11); } - if (property_exists($chart, 'totali') && $chart->totali !== null) { + if (property_exists($chart, 'totali') && null !== $chart->totali) { $str = ''; foreach ($chart->totali as $k => $v) { $str .= $k . ' ' . $v . ' - '; diff --git a/Datas/AnswersChartData.php b/Datas/AnswersChartData.php index 9e39b09f4..afcd48539 100644 --- a/Datas/AnswersChartData.php +++ b/Datas/AnswersChartData.php @@ -154,7 +154,7 @@ public function getChartJsOptions(): array 'title' => $title, ]; - if ($this->chart->type == 'horizbar1') { + if ('horizbar1' == $this->chart->type) { $options['indexAxis'] = 'y'; } diff --git a/Routes/api.php b/Routes/api.php index 0e066c402..34a0e3000 100644 --- a/Routes/api.php +++ b/Routes/api.php @@ -15,4 +15,4 @@ | */ -\Illuminate\Support\Facades\Route::middleware('auth:api')->get('/chart', static fn(Request $request) => $request->user()); +\Illuminate\Support\Facades\Route::middleware('auth:api')->get('/chart', static fn (Request $request) => $request->user()); From 7d9be5bbc2f0f3e4a1abbe5a6380c46c955e238e Mon Sep 17 00:00:00 2001 From: marco76tv Date: Tue, 5 Sep 2023 09:09:02 +0000 Subject: [PATCH 6/8] Ignore Dusting commit in git blame --- .git-blame-ignore-revs | 1 + 1 file changed, 1 insertion(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index a99ff0a92..b4e2aaa69 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -7,3 +7,4 @@ a0b67dc4e05712dc2a577a5c380880385527e4e1 8ad1d9b8ff0e8c7e8f0825622a2c3c03af8faee5 d5f15a52d72f12a30680a701a795783606dffd21 2d3ea1ca61a37e8c6c3a149d394f89fd89d0c115 +748e6eb52f1ad7773452e79da50d4bb385040fe6 From 6bf45cc06908739c753516cf734a9c54a3a1635a Mon Sep 17 00:00:00 2001 From: marco76tv Date: Tue, 5 Sep 2023 12:06:12 +0200 Subject: [PATCH 7/8] . --- Providers/Filament/AdminPanelProvider.php | 12 ++++++++++++ module.json | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 Providers/Filament/AdminPanelProvider.php diff --git a/Providers/Filament/AdminPanelProvider.php b/Providers/Filament/AdminPanelProvider.php new file mode 100644 index 000000000..cdd978aad --- /dev/null +++ b/Providers/Filament/AdminPanelProvider.php @@ -0,0 +1,12 @@ + Date: Sat, 9 Sep 2023 13:01:43 +0200 Subject: [PATCH 8/8] up --- Datas/AnswersChartData.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Datas/AnswersChartData.php b/Datas/AnswersChartData.php index afcd48539..e92ae6cff 100644 --- a/Datas/AnswersChartData.php +++ b/Datas/AnswersChartData.php @@ -92,6 +92,9 @@ public function getChartJsData(): array } } else { $data = $this->answers->toCollection()->pluck('avg')->all(); + foreach($data as $key => $item){ + $data[$key] = number_format((float)$item, 2, '.', ''); + } if (isset($this->chart->max)) { $sum = collect($data)->sum(); $other = $this->chart->max - $sum;