2
I’m trying to plot a hierarchy chart on the page using a plugin Angular from this tutorial. Even looking at the demo and trying to put them that way
When I load the page, the page does not work...
That way:
<organization-chart [datasource]="ds"></organization-chart>
There is no error, but when I click on the route where the page is, the route does not load, but when I take the Component, from the plugin the route works again
But this same organizational chart I was able to load using html with javascript and jquery,
There’s a way I could use that same strategy?
Load javascript and css plugins at the angle since the component does not work?
This was the way I managed to assemble this organizing chart in Jquery with javascript and css plugin
const buscarDados = () => {
$.ajax({
url: "{{ route('medidor.hierarquia') }}",
type: "get",
dataType: "json"
}).done( r => {
mountHieraquy(r)
/*setTimeout(() => {
buscarDados()
}, 5000);*/
})
}
const mountHieraquy = ( obj ) => {
$('#chart-container').html('')
$('#chart-container').orgchart({
data:obj,
visibleLevel: 2,
nodeTemplate: nodeTemplate,
//zoom: true,
pan: true
})
$('.ip_medidor').on('click', function(){
const ip = $(this).data('ip')
sessionStorage.setItem('medidor', ip)
sessionStorage.setItem('opcao', 1)
sessionStorage.setItem('errorCount', 0)
//location.href= ;
const url = ip.indexOf("120") != -1 ? "{{ route('medidor.sepam') }}" : "{{ route('medicao.monitoramento') }}"
window.open( url, '_blank');
})
}
As link and style
Is there a way you can take that code to Angular?
The files I added were
html2cancas.min.js
jquery.orgchart.js
jquery.orgchart.min.js
jquery.orgcart.css
jquery.orgchart.min.css
Each case is a case, just testing it. But, the import of the files can be done normally by placing them inside the tag scripts in the archive
angular.json
nay?!– LeAndrade
There how I would do the function up in the component?
– adventistaam
Removes the const and the Arrow Function function and declares it normally in the component:
buscarDados() {...
– LeAndrade
With all this jquery too?
– adventistaam
Yes, the function does not use jQuery? jQuery, Typescript is all Javascript!
– LeAndrade
Really, it worked! Please add the answer
– adventistaam