Work in progress
This commit is contained in:
parent
db7ad681ff
commit
af91fbc5ae
26
server.go
26
server.go
@ -58,12 +58,14 @@ func executeQuery(rw http.ResponseWriter, req *http.Request) {
|
||||
|
||||
response := jsonQueryResponse{
|
||||
Count: len(foundEntries),
|
||||
Ranges: make(map[string]jsonRange),
|
||||
Columns: make(map[string]jsonColumn),
|
||||
Records: make([]jsonRecord, 0)}
|
||||
|
||||
for name, value := range features {
|
||||
column := jsonColumn{Value: value, Steps: request.Resolution}
|
||||
column := jsonColumn{
|
||||
Bracket: jsonBracket{Max: -1, Min: 1},
|
||||
Value: value,
|
||||
Steps: request.Resolution}
|
||||
|
||||
hints := project(
|
||||
entries,
|
||||
@ -77,23 +79,17 @@ func executeQuery(rw http.ResponseWriter, req *http.Request) {
|
||||
column.Hints = append(column.Hints, jsonHint)
|
||||
}
|
||||
|
||||
for _, record := range foundEntries {
|
||||
if feature, ok := record.features[name]; ok {
|
||||
column.Bracket.Max = math.Max(column.Bracket.Max, feature)
|
||||
column.Bracket.Min = math.Min(column.Bracket.Min, feature)
|
||||
}
|
||||
}
|
||||
|
||||
response.Columns[name] = column
|
||||
}
|
||||
|
||||
for index, record := range foundEntries {
|
||||
for feature, value := range record.features {
|
||||
rng, ok := response.Ranges[feature]
|
||||
if ok {
|
||||
rng.Max = math.Max(rng.Max, value)
|
||||
rng.Min = math.Min(rng.Min, value)
|
||||
} else {
|
||||
rng.Max = value
|
||||
rng.Min = value
|
||||
}
|
||||
|
||||
response.Ranges[feature] = rng
|
||||
}
|
||||
|
||||
if index >= request.MaxResults {
|
||||
break
|
||||
}
|
||||
|
@ -96,6 +96,7 @@
|
||||
var _onValueChanged = params.onValueChanged;
|
||||
var _range = params.range;
|
||||
var _scale = params.scale;
|
||||
var _bracket = params.bracket;
|
||||
var _elements = {};
|
||||
|
||||
function createShapes() {
|
||||
@ -121,16 +122,6 @@
|
||||
stroke: _borderColor
|
||||
});
|
||||
|
||||
// bracket
|
||||
_elements.bracket = _canvas.rect(
|
||||
_width - _bracketSize,
|
||||
0,
|
||||
_bracketSize,
|
||||
_height - _panelSize
|
||||
).attr({
|
||||
fill: '#ff0000'
|
||||
});
|
||||
|
||||
// panel
|
||||
_elements.panel = _canvas.rect(
|
||||
_tickSize,
|
||||
@ -163,6 +154,26 @@
|
||||
fill: computeIndicatorColor(_data.value)
|
||||
}).click(clicked);
|
||||
|
||||
console.log(_data);
|
||||
|
||||
// bracketMin
|
||||
_elements.bracketMin = _canvas.circle(
|
||||
_width - _bracketSize / 2,
|
||||
valueToIndicator(_data.bracket.min),
|
||||
5
|
||||
).attr({
|
||||
fill: '#0000ff'
|
||||
});
|
||||
|
||||
// bracketMax
|
||||
_elements.bracketMax = _canvas.circle(
|
||||
_width - _bracketSize / 2,
|
||||
valueToIndicator(_data.bracket.max),
|
||||
5
|
||||
).attr({
|
||||
fill: '#ff0000'
|
||||
});
|
||||
|
||||
// tick
|
||||
if (_range.contains(0.0)) {
|
||||
var origin = valueToIndicator(0.0);
|
||||
@ -180,7 +191,8 @@
|
||||
_elements.backdrop,
|
||||
_elements.indicator,
|
||||
_elements.density,
|
||||
_elements.bracket,
|
||||
_elements.bracketMin,
|
||||
_elements.bracketMax,
|
||||
_elements.panel,
|
||||
_elements.tick,
|
||||
_elements.label
|
||||
@ -204,6 +216,16 @@
|
||||
_valueAnimated = value;
|
||||
}
|
||||
|
||||
function updateBracket() {
|
||||
_elements.bracketMin.attr({
|
||||
y: _data.bracket.min
|
||||
});
|
||||
|
||||
_elements.bracketMax.attr({
|
||||
y: _data.bracket.max
|
||||
});
|
||||
}
|
||||
|
||||
function updateDensity() {
|
||||
var fill = _backdropColor;
|
||||
if (_data.hints.length > 0) {
|
||||
@ -313,6 +335,10 @@
|
||||
_data.hints = data.hints;
|
||||
updateDensity();
|
||||
}
|
||||
if (_.has(data, 'bracket')) {
|
||||
_data.bracket = data.bracket;
|
||||
updateBracket();
|
||||
}
|
||||
};
|
||||
|
||||
createShapes();
|
||||
|
@ -120,7 +120,8 @@
|
||||
_ctx.query.features[feature] = column.value;
|
||||
columns[feature] = {
|
||||
value: column.value,
|
||||
hints: column.hints
|
||||
hints: column.hints,
|
||||
bracket: column.bracket
|
||||
};
|
||||
}
|
||||
|
||||
|
4
types.go
4
types.go
@ -49,6 +49,7 @@ type jsonQueryRequest struct {
|
||||
}
|
||||
|
||||
type jsonColumn struct {
|
||||
Bracket jsonBracket `json:"bracket"`
|
||||
Hints []jsonProjection `json:"hints"`
|
||||
Steps int `json:"steps"`
|
||||
Value float64 `json:"value"`
|
||||
@ -72,7 +73,7 @@ type jsonRecord struct {
|
||||
Url string `json:"url"`
|
||||
}
|
||||
|
||||
type jsonRange struct {
|
||||
type jsonBracket struct {
|
||||
Min float64 `json:"min"`
|
||||
Max float64 `json:"max"`
|
||||
}
|
||||
@ -80,7 +81,6 @@ type jsonRange struct {
|
||||
type jsonQueryResponse struct {
|
||||
Columns map[string]jsonColumn `json:"columns"`
|
||||
Count int `json:"count"`
|
||||
Ranges map[string]jsonRange `json:"ranges"`
|
||||
Records []jsonRecord `json:"records"`
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user