Skip to content

Commit

Permalink
Work for #48 - remove empty and unused sort option
Browse files Browse the repository at this point in the history
  • Loading branch information
tsv2013 committed May 30, 2024
1 parent 7a78221 commit 07db884
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
10 changes: 4 additions & 6 deletions examples/summary-remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,24 +225,22 @@ const summaryData = {
"product_improvement": {"native": 3, "support": 7, "mobile": 1, "platform": 1, "großmutter": 9, "product": 1, "super": 1, "functional": 1, "ux": 1, "challenging": 1, "goals": 1, "attract": 1, "audience": 3, "survey": 2, "builder": 5, "site": 1, "revisit": 1, "usability": 1, "ui": 2, "able": 1, "successfully": 1, "don't": 1, "input": 1, "negative": 1, "trial": 1, "error": 1, "learning": 1, "logic": 1, "surveymonkey": 1, "dfgdfg": 1, "fix": 1, "rtl": 1, "bugs\nsave": 1, "\"not": 1, "answered": 1, "questions\"": 1, "matrix": 1, "survey's": 1, "json": 1, "lack": 1, "accessibility": 1, "huge": 1, "disadvantage": 1, "that's": 1, "reason": 1, "projects": 1},
}

// function getSummaryData({ questionNames, filter, sort, callback }) {
// function getSummaryData({ visualizer, questionNames, filter, callback }) {
// console.log(JSON.stringify(filter));
// console.log(JSON.stringify(sort));
// setTimeout(() => {
// callback({ data: summaryData[questionNames[0]] });
// }, 1000);
// }

// function getSummaryData({ questionNames, filter, sort}) {
// function getSummaryData({ visualizer, questionNames, filter }) {
// const url = "http://www.example.com/";
// const reqBody = { questionNames, filter, sort };
// const reqBody = { questionNames, filter };
// return fetch(url, { body: reqBody });
// }

function getSummaryData({ visualizer, questionNames, filter, sort }) {
function getSummaryData({ visualizer, questionNames, filter }) {
console.log("Question: " + JSON.stringify(questionNames));
console.log("Filter: " + JSON.stringify(filter));
console.log("Sort: " + JSON.stringify(sort));
return new Promise((resolve, reject) => {
let dataSetName = questionNames[0];
if(["histogram", "number", "wordcloud", "text"].indexOf(visualizer.type) != -1) {
Expand Down
8 changes: 2 additions & 6 deletions src/dataProvider.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Event } from "survey-core";

export type SummaryFilter = { field: string, type: string, value: any };
export type SummarySortOrder = { field: string, direction: undefined | "asc" | "desc" };
export type GetDataUsingCallbackFn = (params: { visualizer: any, questionNames: string[], filter?: Array<SummaryFilter>, sort?: Array<SummarySortOrder>, callback?: (response: { data: Array<Object>, error?: any }) => void }) => void;
export type GetDataUsingPromiseFn = (params: { visualizer: any, questionNames: string[], filter?: Array<SummaryFilter>, sort?: Array<SummarySortOrder> }) => Promise<Array<Object>>;
export type GetDataUsingCallbackFn = (params: { visualizer: any, questionNames: string[], filter?: Array<SummaryFilter>, callback?: (response: { data: Array<Object>, error?: any }) => void }) => void;
export type GetDataUsingPromiseFn = (params: { visualizer: any, questionNames: string[], filter?: Array<SummaryFilter> }) => Promise<Array<Object>>;
export type GetDataFn = GetDataUsingCallbackFn | GetDataUsingPromiseFn;

export class DataProvider {
Expand Down Expand Up @@ -113,9 +112,6 @@ export class DataProvider {
}
}

public getSorters(): SummarySortOrder[] {
return [];
}
public getFilters(): SummaryFilter[] {
return Object.keys(this.filterValues).map(key => ({ field: key, type: "=", value: this.filterValues[key] }));
}
Expand Down
1 change: 0 additions & 1 deletion src/visualizerBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,6 @@ export class VisualizerBase implements IDataInfo {
questionNames: Array.isArray(this.name) ? this.name : [this.name],
visualizer: this,
filter: this.dataProvider.getFilters(),
sort: this.dataProvider.getSorters(),
callback: (loadedData: { data: Array<Object>, error?: any }) => {
this.loadingData = false;
if(!loadedData.error && Array.isArray(loadedData.data)) {
Expand Down

0 comments on commit 07db884

Please sign in to comment.