D3 refresh axes labels - refresh

I have a graph that I show two sets of data in it. The user can hit a button to flip to another set of data. The problem is the axes aren't the same, but when I want to update the ticks I instead just layer on top another axis.
http://jsfiddle.net/scottieb/VjHd6/
The key bit is at the end:
vis.selectAll("axis").remove();
vis.append("svg:g")
.attr("class", "x axis")
.attr("transform", "translate(0, " + (h - margin ) + ")")
.call(d3.svg.axis()
.scale(x)
.tickSize(0)
.tickSubdivide(true)
.tickFormat(formatCurrency)
);
I've tried selectAll("g").remove(), but that prevents laying down the next axis. Any ideas?

Whoops, needed to redefine the scale and call a transition rather than just build a whole new axis.
http://jsfiddle.net/scottieb/JwaaV/

Your issue is that your selector is not correct. Instead of selecting "axis", you should select ".axis" since you are appending a "g" node with a class.

Related

An expression for positioning an element

I’ve got a problem with creating a proper expression when it comes to a position of an image.
I do have this expression placed in position: thisComp.layer("TA1").transform.position
My goal is adding to this expression (thisComp.layer("TA1").transform.position)
An extra line which can move the whole image by 200 pixels down
I don’t know what to type in order to make it work or how to solve it. I’ve tried to do my research on expressions but so far unable to find any answers myself.
Thank you in advance
enter image description here
To add to Stib's comment above (I still don't have enough rep to comment). You can use the pickwhip tool to access the individual x and y properties. The pickwhip tool is the one with the spiral icon below the property values.
If I click on the pickwhip and drag it to the x value of my position, I get:
temp = transform.position[0];
[temp, temp]
If I then add a line between those and pickwhip the y value, I'll have:
temp = transform.position[0];
transform.position[1]
[temp, temp]
Then I can change it to:
x = transform.position[0];
y = transform.position[1] + 200;
[x, y]
This should also give you what you want.
Of course this could also be done to a seperate layer giving you:
x = thisComp.layer("TA1").transform.position[0];
y = thisComp.layer("TA1").transform.position[1] + 200;
[x, y]

Qt trying to enable scrolling slightly beyond last element in QTableView

I'm making a sort of an Excel-type application in which I can load a tab-delimited text file and I am able to edit cells... etc
It's useable but I have an issue related to me allowing the user to "freeze" a number of columns/rows. ("Frozen" rows/columns can only be one of the first ones and are then "frozen", i.e. always displayed even when scrolling)
The whole frozen Col/Row is working but I would like the user to be able to scroll slightly past the last Col/Row in order to be able to only ever display full cells.
Right now when reaching the end of the scrollbar I end up with a partial leftmost column and topmost row because it's only displaying up to the last full col/row and not going a wee bit further for all content to be displayed fully.
I've tried doing adding some space to the maximum scrollbar value once everything is loaded in the table but it seems to have no effect :
table->horizontalScrollBar()->setMaximum(table->horizontalScrollBar()->maximum() + t->horizontalScrollBar()->singleStep()*2);
I tried multiple values too.
(Edit) There may be some Qt code that "snaps" the QTableView viewport back to the edge of the last cell automatically...
(Edit2) I connected verticalScrollbar's rangeChanged() signal to a custom slot with the following code:
void MyTableView::onRangeChanged(int min, int max) {
QScrollBar *sender = verticalScrollBar();
int newVMax = max + 20;
sender->blockSignals(true);
sender->setRange(min, newVMax);
sender->blockSignals(false);
}
Sadly there is definitely a snapback mechanic when scrolling to the end of verticalScrollbar...
Gif of snap back issue
(Edit3) The snap back may be related to:
void QHeaderViewPrivate::setScrollOffset(const QScrollBar *scrollBar, QAbstractItemView::ScrollMode scrollMode)
{
Q_Q(QHeaderView);
if (scrollMode == QAbstractItemView::ScrollPerItem) {
if (scrollBar->maximum() > 0 && scrollBar->value() == scrollBar->maximum())
q->setOffsetToLastSection();
else
q->setOffsetToSectionPosition(scrollBar->value());
} else {
q->setOffset(scrollBar->value());
}
}
mainly:
if (scrollBar->maximum() > 0 && scrollBar->value() == scrollBar->maximum())
q->setOffsetToLastSection();

