Dc.js: Scrollable rowChart with no gap? - dc.js

It seems like the height and fixedBarHeight cant both be used in a rowChart. Ids like to use fixedBarHeight so all the bars have the size I want, and the chart to be in a scrollable div so that the numbers of bars define the height of the chart. Is this possible?

#ialarmedalien made this block, which introduces a dc.axisChart to separate the axis of the row chart from the actual chart.
Then you can use conventional overflow-y: auto on the row chart div.
Here is a related issue on dc.js.

The dc.axis addon mentioned by #Gordon will solve the problem with the axis in a scrollable div, but not the problem asked. By default, the axis will only appear at the bottom, not before.
To solve this, add one div after the row chart div, this div will contain a copy of the axis.
<div id='row-axis'></div>
Then initialize this axis in the javascript
dc.axisChart('#row-axis')
.margins({ left: 10, top: 0, right: 10, bottom: 10 })
.height( 50 )
.width( 300 )
.dimension( dimension )
.group( group )
.elasticX( true );
Then change the margin of the row chart to 'glue' correctly with the axis. They also must have the same width.
.width(300)
.margins({ left: 10, top: 0, right: 10, bottom: 0 })
Then , in the css
div.dc-chart {
float: none;
}
Dont forget to include overflow-y: auto for the row style. Then you get:
This however doesnt solve the gap problem if your height is too large (or too small) compared to the fixedBarHeight.
But now your margin is zero, so the proper height is easy to calculate (but you must pass the gap value, which has 5 by default). Assuming N=chart.group().all().length, then do:
.fixedBarHeight(X)
.height(X*N + gap*(N+1))
Which will give you:
Worth mentioning that at this point you dont even need the fixedBarHeight anymore. Simply setting the height using XN + gap(N+1) will result in dc auto setting this value to X.
Based on: https://bl.ocks.org/ialarmedalien/0a4bf25ffc0fb96ae569a20f91957bc1

Just add style="overflow-y: auto; height: 300px;" in your rowchart div. It should work.

Related

Ensure amCharts bubble chart area is square

When creating a bubble chart, such as https://www.amcharts.com/demos/bubble-chart/, is it possible to ensure the chart area/grid is square without specifying the chart div width and height? I'm hoping it could be somewhat responsive. No matter what the window size, the chart 's grid is square. It would need to take into consideration any axis labels.
I'm using React/TypeScript. Thanks!
After struggling with amchart settings to no avail, the following solution works. However, seems like there should be away to do in with chart settings.
This article explains how to maintain a specific aspect ratio for images. I simply adopted it for the bubble chart.
<div style={{ position: 'relative', paddingTop: '93%' }}>
<div id={chartId} style={{ position: 'absolute', top: 0, left: 0, height: '100%', width: '100%' }}></div>
</div>
Create a container div with relative positioning and the top padding to the correct aspect ratio
Create the chart div as a child with absolute positioning
Render the page
Take a screenshot, paste it in your favorite image editor
Measure the pixels
Recalculate the top padding
For my chart, which has axis text on the left and bottom, 93% was perfect. Now, no matter the page width or device, the grid is always square. HTH.

Is the length of the text in a nvd3-legend adjustable?

I'm using d3 and nvd3 to visualize some data in a graph. Now, no matter how many graphs i have, the legend above the (line)graph will always be shortened with trailing dots at the end.
Is there a way to adjust the legend in a fairly comfortable way? If so, how would i adress the legend and its properties?
I found the answer myself.
To keep the text from shortening, you can use chart.legend.align(false)
Thanks Reteras it did the trick for my PieChart, here are my legend chart options (typescript version)
Just change the margin to adjust the position
legend: {
align: false,
height: 200,
margin: {
right: 50,
top: 25,
left:0
}
}
legendPosition: 'right',
legend: {
maxKeyLength: 100,
padding: 40
}
This will set maximum text length of legend as 100 and ensures text cut off due to ellipsis.

NVD3: labels for second y-axis in MultiChart?

Is it possible to specify a label for the second y-axis in an NVD3 (1.8.3+) MultiChart? The following correctly sets a label on the left-hand side of the graph, but not the right:
chart.yAxis1.axisLabel('Liters');
chart.yAxis2.axisLabel('Gallons');
I had the same issue, turned out that the right side was being cut off. I solved it by including a margin when I defined the multichart model.
`var chart = nv.models.multiChart()
.margin({top: 30, right: 90, bottom: 50, left: 70})
.color(d3.scale.category10().range());
That fixed the problem for me, might be worth checking it out. The multichart example on github also has a .margin setting in their code.

Handsontable - Change row height - jumpy scroll

I try to change the row height of the table with css
http://jsfiddle.net/aep5bo3r/1/
I added this to change the row height.
#basic_example td
{
height: 15px!important;
line-height: 15px!important;
font-size: 10px;
}
The rows height is smaller, but now the scroll is .. jumpy?
With the default row height the cells are added nicely when scrolling, but if the rows are smaller, it won't add new rows until you scrolled past a certain portion.
I guess the javascript part doesn't like the new change.
If you can help me solve this, having smaller row height with an working scroll, it would be nice.
Thanks;
If I understand well so your problem will be solved if we add renderAllRows: true to your settings option when creating Handsontable object.
var hot = new Handsontable($('#tableContainerId')[0], {
...
renderAllRows: true,
...
});

grid height and the empty space after the last column

Is it possible to comply all these requirements ?
the height of the grid shall be fixed whatever the number of records;
the right space after the last columns shall be never displayed;
if the number of records is greater than the height of the grid then a vertical scrollbar shall be displayed;
an horizontal scrollbar shall be never displayed;
when possible, the height could be adapted in order to not have an "half" displayed record in the bottom of the grid.
with scroll = true
... and whatever the number of grids on screen OUF !
PS: Oleg has surely the answer ...
Add this to your stylesheet:
.ui-jqgrid .ui-jqgrid-bdiv thead,div,tbody{
position: relative;
margin: 0em;
padding:0;
/*overflow: auto;*/
overflow-x:hidden;
overflow-y:auto;
text-align:left;
}
As parameters to jqgrid add:
scrollOffset: 0,

Resources