← Back to team overview

dhis2-devs team mailing list archive

Re: Embed chart - 2.24

 

Thanks Jan & Pooben. I tried to work with the existing JS and managed to
get a bit further:

<html>
<head>
<script src="http://mydhis2.com/dhis-web-commons\javascripts\ext\ext-all.js";
></script>
<script src="http://mydhis2.com/dhis-web-commons/javascripts/plugin/chart.js
"></script>
</head>
<body>
<div id="chart1" style="width:700px; height:400px"></div>
<script>
Ext.onReady(function() {
DHIS.getChart({
"url": "http://mydhis2.com";,
"user": "admin",
"password": "password",
"id": "pNxjHhHRy6Y"
});
});
</script>
</body>
</html>

The problem is now that the calls are being redirected to the login page
which of course don't go well. Is there a better way to authenticate? (my
CORS exceptions are OK).

When i test the individual API calls, they are working (provided I
authenticate properly of course).

I'll try to use the 2.25 advce from Jan.

Martin



On Wed, Aug 30, 2017 at 3:02 PM, Jan Henrik Øverland <jan@xxxxxxxxx> wrote:

> Hi Martin,
>
> Sorry for not offering a complete set of plugins.
>
> There is a chance that the one for 2.25 will work with 2.24.
>
> Please follow this example: https://github.com/
> dhis2/pivot-tables-app/blob/v25/plugin.html
>
> Just replace the link to reporttable.js with http://dhis2-cdn.org/
> v225-1/plugin/reporttable.js
>
> Then refer to your own pivot table favorites (the "id" param in the
> config).
>
> Hope that helps, if not maybe we could find some time to generate plugins
> for 2.24 as well.
>
> Jan
>
> On 30 August 2017 at 14:55, Pooben Dass <pooben@xxxxxxxx> wrote:
>
>> Hi Martin
>>
>> I see so what you looking for is the CDN for 2.24?
>>
>> Do you have a DHIS2.24 version running because then you can access it
>> from your dhis server in these location
>> ../dhis-web-commons\javascripts\ext\ext-all.js
>> ../dhis-web-commons\javascripts\plugin/chart.js
>> ../dhis-web-commons\javascripts\ext\resources\css\ext-plugin-gray.css
>>
>> so something like
>> <script type="text/javascript" src="../dhis-web-commons\javascripts\
>> plugin/chart.js"></script>
>>
>> Regards
>> Pooben
>>
>> On Wed, Aug 30, 2017 at 2:34 PM, Martin Van Aken <martin@xxxxxxxxxxxxxxxx
>> > wrote:
>>
>>> Hi Pooben,
>>> Thanks for you answer. The problem is when i click "embed" on a given
>>> graph I get something like this:
>>>
>>> <html>
>>> <head>
>>> <link rel="stylesheet" href="http://dhis2-cdn.org/v22
>>> 4/ext/resources/css/ext-plugin-gray.css" />
>>> <script src="http://dhis2-cdn.org/v224/ext/ext-all.js";></script>
>>> <script src="http://dhis2-cdn.org/v224/plugin/chart.js";></script>
>>> </head>
>>>
>>> <body>
>>> <div id="chart1" style="width:700px; height:400px"></div>
>>>
>>> <script>
>>>
>>> Ext.onReady(function() {
>>>
>>> DHIS.getChart({
>>>   "id": "pNxjHhHRy6Y"
>>> });
>>>
>>> });
>>>
>>> </script>
>>>
>>> </body>
>>> </html>
>>>
>>> First problem is none of the referenced JS or CSS file exists at the
>>> given url, and I'm not sure what to replace them with. The closest thing I
>>> can find API wise looks to be the 2.22 file (
>>> http://dhis2-cdn.org/v222/plugin/chart.js)
>>>
>>> I also suppose I need to send a user password somewhere ?
>>>
>>> Your code looks like what is needed to generate a "new/custom" chart - I
>>> just want to embed an existing one.
>>>
>>> Martin
>>>
>>> On Wed, Aug 30, 2017 at 8:40 AM, Pooben Dass <pooben@xxxxxxxx> wrote:
>>>
>>>> Hi Martin
>>>>
>>>> What error are you seeing in the browser console?
>>>>
>>>> can you try this ?
>>>>
>>>> DV.plugin.getChart({
>>>> url : base,
>>>> el : 'chart1',
>>>> type : 'bar',
>>>> columns : [ {dimension : 'in',items : [ {id : '?? } ] } ],
>>>> rows :  [{dimension : 'ou',items : x } ],
>>>> filters : [ {dimension : 'pe',items : [ {id : period} ]} ],
>>>> showData : true,
>>>> });
>>>>
>>>> Regards
>>>> Pooben
>>>>
>>>> On Mon, Aug 28, 2017 at 4:32 PM, Martin Van Aken <
>>>> martin@xxxxxxxxxxxxxxxx> wrote:
>>>>
>>>>> Hi,
>>>>> I'm trying to embed chart using a 2.24 version. Jan did help me a
>>>>> while ago with a 2.22 version, but when I go to the doc for the 2.24 it
>>>>> does not look up to date - https://docs.dhis2.org/2.24/
>>>>> en/developer/html/dhis2_developer_manual_full.html#d7652e7049. From
>>>>> the CDN it looks like there is no JS package there for 2.24 -
>>>>> https://dhis2-cdn.org/
>>>>>
>>>>> Is the JS code the same than for 2.25 or 2.22 (the two closest
>>>>> versions where there is something on the CDN?). Has anyone a running
>>>>> example of an embed on 2.24 ?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Martin
>>>>>
>>>>> --
>>>>> *Martin Van Aken - **Freelance Enthusiast Developer*
>>>>>
>>>>> Mobile : +32 486 899 652
>>>>>
>>>>> Follow me on Twitter : @martinvanaken
>>>>> <http://twitter.com/martinvanaken>
>>>>> Call me on Skype : vanakenm
>>>>> Hang out with me : martin@xxxxxxxxxxxxxxxx
>>>>> Contact me on LinkedIn : http://www.linkedin.com/in/martinvanaken
>>>>> Company website : www.joyouscoding.com
>>>>>
>>>>> _______________________________________________
>>>>> Mailing list: https://launchpad.net/~dhis2-devs
>>>>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>>>>> Unsubscribe : https://launchpad.net/~dhis2-devs
>>>>> More help   : https://help.launchpad.net/ListHelp
>>>>>
>>>>>
>>>>
>>>> *This message and any attachments are subject to a disclaimer published
>>>> at http://www.hisp.org/policies.html#comms_disclaimer
>>>> <http://www.hisp.org/policies.html#comms_disclaimer>.  Please read the
>>>> disclaimer before opening any attachment or taking any other action in
>>>> terms of this electronic transmission.  If you cannot access the
>>>> disclaimer, kindly send an email to disclaimer@xxxxxxxx
>>>> <disclaimer@xxxxxxxx> and a copy will be provided to you. By replying to
>>>> this e-mail or opening any attachment you agree to be bound by the
>>>> provisions of the disclaimer.*
>>>>
>>>
>>>
>>>
>>> --
>>> *Martin Van Aken - **Freelance Enthusiast Developer*
>>>
>>> Mobile : +32 486 899 652
>>>
>>> Follow me on Twitter : @martinvanaken <http://twitter.com/martinvanaken>
>>> Call me on Skype : vanakenm
>>> Hang out with me : martin@xxxxxxxxxxxxxxxx
>>> Contact me on LinkedIn : http://www.linkedin.com/in/martinvanaken
>>> Company website : www.joyouscoding.com
>>>
>>
>>
>> *This message and any attachments are subject to a disclaimer published
>> at http://www.hisp.org/policies.html#comms_disclaimer
>> <http://www.hisp.org/policies.html#comms_disclaimer>.  Please read the
>> disclaimer before opening any attachment or taking any other action in
>> terms of this electronic transmission.  If you cannot access the
>> disclaimer, kindly send an email to disclaimer@xxxxxxxx
>> <disclaimer@xxxxxxxx> and a copy will be provided to you. By replying to
>> this e-mail or opening any attachment you agree to be bound by the
>> provisions of the disclaimer.*
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~dhis2-devs
>> Post to     : dhis2-devs@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~dhis2-devs
>> More help   : https://help.launchpad.net/ListHelp
>>
>>
>
>
> --
> Jan Henrik Øverland
> Software developer, DHIS 2
> University of Oslo
> http://www.dhis2.org <https://www.dhis2.org/>
>



-- 
*Martin Van Aken - **Freelance Enthusiast Developer*

Mobile : +32 486 899 652

Follow me on Twitter : @martinvanaken <http://twitter.com/martinvanaken>
Call me on Skype : vanakenm
Hang out with me : martin@xxxxxxxxxxxxxxxx
Contact me on LinkedIn : http://www.linkedin.com/in/martinvanaken
Company website : www.joyouscoding.com

References