OpenOffice calc, can macros update cell content automatically?

I have used a macro I found on a forum online.
It detects the background colour of a indicated cell and returns a numerical value of that background colour. The problem is that it does it only once. When I change the background colour of the indicated cell, the numerical value does not update.
To update it I have to change something in the cell where I call on the macro (e.g. delete one character and retype it), and hit enter. Then it updates the numerical value.
Is there a way to get it to update automatically? Alternatively, is there an easier way to get it to update (compared to the described deleting and retyping method), preferably one that works on multiple cells at once.
Code by Villeroy at openoffice forum:
Function CELL_BACKCOLOR(vSheet,lRowIndex&,iColIndex%)
'calls: getSheetCell
REM returns color code as number
Dim v
v = getSheetCell(vSheet,lRowIndex&,iColIndex%)
if vartype(v) = 9 then
CELL_BACKCOLOR = v.CellBackColor
else
CELL_BACKCOLOR = v
endif
End Function
Function getSheetCell(byVal vSheet,byVal lRowIndex&,byVal iColIndex%)
dim oSheet
' print vartype(vsheet)
oSheet = getSheet(vSheet)
if varType(oSheet) <>9 then
getSheetCell = NULL
elseif (lRowIndex > oSheet.rows.count)OR(lRowIndex < 1) then
getSheetCell = NULL
elseif (iColIndex > oSheet.columns.count)OR(iColIndex < 1) then
getSheetCell = NULL
else
getSheetCell = oSheet.getCellByPosition(iColIndex -1,lRowIndex -1)
endif
End Function
I'm not sure why the "AutoCalculate" setting doesn't work in this case (tested with LibreOffice 7.0.2). Anyway, you can manually update the macro output for a single cell or for multiple cells:
for a single cell, hit F9
for multiple cells, select them and hit CTRL + SHIFT + F9.

Unity Slider mapped to list<float>?

I currently have a list<float> that are arranged in an increasing order. My sliders min.value is the lowest value of my list (i.e. first element of my list) and sliders max.value is equal to the last item of my list.
What I want to do is that whenever my slider is at a specific value or +-0.1 to one of the elements on my list, I Want to be able to get the index out that specific element to perform a task.
Any suggestions?
Someone asked for code, I don't even like this code since it only gives me the right value once I press "play" from zero, but then it removes my data, so I can't go back with the slider
this code is inside update void, and isPlaying is true when I press a "play" button
if(isPlaying){
timeSlider.value += Time.deltaTime;
timer = timeSlider.value;
print(timeSlider.value);
if((newTimes[0]>=(timer-0.1f)) && (newTimes[0]<=(timer+0.1f))){
print("time: " + newTimes[0]+ " at run time: " + timer);
NewTimes.RemoveAt(0);
}
}
You can set the slider to use whole numbers in the inspector and use the value as your index?
My first thought would be:
Set Slider Steps to Floats in your List
-> Perform task on List[currentSliderStep] as needed

Remove blanks at ends of DataVisualization chart x axis

I am using Microsoft's DataVisualization.Charting.Chart, and I have integer values along the X axis, using line-style graphs. However, the chart is adding an extra blank item at the beginning and end of the x-axis, with no value labels to explain what they are.
How can I remove these empty items and make the lines go right up to the ends?
Use the IsMarginVisible property of the xaxis. I believe that will do the trick.
To test this, I changed one of my own charts to be a line chart and then set the value in the code:
ReactivityChart.ChartAreas(0).AxisX.IsMarginVisible = False
Tell me if this is what you were hoping to get or if I have totally misunderstood the question:
(note that I do not have a high enough rep to post this image)
http://www.rectorsquid.com/chartmargintest.gif
You should set the Maximum and Minimum properties in ChartArea.AxisX, e.g. :
this.chart1.ChartAreas[0].AxisX.Minimum = 0; // if your minimum X = 0
this.chart1.ChartAreas[0].AxisX.Maximum = 100; // if your maximum X = 100
In this way, your chart area will show only the values between Minimum and Maximum.