Is there a "rendering complete" event I can use with Dojo Charts? - dojo

I would like to show a loading icon while my Dojo Charts are loading and then hide it when the charts are finished rendering. I cannot find documentation that defines what event I can add a dojo.connect to when the chart has finished rendering. For example, I am doing something similar with the ArcGIS mapping API (built on Dojo) where I have a loading icon displayed when the map updates and then I hide it when the map is finished updating using this line of code:
dojo.connect(map, "onUpdateEnd", hideLoading);
I have tried "onUpdateEnd", "onStartup", "postCreate" with no luck. Anyone know if there is a "rendering complete" event I can use with Dojo Charts?

For any one else that requires to listen on a completion of any method of almost any dojo object, look at dojo/aspect.
http://dojotoolkit.org/reference-guide/1.10/dojo/aspect.html
Sample code:
aspect.after(this.chart, "render", function () {
//your code here
console.log("render completed");
});

Related

How to customize Pull-To-Refresh indicator style in NativeScript/Vue?

I am trying to customize the style of Pull-To-Refresh indicator in NativeScript/Vue app. There seems to be no example code for Vue. I tried to place the following code adapted from Angular into , got errors when running the app.
<RadListView.pullToRefreshStyle>
<PullToRefreshStyle indicatorColor="white" indicatorBackgroundColor="blue"/>
</RadListView.pullToRefreshStyle>
Can anybody offer a working example or update the following page?
https://docs.nativescript.org/vuejs/ns-ui/ListView/pull-to-refresh
On a side note, according to doc here:
https://docs.nativescript.org/ns-ui-api-reference/classes/pulltorefreshstyle
Only color and background color can be customized. Is there anyway to get around this change size of indicator?
The only way I can think of is to set both foreground and background of indicator to transparent then use page level activityIndicator.
Just set the attributes on pullToRefreshStyle property
HTML
<RadListView :pullToRefreshStyle="pullToRefreshStyle">
Script
import * as colorModule from "tns-core-modules/color";
data() {
return {
pullToRefreshStyle: {
indicatorColor: new colorModule.Color("red"),
indicatorBackgroundColor: new colorModule.Color("green")
}
};
}

Interactive vega-lite / vega chart with selection

I'm trying to build an interactive vega-lite dashboard where I have got this world map vega editor link
Based on the selection of a country I'm trying to display another graph below(vconcat or outside)
Is it possible to do it outside this chart without using vconcat or I can do it only by vconcat?
Has anyone tried something similar?
The easiest would be to create with vconcat.
That said, there is a way to read the underlying Vega signal of the selection. Then you can use the Vega View API to trigger callback that shows another chart based on the selected data.
You can now use observable notebooks to achieve what you want.
You create you first chart in a cell, link it to a second cell and then export the cells in your web site.
Here's how to start in observable
Here is the central part of the code
letter_selected = Generators.observe(
// selection_caught will (yield) a value promise with the selected letters
function initialize_f(change_) {
// creating an event listener (ie a function to attach to some DOM element)
const signaled = (name, value) => change_(value);
// attaching the event listener and naming it "test_selection"
barChart.addSignalListener("test_selection", signaled);
// check the doc ... https://github.com/observablehq/stdlib
change_(barChart.signal("test_selection"));
function dispose_f() {
return barChart.removeSignalListener("test_selection", signaled);
}
return dispose_f;
}
)

Durandal view no more displayed if user click quickly on menus

I use Durandal 2.0 & Breeze in my SPA.
I have a sidebar menu for my drivers (Chauffeurs) where user can click on submenus (Récents, Disponibles, Indisponibles) for calling my view with different parameters. This will fill a koGrid with data. The data is fetched in the activate call and the binding of the koGrid is done in the compositionComplete.
Everything goes well most of the time. Things goes wrong when I click very quickly on submenus (calling the same view). Example: I click on 'Récents' and immediately (without waiting for the view to display) I click on 'Disponibles'.
I have the following for the activate:
var activate = function (filterParam) {
filter(filterParam);
pagedDataSource.getDataFunction = getData;
pagedDataSource.getPredicatesFunction = getPredicates;
return pagedDataSource.reload();
};
And I have the following code for the compositionComplete:
var compositionComplete = function (view) {
bindEventToList(view, '.kgCellText', gotoDetails);
$('#mySearchGrid').attr('data-bind', 'koGrid: gridOptions');
ko.applyBindings(vm, document.getElementById('mySearchGrid'));
};
When I trace the activity, I noted that if user click quickly on submenus, the activate does not have the time to finish and is called again (for the second click of the user) and the compositionComplete does not execute. Then after that, nothing more happened visually. It seems blocked.
Any idea how can I prevent this problem?
Thanks.
The migration to the latest Durandal version 2.0.1 fixed the problem.

