Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed scatter bug #123

Merged
merged 1 commit into from
May 29, 2018
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
2 changes: 1 addition & 1 deletion packages/perspective-viewer-highcharts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"babel-runtime": "^6.26.0",
"chroma-js": "^1.3.4",
"gradient-parser": "0.1.5",
"highcharts": "6.0.7",
"highcharts": "6.1.0",
"highcharts-grouped-categories": "1.1.2",
"highcharts-more": "^0.1.2"
},
Expand Down
28 changes: 11 additions & 17 deletions packages/perspective-viewer-highcharts/src/js/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ import {color_axis} from "./color_axis.js";
import {make_tree_data, make_y_data, make_xy_data, make_xyz_data} from "./series.js";
import {set_boost, set_axis, set_category_axis, default_config} from "./config.js";

export const draw = (mode) => async function(el, view, hidden, task) {
export const draw = (mode) => async function(el, view, task) {
const row_pivots = this._view_columns('#row_pivots perspective-row:not(.off)');
const col_pivots = this._view_columns('#column_pivots perspective-row:not(.off)');
const aggregates = this._get_view_aggregates();
const hidden = this._get_view_hidden(aggregates);

const [js, schema, tschema] = await Promise.all([view.to_json(), view.schema(), this._table.schema()]);

Expand All @@ -42,7 +43,11 @@ export const draw = (mode) => async function(el, view, hidden, task) {
xaxis_name = aggregates.length > 0 ? aggregates[0].column : undefined,
xaxis_type = schema[xaxis_name],
yaxis_name = aggregates.length > 1 ? aggregates[1].column : undefined,
yaxis_type = schema[yaxis_name];
yaxis_type = schema[yaxis_name],
xtree_name = row_pivots.length > 0 ? row_pivots[row_pivots.length - 1] : undefined,
xtree_type = tschema[xaxis_name],
ytree_name = col_pivots.length > 1 ? col_pivots[col_pivots.length - 1] : undefined,
ytree_type = tschema[yaxis_name];

if (mode === 'scatter') {
let [series, top, colorRange] = make_xy_data(js, row_pivots, col_pivots, hidden);
Expand Down Expand Up @@ -73,13 +78,8 @@ export const draw = (mode) => async function(el, view, hidden, task) {
color_axis.call(this, config, colorRange)
set_boost(config);

xaxis_name = row_pivots.length > 0 ? row_pivots[row_pivots.length - 1] : undefined;
xaxis_type = tschema[xaxis_name];
yaxis_name = col_pivots.length > 1 ? col_pivots[col_pivots.length - 1] : undefined;
yaxis_type = tschema[yaxis_name];

set_category_axis(config, 'xAxis', xaxis_type, top);
set_category_axis(config, 'yAxis', yaxis_type, ytop);
set_category_axis(config, 'xAxis', xtree_type, top);
set_category_axis(config, 'yAxis', ytree_type, ytop);

Object.assign(config, {
series: [{
Expand Down Expand Up @@ -115,17 +115,11 @@ export const draw = (mode) => async function(el, view, hidden, task) {
} else {
let [series, top, colorRange] = make_y_data(js, row_pivots, hidden);
config.series = series;
const colors = series.length <= 10 ? COLORS_10 : COLORS_20;

xaxis_name = row_pivots.length > 0 ? row_pivots[row_pivots.length - 1] : undefined;
xaxis_type = tschema[xaxis_name];
yaxis_name = col_pivots.length > 1 ? col_pivots[col_pivots.length - 1] : undefined;
yaxis_type = tschema[yaxis_name];
set_category_axis(config, 'xAxis', xaxis_type, top);
config.colors = series.length <= 10 ? COLORS_10 : COLORS_20;
set_category_axis(config, 'xAxis', xtree_type, top);
config.legend.enabled = col_pivots.length > 0 || series.length > 1;
config.legend.floating = series.length <= 20;
Object.assign(config, {
colors: colors,
yAxis: {
startOnTick: false,
endOnTick: false,
Expand Down
4 changes: 3 additions & 1 deletion packages/perspective-viewer-highcharts/src/js/series.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
* Y
*/

import {COLORS_10, COLORS_20} from "./externals.js";

function row_to_series(series, sname, gname) {
let s;
for (var sidx = 0; sidx < series.length; sidx++) {
Expand All @@ -25,7 +27,7 @@ function row_to_series(series, sname, gname) {
s = {
name: sname,
connectNulls: true,
data: [],
data: []
};
if (gname) {
s.stack = gname;
Expand Down
3 changes: 2 additions & 1 deletion packages/perspective-viewer-hypergrid/src/js/hypergrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,8 @@ const LAZY_THRESHOLD = 10000;

const PRIVATE = Symbol("Hypergrid private");

async function grid(div, view, hidden, task) {
async function grid(div, view, task) {
let hidden = this._get_view_hidden();

this[PRIVATE] = this[PRIVATE] || {};

Expand Down
27 changes: 18 additions & 9 deletions packages/perspective-viewer/src/js/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,14 +531,11 @@ function update() {
let filters = this._get_view_filters();
let aggregates = this._get_view_aggregates();
if (aggregates.length === 0) return;
let hidden = [];
let sort = this._get_view_sorts("#sort perspective-row");
for (let s of sort) {
if (aggregates.map(agg => agg.column).indexOf(s[0]) === -1) {
let all = this._get_view_aggregates('#inactive_columns perspective-row');
aggregates.push(all.reduce((obj, y) => y.column === s[0] ? y : obj));
hidden.push(s[0]);
}
let hidden = this._get_view_hidden(aggregates, sort);
for (let s of hidden) {
let all = this._get_view_aggregates('#inactive_columns perspective-row');
aggregates.push(all.reduce((obj, y) => y.column === s ? y : obj));
}

if (this._view) {
Expand All @@ -564,7 +561,7 @@ function update() {
this._task.cancel();
}
const task = this._task = new CancelTask();
this._plugin.create.call(this, this._datavis, this._view, hidden, task).then(() => {
this._plugin.create.call(this, this._datavis, this._view, task).then(() => {
timer();
task.cancel();
}).catch(err => {
Expand All @@ -583,7 +580,7 @@ function update() {
this._render_count--;
});

this._plugin.create.call(this, this._datavis, this._view, hidden, task).catch(err => {
this._plugin.create.call(this, this._datavis, this._view, task).catch(err => {
console.warn(err);
}).finally(() => {
if (!this.hasAttribute('render_time')) {
Expand Down Expand Up @@ -673,6 +670,18 @@ function update() {
return this._view_columns('#sort perspective-row', false, false, true);
}

_get_view_hidden(aggregates, sort) {
aggregates = aggregates || this._get_view_aggregates();
let hidden = [];
sort = sort || this._get_view_sorts("#sort perspective-row");
for (let s of sort) {
if (aggregates.map(agg => agg.column).indexOf(s[0]) === -1) {
hidden.push(s[0]);
}
}
return hidden;
}

_view_columns(selector, types, filters, sort) {
selector = selector || '#active_columns perspective-row';
let selection = this.querySelectorAll(selector);
Expand Down