diff --git a/Modules/C3js/resource/Histogram.js b/Modules/C3js/resource/Histogram.js index ff2b4b40a2..cd64c9f276 100644 --- a/Modules/C3js/resource/Histogram.js +++ b/Modules/C3js/resource/Histogram.js @@ -1,162 +1,169 @@ document.body.style.backgroundColor = 'rgb(240, 240, 240)'; var greyvalue; //needed to display the tooltip in the right format var binSize = 10; var min; var max; +var minHeight = 255; + var chart = c3.generate({ data: { x : 'x', //use first "column" as x axis values columns: [], //initialize empty. Data will be loaded in function setupChart(initValues) type: 'bar', selection: { enabled: false, multiple: false, } }, grid: { y: { lines: [{value:0}] //Draws a horizontal line at y=0 } }, bar: { width: { ratio: 0.95 // this makes bar width 95% of length between ticks } }, zoom: { enabled: true, }, subchart: { show: true //Shows a subchart that shows the region the primary chart is zoomed in to by overlay. }, axis: { x: { type: 'category', //only for type 'category' the bars will be rescaled in width on zoom tick: { multiline: false, fit: false, //to make more x labels appear on zoom centered: true, }, }, y: { tick: { format: d3.format("s"), }, //for some reason, there is an offset for our linegraph. This is prevented by the following lines min: 0, padding: { top: 0, bottom: 0 } } }, //Style data points in linegraph point: { r: 0.2, focus: { expand: { r: 4 } } }, tooltip: { format: { title: function (d) { var endValue = (parseFloat(greyvalue[d]) + binSize); endValue = endValue.toFixed(3); return 'Greyvalue: ' + greyvalue[d] + '...' + endValue; }, } } }); var initValues; window.onload = function() { new QWebChannel(qt.webChannelTransport, function(channel) { initValues = channel.objects.initValues; setupChart(initValues) }); } //This is necessary to resize the chart, after the size of the parent changed window.onresize = function () { + var size = window.innerHeight-(window.innerHeight/100*10); //subtract 5% of height to hide vertical scrool bar + + if (size < minHeight) + { + size = minHeight; + } + chart.resize({ - height: window.innerHeight-(window.innerHeight/100*5), //subtract 5% of height to hide vertical scrool bar + height: size, }); } function setupChart(initValues) { - chart.resize({ - height: window.innerHeight - (window.innerHeight / 100 * 5), - }); + window.onresize(); calcBinSize(initValues); //copy measurements to xValues for x-axis-labels and to greyvalues for tooltips var xValues = initValues.m_Measurement.slice(0); greyvalue = initValues.m_Measurement.slice(0); for (var i = 0; i < xValues.length; i++) { greyvalue[i] = greyvalue[i] - (binSize / 2); greyvalue[i] = greyvalue[i].toFixed(3); //change number format for x axis. Need to do it here, because it is not working on chart generation. xValues[i] = xValues[i]; xValues[i] = xValues[i].toFixed(); xValues[i] = d3.format("s")(xValues[i]); } xValues.unshift('x'); //add label to x array xValues.push(null); //append null value, to make sure the last tick on x-axis is displayed correctly var yValues = initValues.m_Frequency; yValues.unshift('Frequency'); //add label to y array xValues.push(null); //append null value, to make sure the last tick on x-axis is displayed correctly chart.unload(); //unload data before loading new data chart.load({ columns:[ xValues, yValues ] }); if (initValues.useLineGraph) { chart.transform('line'); } } /* * Calculation of the bin size. */ function calcBinSize(initValues) { if (1 < initValues.m_Measurement.length) { min = d3.min(initValues.m_Measurement); max = d3.max(initValues.m_Measurement); binSize = ((max - min) / (initValues.m_Measurement.length - 1)); } else { binSize = 10; } } //Transforamtion between bar and line chart //takes the name of the chart type as a parameter //calles by QmitkC3jsWidget function transformView(TransformTo) { chart.transform(TransformTo); }; function changeTheme(color) { if (color == 'dark') { link = document.getElementsByTagName("link")[0]; link.href = "Histogram_dark.css"; } else { link = document.getElementsByTagName("link")[0]; link.href = "Histogram.css"; } }; \ No newline at end of file diff --git a/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsViewControls.ui b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsViewControls.ui index 2e0549c2b2..ce03158490 100644 --- a/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsViewControls.ui +++ b/Plugins/org.mitk.gui.qt.measurementtoolbox/src/internal/QmitkImageStatisticsViewControls.ui @@ -1,624 +1,630 @@ QmitkImageStatisticsViewControls true 0 0 548 800 Form 0 0 Qt::LeftToRight Feature Image: 0 0 None 0 0 Mask: 0 0 None -1 0 0 color: rgb(255, 0, 0); Error Message Qt::AutoText Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter Ignore zero-valued voxels false Statistics 9 9 9 100 180 16777215 16777215 Qt::ScrollBarAsNeeded Qt::ScrollBarAsNeeded true QAbstractItemView::NoEditTriggers true true Qt::DotLine false 14 false false 80 true 80 false true false false 25 25 false false Mean Median StdDev RMS Max Min N V (mm³) Skewness Kurtosis Uniformity Entropy MPP UPP 0 0 0 0 0 0 Copy to Clipboard Qt::Horizontal QSizePolicy::Fixed 20 20 false copy complete table Qt::Horizontal 40 20 false - 150 - 160 + 400 + 450 Histogram false 0 0 0 0 16777215 16777215 Plot 0 0 Barchart true 0 0 0 0 Linegraph Qt::Horizontal 40 20 Use default bin size true QFrame::NoFrame QFrame::Raised 0 0 0 0 0 60 0 100 16777215 Bin size: Press enter to recalculate statistics with new bin size. true 5 0.000010000000000 1000000.000000000000000 10.000000000000000 + + + 0 + 0 + + 0 0 0 0 0 0 0 0 Copy to Clipboard Qt::Horizontal - 40 - 20 + 413 + 17 Qt::Vertical 20 40 QmitkC3jsWidget QWidget
QmitkC3jsWidget.h