how to attach an event to dojox.mobile.heading 'back' button

In addition to the 'back' button functioning as expected, I need to asynchronously invoke a function to update some db tables and refresh the UI.
Prior to making this post, I did some research and tried the following on this...
<h1 data-dojo-type="dojox.mobile.Heading" id="hdgSettings" data-dojo-props="label:'Settings',back:'Done',moveTo:'svStart',fixed:'top'"></h1>
dojo.connect(dijit.registry.byId("hdgSettings"), "onclick",
function() {
if (gblLoggerOn) WL.Logger.debug(">> hdgSettings(onclick) fired...");
loadTopLvlStats();
});
Since my heading doesn't have any other widgets than the 'back' button, I thought that attaching this event to it would solve my problem... it did nothing. So I changed it to this...
dojo.connect(dijit.registry.byId("hdgSettings")._body, "onclick",
function() {
if (gblLoggerOn) WL.Logger.debug(">> hdgSettings(onclick) fired...");
loadTopLvlStats();
});
As it turns out, the '._body' attribute must be shared by the Accordion widget that I just happen to use as my app's main UI component, and any attempt to interact w the Accordion rendered my entire app useless.
As a last resort, I guess I could simply forgo using the built-in 'back' button, and simply place my own tabBarButton on the heading to control my app's transition and event processing.
If the community suggests that I use my own tabBarButton, then so be it, however there has to be a way to cleanly attach an event to the built-in 'back' button support.
Thoughts?
The following should do the trick:
var backButton = dijit.registry.byId("hdgSettings").backButton;
if (backButton) {
dojo.connect(backButton, "onClick", function() { ... });
}
Remarks:
The code above should be executed via a dojo/ready call, to avoid using dijit's widget registry before it gets filled. See http://dojotoolkit.org/reference-guide/1.9/dojo/ready.html.
Note the capitalization of the event name: "onClick" (not "onclick").
Not knowing what Dojo version you use (please always include the Dojo version information when asking questions), I kept your pre-AMD syntax, which is not recommended with recent Dojo versions (1.8, 1.9). See http://dojotoolkit.org/documentation/tutorials/1.9/modern_dojo/ for details.

Dynamic menu button items in TinyMCE

I have a custom menubutton in my tinyMCE editor that uses specific HTML elements elsewhere on the page as the menu items. I use a jQuery selector to get the list of elements and then add one each as a menu item:
c.onRenderMenu.add(function(c,m) {
m.add({ title: 'Pick One:', 'class': 'mceMenuItemTitle' }).setDisabled(1);
$('span[data-menuitem]').each(function() {
var val = $(this).html();
m.add({
title: $(this).attr("data-menuitem"),
onclick: function () { tinyMCE.activeEditor.execCommand('mceInsertContent', false, val) }
});
});
});
My problem is that this only happens once when the button is first clicked and the menu is first rendered. The HTML elements on the current page will change occasionally based on user clicks and some AJAX, so I need this selector code to run each time the menu is rendered to make sure the menu is fully up-to-date. Is that possible?
Failing that, is it possible to dynamically update the control from the end of my AJAX call elsewhere in the page? I'm not sure how to access the menu item and to update it. Something using tinyMCE.activeEditor.controlManager...?
Thanks!
I found a solution to this problem, though I'm not sure it's the best path.
It doesn't look like I can make tinyMCE re-render the menu, so instead I've added some code at the end of my AJAX call: after it has updated the DOM then it manually updates the tinymce drop menu.
The menu object is accessible using:
tinyMCE.activeEditor.controlManager.get('editor_mybutton_menu')
where mybutton is the name of my custom control. My quick-and-dirty solution is to call removeAll() on this menu object (to remove all the current menu items) and then to re-execute my selector code to find the matching elements in the (new) DOM and to add the menu items back based on the new state.
It seems to work just fine, though tweaks & ideas are always welcome!