I usecss-grid that divides and assigns layout into portions.
I draw a graph in canvas. It seems canvas size doesn’t respect layout that it is assigned.
I want radar-chart is drawn in canvas with size as same as div size.
I have 2 picture, one is with simply plain div and second is with graph in canvas.
With graph
With div
This is may snapshot view code.
Div canvasWrapper = new Div();
canvasWrapper.setMinHeight("0");
canvasWrapper.setMinWidth("0");
Canvas canvas = new Canvas(5, 5);
canvas.setId("spider-chart-canvas");
canvas.setHeight(canvasWrapper.getHeight());
canvas.setWidth(canvasWrapper.getWidth());
canvasWrapper.add(canvas);
FluentGridLayout mainLayout = new FluentGridLayout();
mainLayout.withTemplateRows(new Flex(), new Flex(), new Flex())
.withTemplateColumns(new Flex(), new Flex(), new Flex())
.withRowAndColumn(leftLayout, 1, 1, 1, 2)
// if uses div
//.withRowAndColumn(getDiv(), 1, 3, 1, 3)
// if uses Chart.js
.withRowAndColumn(canvasWrapper, 1, 3, 1, 3)
.withRowAndColumn(mainBottomLayout, 2, 1, 4, 4)
;
private Component getDiv() {
Div div = new Div();
div.setClassName("item");
int nextInt = random.nextInt(0xffffff + 1);
String colorCode = String.format("#%06x", nextInt);
div.add(new NativeLabel(colorCode));
div.getStyle().set("background", colorCode).set("padding", "20px");
return div;
}
Any help or suggestion is mostly welcomed.
Thanks in advance
sLawalata