Skip to content

Commit

Permalink
bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobinso committed Nov 22, 2024
1 parent 3d8d250 commit bf033cd
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 93 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ Below are examples and a quickstart guide. See the [developer documentation](ht

# Examples

***[Alignments](https://igv.org/web/release/3.0.9/examples/cram-vcf.html)***
***[Alignments](https://igv.org/web/release/3.1.0/examples/cram-vcf.html)***

***[Interactions](https://igv.org/web/release/3.0.9/examples/interact.html)***
***[Interactions](https://igv.org/web/release/3.1.0/examples/interact.html)***

***[Copy number](https://igv.org/web/release/3.0.9/examples/copyNumber.html)***
***[Copy number](https://igv.org/web/release/3.1.0/examples/copyNumber.html)***

***[Multiple regions](https://igv.org/web/release/3.0.9/examples/multi-locus.html)***
***[Multiple regions](https://igv.org/web/release/3.1.0/examples/multi-locus.html)***

***[Mutation Annotation Format (MAF)](https://igv.org/web/release/3.0.9/examples/maf-tcga.html)***
***[Mutation Annotation Format (MAF)](https://igv.org/web/release/3.1.0/examples/maf-tcga.html)***

***[Variant color options](https://igv.org/web/release/3.0.9/examples/variant-colors.html)***
***[Variant color options](https://igv.org/web/release/3.1.0/examples/variant-colors.html)***

***[More](https://igv.org/web/release/3.0.9/examples/)***
***[More](https://igv.org/web/release/3.1.0/examples/)***


# Quickstart
Expand All @@ -39,18 +39,18 @@ Below are examples and a quickstart guide. See the [developer documentation](ht
igv.js consists of a single javascript file with no external dependencies.

Pre-built files for script include, AMD, or CJS module systems (igv.min.js) and an ES6 module (igv.esm.min.js)
can be downloaded from [https://cdn.jsdelivr.net/npm/igv@3.0.9/dist/](https://cdn.jsdelivr.net/npm/igv@3.0.9/dist/).
can be downloaded from [https://cdn.jsdelivr.net/npm/igv@3.1.0/dist/](https://cdn.jsdelivr.net/npm/igv@3.1.0/dist/).

To import igv as an ES6 module

```javascript
import igv from "https://cdn.jsdelivr.net/npm/igv@3.0.9/dist/igv.esm.min.js"
import igv from "https://cdn.jsdelivr.net/npm/igv@3.1.0/dist/igv.esm.min.js"
```

Or as a script include (defines the "igv" global)

```html
<script src="https://cdn.jsdelivr.net/npm/igv@3.0.9/dist/igv.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/igv@3.1.0/dist/igv.min.js"></script>
```

Alternatively you can install with npm
Expand Down
28 changes: 14 additions & 14 deletions js/ui/components/colorScaleEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ function paintLegend(legend, newColorScale) {

const ctx = legend.getContext("2d")
const w = legend.width
const step = (newColorScale.high - newColorScale.low) / w
const step = (newColorScale.max - newColorScale.min) / w
for (let i = 0; i < w; i++) {
const v = newColorScale.low + i * step
const v = newColorScale.min + i * step
const color = newColorScale.getColor(v)
ctx.fillStyle = color
ctx.fillRect(i, 0, 1, legend.height)
Expand All @@ -22,7 +22,7 @@ function paintLegend(legend, newColorScale) {
/**
* Editor for color scales. Supported types:
*
* 'gradient': {low, high, lowColor, highColor}
* 'gradient': {min, max, minColor, maxColor}
*
* 'diverging': {mid, midColor, lowGradientScale, highGradientScale}
*
Expand All @@ -44,17 +44,17 @@ class ColorScaleEditor {

const minTextbox = new TextBoxRow({
label: "Min value",
value: newColorScale.low.toString(),
value: newColorScale.min.toString(),
onchange: (v) => {
newColorScale.low = Number.parseFloat(v)
newColorScale.min = Number.parseFloat(v)
paintLegend(legend, newColorScale)
}
})
table.append(minTextbox.row)

const midTextbox = new TextBoxRow({
label: "Mid value",
value: (newColorScale.mid || newColorScale.low).toString(),
value: (newColorScale.mid || newColorScale.min).toString(),
onchange: (v) => {
newColorScale.mid = Number.parseFloat(v)
paintLegend(legend, newColorScale)
Expand All @@ -64,9 +64,9 @@ class ColorScaleEditor {

const maxTextbox = new TextBoxRow({
label: "Max value",
value: newColorScale.high.toString(),
value: newColorScale.max.toString(),
onchange: (v) => {
newColorScale.high = Number.parseFloat(v)
newColorScale.max = Number.parseFloat(v)
paintLegend(legend, newColorScale)
}
})
Expand All @@ -75,17 +75,17 @@ class ColorScaleEditor {

const colorElem = new ColorPickerRow({
label: "Min color",
value: newColorScale.lowColor,
value: newColorScale.minColor,
onchange: (v) => {
newColorScale.lowColor = v
newColorScale.minColor = v
paintLegend(legend, newColorScale)
}
})
table.append(colorElem.row)

const midColorElem = new ColorPickerRow({
label: "Mid color",
value: newColorScale.midColor || newColorScale.lowColor,
value: newColorScale.midColor || newColorScale.minColor,
onchange: (v) => {
newColorScale.midColor = v
paintLegend(legend, newColorScale)
Expand All @@ -95,9 +95,9 @@ class ColorScaleEditor {

const highColorElem = new ColorPickerRow({
label: "Max color",
value: newColorScale.highColor,
value: newColorScale.maxColor,
onchange: (v) => {
newColorScale.highColor = v
newColorScale.maxColor = v
paintLegend(legend, newColorScale)
}
})
Expand All @@ -109,7 +109,7 @@ class ColorScaleEditor {
onchange: (diverging) => {
if (diverging) {
// Converting from gradient to diverting
newColorScale.mid = newColorScale.low < 0 && newColorScale.high > 0 ? 0 : (newColorScale.low + newColorScale.high) / 2
newColorScale.mid = newColorScale.min < 0 && newColorScale.max > 0 ? 0 : (newColorScale.min + newColorScale.max) / 2
newColorScale.midColor = "rgb(255,255,255)"
newColorScale = new DivergingGradientScale(newColorScale)

Expand Down
133 changes: 66 additions & 67 deletions js/util/colorScale.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ const ColorScaleFactory = {
}
},

defaultGradientScale: function (low, high) {
defaultGradientScale: function (min, max) {

return new GradientColorScale({
"type": "doubleGradient",
"low": low,
"high": high,
"lowColor": "rgb(46,56,183)",
"highColor": "rgb(164,0,30)"
"min": min,
"max": max,
"minColor": "rgb(46,56,183)",
"maxColor": "rgb(164,0,30)"
})
},

defaultDivergingScale: function (low, mid, high) {
defaultDivergingScale: function (min, mid, max) {
return new DivergingGradientScale({
"type": "doubleGradient",
"low": 0,
"min": 0,
"mid": 0.25,
"high": 0.5,
"lowColor": "rgb(46,56,183)",
"max": 0.5,
"minColor": "rgb(46,56,183)",
"midColor": "white",
"highColor": "rgb(164,0,30)"
"maxColor": "rgb(164,0,30)"
})
}
}
Expand Down Expand Up @@ -66,45 +66,45 @@ class BinnedColorScale {


class GradientColorScale {
constructor({low, high, lowColor, highColor}) {
constructor({min, max, minColor, maxColor}) {
this.type = 'gradient'
this.setProperties({low, high, lowColor, highColor})
this.setProperties({min, max, minColor, maxColor})
}

setProperties({low, high, lowColor, highColor}) {
setProperties({min, max, minColor, maxColor}) {
this.type = 'gradient'
this.low = low
this.high = high
this._lowColor = lowColor
this._highColor = highColor
this.lowComponents = IGVColor.rgbComponents(lowColor)
this.highComponents = IGVColor.rgbComponents(highColor)
this.min = min
this.max = max
this._lowColor = minColor
this._highColor = maxColor
this.lowComponents = IGVColor.rgbComponents(minColor)
this.highComponents = IGVColor.rgbComponents(maxColor)
}

get lowColor() {
get minColor() {
return this._lowColor
}

set lowColor(c) {
set minColor(c) {
this._lowColor = c
this.lowComponents = IGVColor.rgbComponents(c)
}

get highColor() {
get maxColor() {
return this._highColor
}

set highColor(c) {
set maxColor(c) {
this._highColor = c
this.highComponents = IGVColor.rgbComponents(c)
}

getColor(value) {

if (value <= this.low) return this.lowColor
else if (value >= this.high) return this.highColor
if (value <= this.min) return this.minColor
else if (value >= this.max) return this.maxColor

const frac = (value - this.low) / (this.high - this.low)
const frac = (value - this.min) / (this.max - this.min)
const r = Math.floor(this.lowComponents[0] + frac * (this.highComponents[0] - this.lowComponents[0]))
const g = Math.floor(this.lowComponents[1] + frac * (this.highComponents[1] - this.lowComponents[1]))
const b = Math.floor(this.lowComponents[2] + frac * (this.highComponents[2] - this.lowComponents[2]))
Expand All @@ -114,15 +114,15 @@ class GradientColorScale {

/**
* Return a simple json-like object, not a literaly json string
* @returns {{high, low, highColor, lowColor}}
* @returns {{max, min, maxColor, minColor}}
*/
toJson() {
return {
type: this.type,
low: this.low,
high: this.high,
lowColor: this.lowColor,
highColor: this.highColor
min: this.min,
max: this.max,
minColor: this.minColor,
maxColor: this.maxColor
}
}

Expand All @@ -136,18 +136,17 @@ class DivergingGradientScale {

constructor(json) {
this.type = 'diverging'
const {lowColor, midColor, highColor, low, mid, high} = json
this.lowGradientScale = new GradientColorScale({
lowColor: lowColor,
highColor: midColor,
low: low,
high: mid
minColor: json.minColor || json.lowColor,
maxColor: json.midColor,
min: json.min !== undefined ? json.min : json.low,
max: json.mid
})
this.highGradientScale = new GradientColorScale({
lowColor: midColor,
highColor: highColor,
low: mid,
high: high
minColor: json.midColor,
maxColor: json.maxColor || json.highColor,
min: json.mid,
max: json.max !== undefined ? json.max : json.high
})
}

Expand All @@ -159,70 +158,70 @@ class DivergingGradientScale {
}
}

get low() {
return this.lowGradientScale.low
get min() {
return this.lowGradientScale.min
}

set low(v) {
this.lowGradientScale.low = v
set min(v) {
this.lowGradientScale.min = v
}

get high() {
return this.highGradientScale.high
get max() {
return this.highGradientScale.max
}

set high(v) {
this.highGradientScale.high = v
set max(v) {
this.highGradientScale.max = v
}

get mid() {
return this.lowGradientScale.high
return this.lowGradientScale.max
}

set mid(v) {
this.lowGradientScale.high = v
this.highGradientScale.low = v
this.lowGradientScale.max = v
this.highGradientScale.min = v
}

get lowColor() {
return this.lowGradientScale.lowColor
get minColor() {
return this.lowGradientScale.minColor
}

set lowColor(c) {
this.lowGradientScale.lowColor = c
set minColor(c) {
this.lowGradientScale.minColor = c
}

get highColor() {
return this.highGradientScale.highColor
get maxColor() {
return this.highGradientScale.maxColor
}

set highColor(c) {
this.highGradientScale.highColor = c
set maxColor(c) {
this.highGradientScale.maxColor = c
}

get midColor() {
return this.lowGradientScale.highColor
return this.lowGradientScale.maxColor
}

set midColor(c) {
this.lowGradientScale.highColor = c
this.highGradientScale.lowColor = c
this.lowGradientScale.maxColor = c
this.highGradientScale.minColor = c
}


/**
* Return a simple json-like object, not a literaly json string
* @returns {{high, mid, low, highColor, midColor, lowColor}}
* @returns {{max, mid, min, maxColor, midColor, minColor}}
*/
toJson() {
return {
type: this.type,
low: this.low,
min: this.min,
mid: this.mid,
high: this.high,
lowColor: this.lowColor,
max: this.max,
minColor: this.minColor,
midColor: this.midColor,
highColor: this.highColor
maxColor: this.maxColor
}
}

Expand Down
2 changes: 1 addition & 1 deletion js/version.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const _version = "3.0.9"
const _version = "3.1.0"
function version() {
return _version
}
Expand Down
Loading

0 comments on commit bf033cd

Please sign in to comment.