Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions js/src/IndexSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class IndexSelector extends BaseXSelector {
}

mousemove() {
if (!this.active) {
if (!this.active || this.dirty) {
return;
}
this.dirty = true;
Expand Down Expand Up @@ -143,7 +143,10 @@ export class IndexSelector extends BaseXSelector {
} else {
const pixel = this.scale.scale(selected[0]);
if (this.line !== undefined && this.line !== null) {
this.line.attr('x1', 0).attr('x2', 0).attr('visibility', 'visible');
this.line
.attr('x1', pixel)
.attr('x2', pixel)
.attr('visibility', 'visible');
}
//the selected may be called before the index selector is
//active for the first time.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions ui-tests/tests/notebooks/index_selector_update.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "06ac2448-da47-4939-a22a-e4b556fba103",
"metadata": {},
"outputs": [],
"source": [
"from bqplot import *\n",
"from bqplot.interacts import *\n",
"\n",
"# Create Scatter\n",
"sc_x = LinearScale()\n",
"sc_y = LinearScale()\n",
"\n",
"scatt = Scatter(\n",
" x=list(range(10)), \n",
" y=[20, 3, 23, 5, 6, 12, 23, 14, 20, 3],\n",
" scales={'x': sc_x, 'y': sc_y},\n",
" selected_style={\"opacity\": \"1\"},\n",
" unselected_style={\"opacity\": \"0.2\"}\n",
")\n",
"\n",
"sel = IndexSelector(\n",
" marks=[scatt], \n",
" scale=sc_x,\n",
" selected=3\n",
")\n",
"\n",
"ax_x = Axis(scale=sc_x)\n",
"ax_y = Axis(scale=sc_y, orientation='vertical')\n",
"\n",
"fig = Figure(\n",
" marks=[scatt], \n",
" axes=[ax_x, ax_y],\n",
" interaction=sel\n",
")\n",
"fig"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a0600d9f-2256-4610-a14e-471c255d4924",
"metadata": {},
"outputs": [],
"source": [
"sel.selected = 5"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.0"
}
},
"nbformat": 4,
"nbformat_minor": 5
}