Adding additional dynamic to a canonical view Wasn't sure exactly what to search for in trying to find recommendations for this.

I have created a custom content entity type with some numerical fields. The canonical view for this entity uses "views_data" = "Drupal\views\EntityViewsData" as specified in the entity definition annotation. This entity type does not depend on node. Some modifications are made to the display of the field data using hook_entity_view_alter and hook_page_attachments. This is all working fine.

What I would like to do is two things:

1) add an additional HTML section to the canonical view, below the display of all the entity parameters, which displays the results of a database query. The query being executed will depend on the content of the entity being loaded. Currently I am just using "echo" to test, but that spits the results out at the top of the document.

2) add a form to the canonical view containing one text field, one dropdown, and one button. The contents of the dropdown will also depend on the entity field content. The button should perform some calculations on the numerical fields based on the form inputs, and adjust the build array contents accordingly after reloading the page.

I am not really sure what approach to take here or how to execute it, and would like to ask for recommendations and examples to look at. Should I be creating a custom class that extends Drupal\views\EntityViewsData to accomplish all of this? Should I be doing this with Twig instead (which I am not very familiar with and can't seem to find many examples similar to what I'm trying to do)? Would using jQuery instead be a better approach?
This would be the answer to the two questions:

1) add additional HTML to the canonical view

When using hook_ENTITY_TYPE_view() you have a render array and you can place new array keys with additional render elements. Don't use echo for testing, put it in the build array like this:

$build['text1'] = ['#markup' =&gt; '&lt;p&gt;Text 1&lt;/p&gt;'];


2) add a form to the canonical view

Build a form class for this form. Then you can place the form also in hook_ENTITY_TYPE_view():

$build['myform'] = \Drupal::formBuilder()-&gt;getForm('Drupal\mymodule\Form\MyForm');


You can pass additional parameters in getForm(), if you need information from the entity to build the form.

I don't understand what you are trying to do with Drupal\views\EntityViewsData. Other than mentioning this one class you are not writing anything else about views.