Constructor
new Notes(data, options)
Create a notes visual with the specified data and options.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Array.<Object> | An array of data. |
options |
Object | Configuration options. |
- Source:
Methods
addProperty(name, value)
Add the specified property to this visual. The property is stored as [name, value].
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | The name of the property. |
value |
string | The value of the property. |
- Source:
adjustNoteNumber(amount, callDrawopt)
Adjust the note number by the specified amount for selected notes.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
amount |
number | The amount to adjust. | ||
callDraw |
boolean |
<optional> |
true | Whether to call draw() from this method. |
- Source:
adjustVelocity(amount, callDrawopt)
Adjust the velocity by the specified amount for selected notes.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
amount |
number | The amount to adjust. | ||
callDraw |
boolean |
<optional> |
true | Whether to call draw() from this method. |
- Source:
appendData(data, offsetTime)
Append the provided data array to the existing data array in this visual.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Array | The data array to append. |
offsetTime |
number | An optional offset time for the data. |
- Source:
canAddNote(note, startTime, endTime) → {boolean}
Determines whether the specified note can be added by looking for any notes with the same note number in the specified time range.
Parameters:
| Name | Type | Description |
|---|---|---|
note |
Object | The note to edit. |
startTime |
number | The start time of the note. |
endTime |
number | The end time of the note. |
- Source:
Returns:
True if the added note would not overlap any existing notes; false otherwise.
- Type
- boolean
canDeleteTime(baseTime, deltaTime)
Determines whether time in the specified time range can be deleted.
Parameters:
| Name | Type | Description |
|---|---|---|
baseTime |
number | The start of the selection. |
deltaTime |
number | The end of the selection. |
- Source:
canEditNote(note, newStartTime, newEndTime) → {boolean}
Determines whether the specified note can be edited by looking for any notes with the same note number in the specified time range.
Parameters:
| Name | Type | Description |
|---|---|---|
note |
Object | The note to edit. |
newStartTime |
number | The possible start time of the note. |
newEndTime |
number | The possible end time of the note. |
- Source:
Returns:
True if the note would not overlap any existing notes; false otherwise.
- Type
- boolean
canSetNoteNumber(noteNumber, noteStartTime, noteEndTime) → {boolean}
Determines whether the specified note values can be adjusted by looking for any notes with the same note number in the specified time range.
Parameters:
| Name | Type | Description |
|---|---|---|
noteNumber |
number | The note number. |
noteStartTime |
number | The start time of the note. |
noteEndTime |
number | The end time of the note. |
- Source:
Returns:
True if the note would not overlap any existing notes; false otherwise.
- Type
- boolean
deleteSelectedNotes(callDrawopt)
Delete any selected notes.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
callDraw |
boolean |
<optional> |
true | Whether to call draw() from this method. |
- Source:
deleteTime(baseTime, deltaTime)
Deletes time based on the specified selection range.
Parameters:
| Name | Type | Description |
|---|---|---|
baseTime |
number | The start of the selection. |
deltaTime |
number | The end of the selection. |
- Source:
deselect(callDrawopt)
Deselect selected notes.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
callDraw |
boolean |
<optional> |
true | Whether to call draw() from this method. |
- Source:
dragNote(dx)
Set the width of the note rectangle based on the specified delta x.
Parameters:
| Name | Type | Description |
|---|---|---|
dx |
number | Delta x. |
- Source:
draw()
Draw notes.
- Source:
endNote(callDrawopt)
End the new note rectangle, erasing the rectangle and adding the new note to the data.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
callDraw |
boolean |
<optional> |
true | Whether to call draw() from this method. |
- Source:
endShiftingNotes(callDrawopt)
End note shifting, erasing the empty rectangles and updating the note data.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
callDraw |
boolean |
<optional> |
true | Whether to call draw() from this method. |
- Source:
erase()
Erase notes.
- Source:
getNoteScale()
Get the note value scale for this visal.
- Source:
getNotesWithinRanges(t1, t2, note1, note2) → {Array}
Get any notes in the specified time and note ranges and return them in an array.
Parameters:
| Name | Type | Description |
|---|---|---|
t1 |
number | The start of the time range. |
t2 |
number | The end of the time range. |
note1 |
number | The start of the note range. |
note2 |
number | The end of the note range. |
- Source:
Returns:
An array of notes in the specified ranges or an empty array.
- Type
- Array
getSelectedNotes() → {Array}
Get any selected notes.
- Source:
Returns:
An array of selected notes or an empty array.
- Type
- Array
includeVisual(visualType, options)
Include the visual type indicated by the type string with the specified options.
Parameters:
| Name | Type | Description |
|---|---|---|
visualType |
string | The visual type. |
options |
object | Options for the visual type. |
- Source:
initialize(parentElement, width, height, timeScale)
Initialize this visual.
Parameters:
| Name | Type | Description |
|---|---|---|
parentElement |
Element | The parent element. |
width |
number | The parent width. |
height |
number | The parent height. |
timeScale |
d3.scaleLinear | The time scale. |
- Source:
insertTime(baseTime, deltaTime)
Inserts time based on the specified selection range.
Parameters:
| Name | Type | Description |
|---|---|---|
baseTime |
number | The start of the selection. |
deltaTime |
number | The end of the selection. |
- Source:
resetNotes()
Change the visibility or the color of notes back to their original values.
- Source:
select(x1, x2, y1, y2, append, callDrawopt)
Select notes in the specified time and note number ranges.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
x1 |
number | The start of the x range. | ||
x2 |
number | The end of the x range. | ||
y1 |
number | The start of the y range. | ||
y2 |
number | The end of the y range. | ||
append |
boolean | Append selected notes to previously selected notes. | ||
callDraw |
boolean |
<optional> |
true | Whether to call draw() from this method. |
- Source:
setDataTemplate(template)
Set a data template object for adding notes.
Parameters:
| Name | Type | Description |
|---|---|---|
template |
Object | A template object. |
- Source:
setEditor(editor)
Set the editor for this visual and set editing callbacks.
Parameters:
| Name | Type | Description |
|---|---|---|
editor |
object | The VisualEditor to set. |
- Source:
setNoteNumber(number, callDrawopt)
Set the note number for a selected note. For this to work, only one number can be selected.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
number |
number | The note number. | ||
callDraw |
boolean |
<optional> |
true | Whether to call draw() from this method. |
- Source:
setProperty(key, value, callDrawopt)
Set the specified value for the specified key. The properties "note" and "velocity", if specified, will be handled by
setNoteNumber() and setVelocity() respectively.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
key |
string | The key of the property. | ||
value |
number | The value to set for the property. | ||
callDraw |
boolean |
<optional> |
true | Whether to call draw() from this method. |
- Source:
setVelocity(velocity, callDrawopt)
Set velocity to the specified amount for selected notes.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
velocity |
number | The velocity. | ||
callDraw |
boolean |
<optional> |
true | Whether to call draw() from this method. |
- Source:
shiftNotes(dx)
Shift the empty rectangles representing the notes by the specified delta x.
Parameters:
| Name | Type | Description |
|---|---|---|
dx |
number | Delta x. |
- Source:
startNote(x, y)
Start drawing a new note rectangle.
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number | The x value of the note rectangle. |
y |
number | The y value to convert to a note value. |
- Source:
startShiftingNotes()
Start to shift notes in time, drawing empty rectangles representing the selected notes.
- Source:
updateNotes(time)
Change the visibility or the color of notes with time values less than the specified time.
Parameters:
| Name | Type | Description |
|---|---|---|
time |
number | The time up to which all earlier notes should change. |
- Source: