AMChart handleClick to retrieve data from database based on item clicked - events

I'm using AMChart stacked chart to report test execution status from DB. Php file with query is feed into the dataLoader and the stacked columns displays Pass, Fail and NoRun count data for each category. I'm trying to use handleClick function to make the column clickable and once clicked, a query is fired to retrieve data specific to that column's Pass, Fail or NoRun count data and displays the data on the same page. I'm not sure how to implement this. Any help is greatly appreciated!
Below is all I have so far, clicking the column triggers an alert with name of the category and a count, my goal is to be able to trigger a php file with parameters passed in and display data from DB,
// add click listener
chart.addListener("clickGraphItem", handleClick);
function handleClick(event)
{
alert(event.item.category + ": " + event.item.values.value);
}

The issue has been resolved by using JSON (converted from DB data in PHP) and AJAX to display. Within handleClick I call another JS function and pass in the graph variables that the query inside PHP needs.

Related

Dynamic text in master page of Birt report

Can dynamic text be entered into a header or footer of a master page?
I have placed dynamic text into a grid which then sits in the master page footer, this doesn't work and gives error:
ReportDesign (id = 1):
+ Invalid javascript expression: ReferenceError: "row" is not defined. (<inline>#1)
When I test the expression in the footer of the report layout itself this works.
Please see the expression below:
if( BirtComp.lessOrEqual( row["Aggregation"], "1,500.00" )){"user1.jpg"}
else if (BirtComp.greaterThan(row["Aggregation"], "1,500.00")){ "user2.jpg"}
The easiest way to use dynamic text in the master page is as follows:
Optional, but recommended: Create a dataset "MasterPage" which selects the dynamic data that you need.
Create a grid in the page footer (and/or header) of the master page.
Bind the grid to the dataset "MasterPage".
Use dynamic text items and data items inside the grid as you like.
Important:
The grid uses only the first row returned by your dataset.
Thus, it is best practice to create the dataset in such a way that it will return exactly one row.
This means that BIRT aggregation functions won't work here.
If your "MasterPage" dataset is JDBC based, you can of course use SQL aggregation functions like SUM, COUNT etc.
It is not possible to access "the current first record for the current page" this way: The "MasterPage" dataset returns one record for the whole report.

How to load datatable on change of dropdown

I have a view where there is a dropdown and datatable.
At initial load, I am loading the values to be loaded in the datatable based on the first select of dropdown and on change of dropdown, I want to fetch data based on that condition and populate those data on the datatable.
Please anyone suggest a way to do this!
I am trying a way using get request but it is reloading the page and hence I am unable to make the data persist in the datatable.
I followed exactly this https://laracasts.com/discuss/channels/laravel/filtering-data-using-drop-down-onchange-event
Data is coming and populates to the datatable but just after a second, it reloads and comes to old data in datatable.
Please either correct my or suggest some new way to do it!
After debugging, I found that in one of the js file included, there were a code
$(document).ajaxStop(function() {
window.location.reload();
});
Since, this code was making it to reload on every ajax call completes, I faced this issue.

Not retaining values after save

In my application I am using jqGrid to display the data from database, user can update the values and save the data in database. I have a paging in the grid.
I want to implement 2 things --
--- After I save values in the database, jqGrid columns become blank. I want to retain the values in column after save.
--- When I update the values on one page and goes to second page and again I come back to first page, I want to retain the values on the first page.
Is that possible?
If you edited data locally (on grid which has datatype: "local") then you can use grid.jqGrid("getGridParam", "data") to get the current (modified) data. you can send the data to the server via $.ajax call.

How to Update Jquery Data Table

I am using Jquery data table plugin. I was able to display it properly with filtering, sorting and Paging.
But, now the problem is i need to filter the data table rows based on dropdown selection made.
but, i do not have any idea how to do this..I am very new to MVC. So, here i need to send that dropdown selected item as parameter to a server side method and call a method and rebind data to the data table.
I am initially binding data to the data table using for loop and iterating over a datatable
Do i need to use Ajax here..if so how to get the new datatable/data to this view and bind to data table?
Please suggest the way to do..
you use the jquery datatable for this
create function and paste jquery datatable code in there
then call this function on dropdown selection change using jquery.
Tips :jquery datatable code available on net find and use it

Filtering data for d3.js sankey diagrams

I'm trying to have a d3.js Sankey visualisation filter a data set according to categories.
I'm using d3.csv method to input the data as shown in this example - http://bl.ocks.org/timelyportfolio/5052095
I would however like to upload a data set with four columns -
source, target, value, category
My aim is to have a visualisation with the ability to switch between categories. So each Sankey visualisation will only represent one particular category. Then user can switch from the dropdown to another one.
Is this possible using the current d3.csv input method?
Would this work ?
d3.csv("file.csv", function(data) {
[...]
// Called each time there is an action on the dropdown menu
function updateGraph() {
// Select only data that are tagged with a certain category
var dataset = data.filter(function(d) { return d.category == selectedCategory; });
// Update graph visualization
}
}
This way you wouldn't have to reload your csv file each time.
This a very long method for the second part but, creating multiple html/php and csv files depending on your categories and then adding the following code in each of your html/php files. This method would be extra work if you have a lot of categories.
Category 1
category 2
If you figured out a solution the way you were trying it, then if possible please update your answer. it would be helpful.
Thanks.

Resources