Script fix + small optical changes

This commit is contained in:
Inga Kirschnick
2023-06-21 08:46:08 +02:00
parent d6e17e1554
commit 19e01d6709
3 changed files with 59 additions and 35 deletions

View File

@ -42,16 +42,17 @@ class CorpusAnalysisApp {
this.renderTextInfoList(data);
this.renderTextProportionsGraphic(data);
this.renderWordFrequenciesGraphic(data);
this.renderBoundsGraphic(data);
}
);
this.data.corpus.o.getCorpusData()
.then(corpusData => {
// this.renderGeneralCorpusInfo(corpusData);
// this.renderTextInfoList(corpusData);
// this.renderTextProportionsGraphic(corpusData);
// this.renderWordFrequenciesGraphic(corpusData);
this.renderWordDistributionsGraphic(corpusData);
});
// this.data.corpus.o.getCorpusData()
// .then(corpusData => {
// // this.renderGeneralCorpusInfo(corpusData);
// // this.renderTextInfoList(corpusData);
// // this.renderTextProportionsGraphic(corpusData);
// // this.renderWordFrequenciesGraphic(corpusData);
// // this.renderWordDistributionsGraphic(corpusData);
// });
// TODO: Don't do this hgere
cQiCorpus.updateDb();
this.enableActionElements();
@ -142,6 +143,7 @@ class CorpusAnalysisApp {
textData.push(resource);
}
corpusTextInfoList.add(textData);
let textCountChipElement = document.querySelector('.text-count-chip');
@ -160,7 +162,7 @@ class CorpusAnalysisApp {
];
let graphLayout = {
height: 600,
width: 600
width: 900
};
Plotly.newPlot(textProportionsGraphicElement, graphData, graphLayout);
}
@ -169,8 +171,10 @@ class CorpusAnalysisApp {
let wordFrequenciesGraphicElement = document.querySelector('#word-frequencies-graphic');
let words = Object.entries(corpusData.corpus.lexicon[0].freqs.word).sort((a, b) => b[1] - a[1]).slice(0, 5);
let texts = Object.entries(corpusData.text.lexicon);
let graphData = [];
for (let word of words) {
console.log(texts.map(text => text[1].freqs.word[word[0]]));
let data = {
x: texts.map(text => `${corpusData.lookups.text[text[0]].title} (${corpusData.lookups.text[text[0]].publishing_year})`),
y: texts.map(text => text[1].freqs.word[word[0]]),
@ -182,30 +186,46 @@ class CorpusAnalysisApp {
let graphLayout = {
height: 600,
width: 600,
width: 900,
barmode: 'stack',
type: 'bar'
};
Plotly.newPlot(wordFrequenciesGraphicElement, graphData, graphLayout);
}
renderWordDistributionsGraphic(corpusData) {
// let wordDistributionGraphicElement = document.querySelector('#word-distributions-graphic');
// var trace1 = {
// x: [1, 2, 3, 4],
// y: [10, 11, 12, 13],
// mode: 'markers',
// marker: {
// size: [40, 60, 80, 100]
// }
// };
// var data = [trace1];
// var layout = {
// title: 'Marker Size',
// showlegend: false,
// height: 500,
// width: 600
// };
// Plotly.newPlot(wordDistributionGraphicElement, data, layout);
renderBoundsGraphic(corpusData) {
let boundsGraphicElement = document.querySelector('#bounds-graphic');
let graphData = [];
let texts = Object.entries(corpusData.text.lexicon);
graphData = [{
type: 'bar',
x: texts.map(text => text[1].bounds[1] - text[1].bounds[0]),
y: texts.map(text => corpusData.lookups.text[text[0]].title),
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})`),
orientation: 'h',
hovertemplate: '%{base} - %{x} <br>%{y}',
showlegend: false
}];
let graphLayout = {
height: 600,
width: 2000,
barmode: 'stack',
type: 'bar',
showgrid: false,
xaxis: {
rangemode: 'nonnegative',
autorange: true
},
yaxis: {
autorange: true,
showticklabels: false
}
};
Plotly.newPlot(boundsGraphicElement, graphData, graphLayout);
}
}