Visualization fix for real data

This commit is contained in:
Inga Kirschnick 2023-06-22 16:38:06 +02:00
parent 1c98c5070a
commit 6c31788402
2 changed files with 27 additions and 32 deletions

View File

@ -34,26 +34,26 @@ class CorpusAnalysisApp {
.then( .then(
cQiCorpus => { cQiCorpus => {
this.data.corpus = {o: cQiCorpus}; this.data.corpus = {o: cQiCorpus};
// this.data.corpus.o.getVisualizationData() this.data.corpus.o.getVisualizationData()
// .then( .then(
// (data) => { (data) => {
// console.log(data); console.log(data);
// this.renderGeneralCorpusInfo(data); this.renderGeneralCorpusInfo(data);
// this.renderTextInfoList(data); this.renderTextInfoList(data);
// this.renderTextProportionsGraphic(data); this.renderTextProportionsGraphic(data);
// this.renderWordFrequenciesGraphic(data); this.renderFrequenciesGraphic(data);
// this.renderBoundsGraphic(data); this.renderBoundsGraphic(data);
// } }
// ); );
this.data.corpus.o.getCorpusData() // this.data.corpus.o.getCorpusData()
.then(corpusData => { // .then(corpusData => {
console.log(corpusData); // console.log(corpusData);
this.renderGeneralCorpusInfo(corpusData); // this.renderGeneralCorpusInfo(corpusData);
this.renderTextInfoList(corpusData); // this.renderTextInfoList(corpusData);
this.renderTextProportionsGraphic(corpusData); // this.renderTextProportionsGraphic(corpusData);
this.renderFrequenciesGraphic(corpusData); // this.renderFrequenciesGraphic(corpusData);
this.renderBoundsGraphic(corpusData); // this.renderBoundsGraphic(corpusData);
}); // });
// TODO: Don't do this hgere // TODO: Don't do this hgere
cQiCorpus.updateDb(); cQiCorpus.updateDb();
this.enableActionElements(); this.enableActionElements();
@ -132,10 +132,8 @@ class CorpusAnalysisApp {
let textData = []; let textData = [];
for (let i = 0; i < Object.entries(texts).length; i++) { for (let i = 0; i < Object.entries(texts).length; i++) {
let resource = { let resource = {
// title: "corpusData.values.text[i].title", title: corpusData.values.s_attrs.text[i].title,
// publishing_year: "corpusData.lookups.text[i].publishing_year", publishing_year: corpusData.values.s_attrs.text[i].publishing_year,
title: `Text ${i}`,
publishing_year: "2023",
num_tokens: corpusData.s_attrs.text.lexicon[i].counts.token, num_tokens: corpusData.s_attrs.text.lexicon[i].counts.token,
num_sentences: corpusData.s_attrs.text.lexicon[i].counts.s, num_sentences: corpusData.s_attrs.text.lexicon[i].counts.s,
num_unique_words: Object.entries(corpusData.s_attrs.text.lexicon[i].freqs.word).length, num_unique_words: Object.entries(corpusData.s_attrs.text.lexicon[i].freqs.word).length,
@ -159,8 +157,7 @@ class CorpusAnalysisApp {
let graphData = [ let graphData = [
{ {
values: texts.map(text => text[1].counts.token), values: texts.map(text => text[1].counts.token),
// labels: texts.map(text => `${corpusData.lookups.text[text[0]].title} (${corpusData.lookups.text[text[0]].publishing_year})`), labels: texts.map(text => `${corpusData.values.s_attrs.text[text[0]].title} (${corpusData.values.s_attrs.text[text[0]].publishing_year})`),
labels: texts.map(text => text[0]),
type: 'pie' type: 'pie'
} }
]; ];
@ -199,8 +196,7 @@ class CorpusAnalysisApp {
for (let item of sortedData) { for (let item of sortedData) {
let data = { let data = {
// x: texts.map(text => `${corpusData.lookups.text[text[0]].title} (${corpusData.lookups.text[text[0]].publishing_year})`), x: texts.map(text => `${corpusData.values.s_attrs.text[text[0]].title} (${corpusData.values.s_attrs.text[text[0]].publishing_year})`),
x: texts.map(text => text[0]),
y: texts.map(text => text[1].freqs[category][item[0]]), y: texts.map(text => text[1].freqs[category][item[0]]),
name: corpusData.values.p_attrs[category][item[0]], name: corpusData.values.p_attrs[category][item[0]],
type: 'bar' type: 'bar'
@ -220,11 +216,9 @@ class CorpusAnalysisApp {
graphData = [{ graphData = [{
type: 'bar', type: 'bar',
x: texts.map(text => text[1].bounds[1] - text[1].bounds[0]), x: texts.map(text => text[1].bounds[1] - text[1].bounds[0]),
// y: texts.map(text => corpusData.lookups.text[text[0]].title), y: texts.map(text => corpusData.values.s_attrs.text[text[0]].title),
y: texts.map(text => text[0]),
base: texts.map(text => text[1].bounds[0]), base: texts.map(text => text[1].bounds[0]),
// text: texts.map(text => `${corpusData.lookups.text[text[0]].title} (${corpusData.lookups.text[text[0]].publishing_year})`), text: texts.map(text => `${corpusData.values.s_attrs.text[text[0]].title} (${corpusData.values.s_attrs.text[text[0]].publishing_year})`),
text: texts.map(text => text[0]),
orientation: 'h', orientation: 'h',
hovertemplate: '%{base} - %{x} <br>%{y}', hovertemplate: '%{base} - %{x} <br>%{y}',
showlegend: false showlegend: false

View File

@ -103,6 +103,7 @@ class CorpusTextInfoList extends ResourceList {
if (sortElement !== clickedSortElement) { if (sortElement !== clickedSortElement) {
sortElement.classList.remove('asc', 'desc'); sortElement.classList.remove('asc', 'desc');
sortElement.style.color = 'black'; sortElement.style.color = 'black';
sortElement.innerHTML = 'arrow_drop_down';
}; };
}); });
clickedSortElement.style.color = '#aa9cc9'; clickedSortElement.style.color = '#aa9cc9';