Giter Site home page Giter Site logo

Comments (12)

PhaedrusTheGreek avatar PhaedrusTheGreek commented on September 16, 2024 1

@YanekR I'll see if I can figure it out.

from transform_vis.

PhaedrusTheGreek avatar PhaedrusTheGreek commented on September 16, 2024 1

I'll be supplying a more realistic example shortly

from transform_vis.

PhaedrusTheGreek avatar PhaedrusTheGreek commented on September 16, 2024 1

OK here we have a complete working example using ES data. There was a variable binding bug that had to be fixed to get this to work, so 6.2.2 was re-released:

https://github.com/PhaedrusTheGreek/transform_vis/blob/master/RECIPES.md#custom-d3

from transform_vis.

PhaedrusTheGreek avatar PhaedrusTheGreek commented on September 16, 2024

It is possible to import a library like this:

Javascript:

({
 import_some_lib: function() {
    $.getScript( "/path/to/script.js", function( data, textStatus, jqxhr ) {
        console.log("Import Complete");
    }); 
 }
})

Mustache:

{{meta.import_some_lib}}

When I tested this, it worked, but there were some issues with resource paths that had to be hacked out.

from transform_vis.

xycloud avatar xycloud commented on September 16, 2024

yes, if we can import third party js lib in this plugin, which is really awesome

from transform_vis.

PhaedrusTheGreek avatar PhaedrusTheGreek commented on September 16, 2024

I recently pushed some changes so that this is also possible by using a <script> tag inside the template like this:

<script src="http://www.site.com/some.min.js"/>
<script src="/path/to/some.js"/>
<script>
        $('.myButton').doSomethingNew();
</script>
<a href=# class="myButton">Do It</a>

EDIT: This won't work anymore due to tighter security around XSS control. Use this method instead

from transform_vis.

xycloud avatar xycloud commented on September 16, 2024

awesome, which bring with more imagination for this plugin

from transform_vis.

YanekR avatar YanekR commented on September 16, 2024

@PhaedrusTheGreek Would you be able to create a small manual how to, as for me above solution does not work for both d3.js & chart.js lib's.

from transform_vis.

PhaedrusTheGreek avatar PhaedrusTheGreek commented on September 16, 2024

This is now possible as of some changes in 6.2.2. I added an after_render function that is executed after the HTML is rendered, so that D3 might be able to select an element at that point.

I posted an example in the Javascript section of the docs

screen shot 2018-02-22 at 12 04 33 pm

Also note that D3 is already included in the Kibana distrbution so it doesn't need to be imported. If it was necessary to import a library, you could use this method

from transform_vis.

YanekR avatar YanekR commented on September 16, 2024

@PhaedrusTheGreek could you please clarify how can I refer to the outcome of one function in other one? example below:
({
function_one: function() {
var object_one = [];
return object;
}

function_two: function() {
	var object_two = function_one();
	return object_two
}

})

Mustache Syntax example:

{{meta.function_one}} is equal to {{meta.function_one}}

Will appreciate your help,
Yanek_R

from transform_vis.

guanghaofan avatar guanghaofan commented on September 16, 2024

It is possible to import a library like this:

Javascript:

({
 import_some_lib: function() {
    $.getScript( "/path/to/script.js", function( data, textStatus, jqxhr ) {
        console.log("Import Complete");
    }); 
 }
})

Mustache:

{{meta.import_some_lib}}

When I tested this, it worked, but there were some issues with resource paths that had to be hacked out.

what I found it it will throw exception and says can not found the lib...something like this while log out and re-login Kibana:

TypeError: $(...).CanvasJSChart is not a function (http://tdexample01:6789/bundles/commons.bundle.js line 22 > eval:42)

Version: 6.4.4-SNAPSHOT
Build: 18067

Error: TypeError: $(...).CanvasJSChart is not a function (http://tdexample01:6789/bundles/commons.bundle.js line 22 > eval:42)
window.onerror@http://tdexample01:6789/bundles/commons.bundle.js:12:869171

from transform_vis.

guanghaofan avatar guanghaofan commented on September 16, 2024

now my solution is just add the third party js lib into the project dependency and declare it in the response handler js code.
I have successed to add plotly.js as my js lib, then we never need to manual import it in the js template.

from transform_vis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.