March 26, 2015

How to add an ellipsis for Birt bar chart long labels not being displayed

I recently had to design a few reports using Birt.

Amongst some other newby problems, I had this one which I think is a Birt engine bug : when designing or rendering a bar char with long labels, the "ellipsis" thing doesn't work as expected and either the chart isn't displayed at all, or X axis labels aren't displayed.

To address this, you can use scripting to simply cut labels after a certain amount of characters and manually add ellipsis :



To do so, simply select your chart in the designer and switch to the Script tab. Then add the folowing code :

var cutLabel = "";

function afterDataSetFilled( series, dataSet, icsc ) {

 for (var i=0; i 20) {
  
   // cut the string after 20 chars and add ellipsis
   dataSet.getValues()[i] = value.substring(0,20) + "...";
  }
 }
}


function beforeDrawAxisTitle( axis, label, icsc ) {
 if( axis.isCategoryAxis() ){
  label.getCaption().setValue(cutLabel);
 }
}

Hope this helps !

November 13, 2014

Chrome 38 / Chromium keeps crashing in Ubuntu 14.10 (or the Ooops syndrome)

tl;dr
Start chrome with "--disable-gpu-sandbox flag".

Since I moved to Ubuntu 14.10; I experienced frequent crashes of latest chrome release. Had the same issue in chromium. The problem only occurred on some pages, but couldn't detect root cause.

After digging, found this thread.
Issue seems to be pre 14.04, then fixed in 14.04, and back again in 14.10.

So the problem is hardware acceleration related (no need to say waaaaay beyond my knowledge). You can check hadware and WebGL usage of your browser with the about://gpu URL. If everything's fine, all lights should be green (hardware acceleration must of course be enabled in chrome://settings).

So - as stated in the thread linked above, starting the browser with the "--disable-gpu-sandbox" flag I'm not having the issue anymore. I don't know if this raises some security concerns as some will say, but for now it's been working nice for a couple of hours.

To alter the unity shortcut to add this option wasn't that simple :
- editing the  ~/.local/share/applications/[your chrome app].desktop shortcut didn't work, I don' know why
- alacarte software, which usually works really well to create/edit launchers didn't allow me to edit the chrome launcher (this seems to be a known bug though)
- finally I found the "MenuLibre" software, equivalent to "Alacarte", but...working for chrome entry. Here is the installation package

Hope this help.

August 27, 2014

Webstorm/ IntelliJ loses keyboard input in Ubuntu

Edit : Several month after, issue isn't investigated et at jetbrains. Please vote for this issue so devs can start working on it ! 

Sometimes IntelliJ loses input from keyboard in Ubuntu 14.04. I've seen people complain about it as well with PhpStorm and IntelliJ.

Symptom : mouse clicks and menu work as expected, but no keyboard input is accepted and I must restart Webstorm to make it work again.

Solution : restart the ibus service in a terminal :

sudo ibus restart

For latin keyboard people, this switched my keyboard from AZERTY to QWERTY. I had to enter the following command to make it AZERTY again.

setxkbmap fr

Hope this helps.

August 12, 2014

Ubuntu default shortcuts Ctrl+Alt+Numpad overriding google docs quick style shortcuts

I love Google Docs - it's just so fast and user friendly.

I was really used to the Ctrl+Alt+1 / Ctrl+Alt+2 / ... shortcut allowing you to quickly set a level 1 / 2 / ... header style on a line.

When I switched to Ubuntu a couple of years ago, I realized this keystroke was already assigned to Window placement and was overriding GDocs shortcuts, but I never took the time to dig where I could override this behavior.

Today, I'm proud to announce that I finally found it ^^. In case it might help anyone : the offender is the "Grid" plugin. You can configure it or switch it off using CompizConfig Configuration Manager.

Hope this help.


May 11, 2014

Translate Angular-UI DatePicker - text and popup buttons too

You might want to Angular-UI date picker in your own language instead of default english.
Fortunately, guys at Angular-UI team did the job well and used i18n angular system.

All you have to do is to include the correct language pack :

...
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.js"></script>
<script src="https://code.angularjs.org/1.0.2/i18n/angular-locale_fr-fr.js"></script>
...


There's still the popup action buttons that are not translated.
As stated in the doc, you can configure the text displayed in those buttons by altering the datepickerPopupConfig global object default values :


// INJECT GLOBAL DATE PICKER POPUP CONFIG
var DatepickerDemoCtrl = function ($scope, datepickerPopupConfig) {
...
// TRANSLATION HERE
datepickerPopupConfig.currentText = 'Aujourd\'hui';
datepickerPopupConfig.clearText = 'Effacer';
datepickerPopupConfig.closeText = 'Fermer';
...
}
Here's a Plunkr for demoing purpose.

Hope this help !

March 18, 2014

Angular JS : Angular-UI modals won't show up with Bootstrap 3

While migrating from Bootstrap 2 to 3 in an angular jS app, realized there was a bug in modals implementation : Angular-UI directive doesn't add a "display block" CSS prop to the built modal, so it will never show up.

To fix it, simply add the following CSS :

/*
FIX ui-bootstrap modals + bootstrap 3
*/ .modal.ui-bootstrap-modal {   display: block; }
And open the modals this way :
$scope.openTheModal = function () {
$modal.open({
templateUrl: 'myModalTemplate.html',
scope: $scope,
windowClass: 'ui-bootstrap-modal'
});
};
Here we add a different class from the regular 'modal' class. Reason is : in my app I had both plain Bootstrap3 modals and angular-UI modals. Simply adding display: block property on 'modal' class was breaking regular Bootstrap 3 modals.

Hope this help.

December 30, 2013

Grunt uglify task breaks angular app

Here is the error in the browser console :

  1. Error: [$injector:unpr] Unknown provider: aProvider <- a http://errors.angularjs.org/1.2.7-build.2026+sha.7d6e5a2/$injector/unpr?p0=aProvider%20%3C-%20a at http://localhost:9000/vendor/bower_components/angular/angular.js:78:12 at http://localhost:9000/vendor/bower_components/angular/angular.js:3538:19 at Object.getService [as get] (http://localhost:9000/vendor/bower_components/angular/angular.js:3665:39) at http://localhost:9000/vendor/bower_components/angular/angular.js:3543:45 at getService (http://localhost:9000/vendor/bower_components/angular/angular.js:3665:39) at invoke (http://localhost:9000/vendor/bower_components/angular/angular.js:3687:13) at Object.instantiate (http://localhost:9000/vendor/bower_components/angular/angular.js:3708:23) at http://localhost:9000/vendor/bower_components/angular/angular.js:6758:28 at link (http://localhost:9000/vendor/bower_components/angular-route/angular-route.js:897:26) at nodeLinkFn (http://localhost:9000/vendor/bower_components/angular/angular.js:6212:13) <div ng-view="" class="ng-scope"> angular.js:9384


What happened is that Grunt uglify task included angular files (angular-route.js in this case).
Minification included in uglify task broke the file by minufying some string that mustn't be minified.

Three solutions :
  • Make the grunt task do not include unwanted files, and include those files already minified in your app.
  • If problem still occurs after first solution, your angular modules are not "uglify friendly". There's a special way to declare your dependencies so that minifying goes smooth, as described on this page ("a note on minification" paragraph) for example. Please note that instead of doing this declaration "by hand", you can use the "ng-min" task that automatize the process and keep your code clean.
  • Well, in my case I still had issue, so I ended turning off the "mangle" option in uglify (that very option that make long strings into smaller to compress response size). You can turn off the option like this :
 uglify: {

            options: {
                mangle: false
            },

Hope this help.