Problem using Canvas using chart view

Hello,

I try to draw in a char view.
First i declare a default chart :{view:“chart”, id:‘canvas_’,type:‘pie’} in a form view , using then dhx.ui(…); This form view is in a multi view

then a the toolbar view event “onBeforeTabClick” , i retrieved the form view, i get the draw this the canvas.

  var canvas = $$('chartView_').getCanvas().canvas;

var context = canvas.getContext("2d");

The draw result is not refreshed (event using the refresh operation on the chart view.
I need to click in other form view several times , to make appear the result.
So How Can i do to show the result drawing directly.

Hello,

please provide the sample where we could reproduce the problem

Hello,

Find here the code.
I want to draw a circle in the canvas associated to the CharView from the Tab called ‘Canvas’ in the sample.
The problem is in the Tab ‘Canvas’ Tab. We need to click it first, select another one tab, and then select again the ‘Canvas’ Tab to show the drawing result.

Have a nice day.

I attach the files code
test_14022012.zip (80.2 KB)

Hello Alexandra,

Do you have any time to look about this issue ?

Thank you very much.
Have a nice week end.

Hello,

try to call drawShape() function after a view is visible:

function awsui_attachEvents(){ var drawn = false; $$("tabbar").attachEvent("onBeforeTabClick",function(button,id){ $$(id).show(); if((id == 'canvasTab_') &&!drawn){ drawShape(); drawn = true } return true; }); }

Thank You Alexandra . This is resolved.
But I am disapointed. Usually, we draw and after we show the graphic content.
So I dare think that the show operation should initliaze some parameters to make draw visible.

In case of javascript - there is no benefits at drawing before showing, as image in browser will be rendered after script execution end, so the order doesn’t matter.

For performance reasons, content in hidden tabs ignores render commands while it not visible, so to work with such content you need to make it visible first.