зеркало из https://github.com/microsoft/SandDance.git
Fixes for PowerBi tests (#51)
* handle null column * override state errors during load * logo color * use language file * whitespace
This commit is contained in:
Родитель
a399c850b3
Коммит
1c58556ca1
|
@ -16,6 +16,7 @@ import {
|
|||
util
|
||||
} from '@msrvida/sanddance-explorer';
|
||||
import { Logo } from '@msrvida/sanddance-explorer/dist/es6/controls/logo';
|
||||
import { strings } from './language';
|
||||
|
||||
fabric.initializeIcons();
|
||||
|
||||
|
@ -32,7 +33,7 @@ export interface Props {
|
|||
}
|
||||
|
||||
export interface State {
|
||||
loaded: boolean
|
||||
loaded: boolean;
|
||||
chromeless: boolean;
|
||||
darkTheme: boolean;
|
||||
}
|
||||
|
@ -124,7 +125,7 @@ export class App extends React.Component<Props, State> {
|
|||
React.createElement("div", { className: "sanddance-init" },
|
||||
React.createElement("div", null,
|
||||
React.createElement(Logo),
|
||||
React.createElement("div", null, "Please add fields to Values") //TODO language
|
||||
React.createElement("div", null, strings.notLoaded)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
export const strings = {
|
||||
notLoaded: "Please add fields to Values"
|
||||
}
|
|
@ -107,6 +107,7 @@ export class Visual implements IVisual {
|
|||
}
|
||||
|
||||
this.app.load(data, columns => {
|
||||
if (!columns) return;
|
||||
|
||||
const {
|
||||
sandDanceMainSettings,
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
text-align: center;
|
||||
}
|
||||
svg {
|
||||
fill: red;
|
||||
fill: rgb(0, 120, 212);
|
||||
height: 50px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,13 +14,13 @@ export function ensureColumnsExist(insightColumns: SandDance.types.InsightColumn
|
|||
|
||||
export function ensureColumnsPopulated(chart: SandDance.types.Chart, insightColumns: SandDance.types.InsightColumns, actualColumns: SandDance.types.Column[]) {
|
||||
//ensure columns are populated
|
||||
const firstColumnName = actualColumns[0].name;
|
||||
const firstColumn = actualColumns[0];
|
||||
const firstColumnName = firstColumn && firstColumn.name;
|
||||
const ensureColumn = (role: SandDance.types.InsightColumnRoles) => {
|
||||
if (!insightColumns[role]) {
|
||||
insightColumns[role] = firstColumnName;
|
||||
}
|
||||
};
|
||||
|
||||
switch (chart) {
|
||||
case 'barchart':
|
||||
ensureColumn('x');
|
||||
|
|
|
@ -289,9 +289,7 @@ export class Explorer extends React.Component<Props, State> {
|
|||
|
||||
ensureColumnsExist(newState.columns, dataContent.columns);
|
||||
const errors = ensureColumnsPopulated(partialInsight ? partialInsight.chart : null, newState.columns, dataContent.columns);
|
||||
if (errors) {
|
||||
newState.errors = errors;
|
||||
}
|
||||
newState.errors = errors;
|
||||
|
||||
this.changeInsight(newState as State);
|
||||
//make sure item is active
|
||||
|
|
|
@ -12,7 +12,8 @@ function isQuantitative(column: Column) {
|
|||
* @param data Array of data objects.
|
||||
*/
|
||||
export function getColumnsFromData(data: object[], columnTypes?: ColumnTypeMap) {
|
||||
const fields = Object.keys(data[0]);
|
||||
const sample = data[0];
|
||||
const fields = sample ? Object.keys(sample) : [];
|
||||
const inferences = { ...VegaDeckGl.base.vega.inferTypes(data, fields), ...columnTypes };
|
||||
const columns = fields.map(name => {
|
||||
const column: Column = {
|
||||
|
|
Загрузка…
Ссылка в новой задаче