Custom Sales by Month Chart - No Advanced Pack

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jyamada
    Junior Member
    • Aug 2026
    • 8

    #1

    Custom Sales by Month Chart - No Advanced Pack

    I have a custom dashlet, I need to fill it with a chart of gallons collected by user, per month. The Sales by Month seems to do part of that, but I need it on my entity, not on Opportunities. Client does not want to use the Advanced Pack. I couldn't find the sales by month dashlet in the source code, I'm guessing it's not there.

    It doesn't even really need to be a chart, it just needs to be able to sum all of a field. Though last week I was struggling with getting that to work.

    It doesn't help that my javascript is extremely rusty, but I'm slowly remembering things.
  • yuri
    EspoCRM product developer
    • Mar 2014
    • 10001

    #2


    ​​​​​​https://github.com/espocrm/espocrm/b...es-by-month.js

    Comment


    • jyamada
      jyamada commented
      Editing a comment
      Ah yep. Entirely my fault, I looked in client/src, not client/modules/crm/src
  • jyamada
    Junior Member
    • Aug 2026
    • 8

    #3
    Problem before getting to the dashlet. I made a custom entity in the instance, I'm trying to replicate it inside the extension so everything is in one place. I have the

    src\files\custom\Espo\Modules\ext\Resources\metada ta\entityDefs\ json copied from the running docker instance (EDIT: for some reason it's putting a space in metadata, I'm certain the path is correct in my editor)

    and the src\files\custom\Espo\Modules\ext\Entities\ php.

    I'm copying off the real estate extension. The extension compiles and uploads, but it doesn't show up in the entity manager. Is there a file I'm missing? Do I need to set up a view?

    PHP Code:
     namespace Espo\Modules\ext\Entities;
       use Espo\Core\ORM\Entity;
       class customCollection extends Entity  {
         public const ENTITY_TYPE = 'customCollection';
    } 
    
    That's all that's in the php, I'm unsure what else needs to go here
    Last edited by jyamada; Yesterday, 11:12 PM.

    Comment

    • eymen-elkum
      Active Community Member
      • Nov 2014
      • 496

      #4
      You are dealing with two separate tasks:
      1. Registering the custom entity inside your extension.
      2. Creating the “gallons by month” chart.

      I would solve the entity registration first, because the chart will depend on it.

      1. Why the entity is not appearing

      Copying only the PHP entity class and entityDefs is usually not enough.

      The PHP class represents the entity in the backend, while entityDefs describes its fields and relationships. EspoCRM still needs a scope definition to register the entity type.

      Check that your extension contains a file similar to:
      files/custom/Espo/Modules/YourModule/Resources/metadata/scopes/YourEntity.json

      The exact content depends on the entity type, but it should register the scope as an entity/object and specify the appropriate type or template.

      Also verify that the entity name uses exactly the same spelling and capitalization everywhere:
      Resources/metadata/scopes/YourEntity.json
      Resources/metadata/entityDefs/YourEntity.json
      Entities/YourEntity.php

      Inside the PHP class, ENTITY_TYPE should also match the same name.

      For a complete entity, you will normally also need some of the following:
      Resources/metadata/clientDefs/YourEntity.json
      Resources/layouts/YourEntity/
      Resources/i18n/en_US/YourEntity.json
      Controllers/YourEntity.php

      clientDefs, layouts and translations control how the entity is displayed in the UI. A custom client view should not be required just to make the entity appear.

      After building the extension, open the generated ZIP and verify that these files are actually present below:
      files/custom/Espo/Modules/YourModule/

      Checking the generated ZIP is important because having a file under your project’s src/files directory does not guarantee that it was included in the final package.

      After installing the corrected package, run a rebuild and clear the EspoCRM cache.


      2. Creating the monthly gallons chart

      Once the entity works, the existing “Sales by Month” dashlet is a good example to start from. You do not need to reproduce the whole Reports feature.

      Your server-side code only needs to return data similar to:
      [
      {"month": "2026-01", "value": 1200},
      {"month": "2026-02", "value": 1450},
      {"month": "2026-03", "value": 1310}
      ]

      The query should:
      • Read records from your custom entity.
      • Filter them by the required date range.
      • Group them by year and month.
      • Calculate SUM(gallons) for each month.
      • Optionally group by the assigned user if you need a separate series for every user.

      Then the dashlet’s JavaScript can pass the returned labels and values to the same chart component used by “Sales by Month.”

      If the client only needs one value, such as “total gallons this month,” a numeric KPI dashlet would be simpler. But if they need to compare several months, the chart approach is the correct one.

      I suggest starting with the smallest version:
      1. Make the entity appear and confirm that records can be created.
      2. Return the monthly totals from a backend endpoint.
      3. Display one chart series containing the total gallons.
      4. Add grouping by user only after the basic chart works.

      It may be useful to review our extension: Ebla Dash Pro

      Eblasoft | EspoCRM specialists since 2014
      Consulting · Development · Integrations · Premium Extensions
      .

      Comment

      Working...