OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – HTML, JavaScript, CSS, Design Questions javascript amChart as a page-component

This topic contains 6 replies, has 2 voices, and was last updated by  adriwan_kenoby 7 years ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #34656

    adriwan_kenoby
    Participant

    Hi everybody,

    I am trying to use amCharts as page-component. I think that my probleme maybe is I don’t define dependencies correctly OR it’s because of the amChart code don’t respect the requirejs standard API , I need help to better undestood the front-end architecture.

    This is the inline code of an amChart : https://www.amcharts.com/demos/date-based-data/

    This is an example using requirejs : http://www.amcharts.com/tips/using-requirejs-with-amcharts/

    And this is my code for replace it as a page-component:

    The view.html.twig ( whose extend OroUIBundle:actions:view.html.twig and where sondeData is an associative array ) :

    And the yaml configuration file for requirejs :

Viewing 6 replies - 1 through 6 (of 6 total)
  • Author
    Replies
  • #34657

    Hryhorii Hrebiniuk
    Participant

    Hello @adriwan_kenoby,

    You did everything right, defining modules over requirejs.yml configuration. But this is not enough, amCharts needs init-function in shim configuration. And it is not possible to define a function in yml-configuration file. For such cases we have workaround, that allows us to configure requirejs in JavaScript syntax. See Runtime require.js main config extension.

    In other words, you have to define requirejs.config.js.twig in your bundle

    And declare this template file as content for requirejs_config_extend placeholder:

    #34658

    adriwan_kenoby
    Participant

    Thanks a lot @Hryhorii,

    I had forgot to talk about that init function and in fact I had notice that it is not configurable in yaml file.

    In requirejs.config.js.twig should I use require.config({…}) instead of require() ?

    I have still an error on the rendering but it is in the amcharts.js file, their is an undefined element.

    Any idea ?

    #34659

    adriwan_kenoby
    Participant

    My error was that i pass $elem in makeChart(), but this method use an id.

    #34660

    adriwan_kenoby
    Participant
    #34661

    adriwan_kenoby
    Participant

    My chart can’t be loaded since upgrade 2.0. I don’t understand why. What are the changes I have to make ?

    #34662

    adriwan_kenoby
    Participant

    It seems that placeholders.yml is not loaded properly. I had move it under Resources/config/oro and it look like this :

    What is the problem ?

Viewing 6 replies - 1 through 6 (of 6 total)

The forum ‘OroPlatform – HTML, JavaScript, CSS, Design Questions’ is closed to new topics and replies.

Back to top