How to customize the title and tooltip in ux-chartjs? - symfony

I made a chart with Symfony UX and chartJs. Everything works but when I want to customize it, it become a problem and I can't find a good docs for that.
My chart is done and now I want to customize the tooltip and the title, I did like that :
$chart->setOptions([
'responsive' => true,
'title' => [
'display' => true,
'text' => 'test',
'color' => '#ce1111',
],
'tooltips' => [
'backgroundColor' => '#ce1111',
'titleColor' => '#000'
]
]);
For the title, it displays 'test' but the color doesn't work even if I replace it with titleColor.
For tooltips the backgroundColor works but not the titleColor.
Anyone has already solved this problem ?

I found it, sorry for the question but the docs is different. I post here how I dit it :
$chart->setOptions([
'responsive' => true,
'title' => [
'display' => true,
'text' => strtoupper('test'),
'fontColor' => '#ce1111',
'fontSize' => 16
//'padding' => 50
],
'tooltips' => [
'backgroundColor' => '#fff',
'bodyFontColor' => '#000',
'bodyFontSize' => 16,
],
'legend' => [
'labels' => [
'fontColor' => "#ce1111",
'fontSize' => 16
]
]
]);

Related

How to add title to axes with chartjs on Symfony UX

I made a chart with Symfony UX and chartJS. All work but i'm battling with the customization.
Has someone succeed to add titles to axes on a chart with chartjs with Symfony UX. I'm trying differents options but I don't know why the title for yAxes and xAxes don't work.
Here is my code :
$chart->setOptions([
'responsive' => true,
'legend' => ['display' => false],
'title' => [
'display' => true,
'text' => 'Title of the graph',
'fontSize' => 16
],
'scales' => [
'yAxes' => [
'title' => [
'display' => true,
'text' => 'Title for y Axes',
]
],
],
]);
The code for the title works perfectly but the title for yAxes do not work.
Has anyone solve this ?

WP Elementor Choose Control Prefix Class Prefixed %s String Format

I am having trouble with elementor prefix class using with CHOOSE control
Here is code snippet
$this->add_responsive_control(
'course_author_layout',
[
'label' => __('Layout', 'text-domain'),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __('Left', 'text-domain'),
'icon' => 'fa fa-long-arrow-left',
],
'up' => [
'title' => __('Center', 'text-domain'),
'icon' => 'fa fa-long-arrow-up',
],
],
'prefix_class' => 'etlms-author-layout-%s',
'default' => 'left',
]
);
Problem is here in prefix_class. In the HTML Markup prefix class is showing with %s but there should only show value.
Current scenario of class : etlms-author-layout-%sleft
Expected result of class : etlms-author-layout-left
Just remove the %s, then you will get the expected result.

Allow spaces when using Select2 tags symfony

I try to create tags if not exist by using select2 entity. When I try to add a tag that contains spaces I can't.
For example :
"Yupi yola" --> not work because tag contains spaces, is getting only first word "Yupi".
"Test" ---> work
"Test_test" ---> work
I added the Select2Entity in my form type
->add('groupe', Select2EntityType::class, [
'remote_route' => 'route',
'class' => Class::class,
'primary_key' => 'id',
'text_property' => 'name',
'minimum_input_length' => 2,
'page_limit' => 10,
'allow_clear' => true,
'delay' => 250,
'cache' => true,
'cache_timeout' => 60000, // if 'cache' is true
'language' => 'en',
'placeholder' => 'Select a group',
'allow_add' => array(
'enabled' => true,
'new_tag_text' => '',
'tokenSeparators'=> '[",", " "]'
),
'multiple' => false,
'attr' => ['style' => 'width:100%'],
'scroll' => true,
])
Please help me. Thx in advance.
Instead of 'tokenSeparators', use 'tag_separators'
'allow_add' => array(
'enabled' => true,
'new_tag_text' => '',
'new_tag_prefix' => '__',
'tag_separators'=> '[",", " "]'
)

Translations are not saved correctly using A2lix Translation + KnpLabs DoctrineBehaviors

In my Symfony project I use SonataAdminBundle and A2lixTranslationForm + KnpLabsDoctrineBehaviors bundles for multi-language support.
I have Serial and Episode entities which use standard OneToMany and ManyToOne relationship. I display episodes using sonata_type_collection:
->add('episodes', 'sonata_type_collection', [
'by_reference' => false,
],
[
'edit' => 'inline',
'inline' => 'table',
]
)
By default A2lixTranslation bundle displays translatable fields under each other. However, I need to display each translation field of the episode in its own column. In order to achieve this, I created three virtual fields with the same property_path:
->add('episode_title', 'a2lix_translations', [
'property_path' => 'translations',
'fields' => [
'title' => [
'attr' => [
'pattern' => false,
],
'label' => false,
],
],
'exclude_fields' => ['subTitle', 'description'],
'label' => 'Title',
])
->add('episode_subtitle', 'a2lix_translations', [
'property_path' => 'translations',
'fields' => [
'subTitle' => [
'label' => false,
],
],
'exclude_fields' => ['title', 'description'],
'label' => 'Subtitle',
'required' => false,
])
->add('episode_description', 'a2lix_translations', [
'property_path' => 'translations',
'fields' => [
'description' => [
'field_type' => 'textarea',
'label' => false,
],
],
'exclude_fields' => ['title', 'subTitle'],
'label' => 'Description',
'required' => false,
])
As you can see, I display only one field in each a2lix_translations form.
But I faced the following problem: only the last field value (description in this case) is saved when I add new episode using Add new button of the collection form and then clicking Update button of the parent (Serial) form. Wherein already existing episodes are saved correctly if edited.
Could you please point me why is this happening and how to fix the issue. I suppose each translations form values rewrite the previous ones, but why do this work normally when saving existing records?
Or maybe there is another way to display each field in the own column in sonata collection form, this also will be helpful.
Thank you.

Display data attributes in collection field Symfony 2

I have 2 fields in my form. First Name and Email.
$builder->add('firstName', 'text', [
'label' => 'First Name',
'required' => true,
'attr' => [
'data-msg-required' => 'First name is required'
],
'trim' => true])
->add('emails', 'collection', [
'type' => new RegisterEmail,
'required' => true,
'by_reference' => false,
'label' => false,
'options' => [
'attr' => [
'data-msg-required' => 'Email is required'
]
],
]);
However data-msg required is only displayed for first field but not for second one. I know I can add that directly in twig template but is there anyway I can achieve that through form class only.
You should add it to the default value of the RegisterEmail type, with setDefaults()

Resources