Skip to content

Commit 3fa3e52

Browse files
committed
Display Dashboard correctly after import #196
* When importing a JSON file the Dashboard charts and legends were not showing correctly. The legend and percentages would sometimes be missing. * Changed No Value Detected to be hidden after load * Cached graph data after the first load so that a db lookup isnt needed for each redraw of the charts * Fixed bug where the packages bar graph displayed incorrect colors Signed-off-by: Jillian Daguil <[email protected]>'
1 parent 12c8bda commit 3fa3e52

File tree

1 file changed

+52
-36
lines changed

1 file changed

+52
-36
lines changed

assets/js/aboutCodeDashboard.js

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,18 @@ class AboutCodeDashboard {
3636
this.totalPackages = $("#total-packages .title");
3737

3838
this.dashboardId = dashboardId;
39-
this.aboutCodeDB = aboutCodeDB;
39+
this.database(aboutCodeDB);
4040

4141
this.sourceLanguageChart = c3.generate({
4242
bindto: "#source-chart",
4343
data: {
4444
columns: [],
4545
type: "pie",
4646
order: 'desc',
47-
hide: 'No Value Detected'
4847
},
4948
color: {
5049
pattern: LEGEND_COLORS
51-
}
50+
},
5251
});
5352

5453
this.licenseCategoryChart = c3.generate({
@@ -57,7 +56,6 @@ class AboutCodeDashboard {
5756
columns: [],
5857
type: "pie",
5958
order: 'desc',
60-
hide: 'No Value Detected'
6159
},
6260
color: {
6361
pattern: LEGEND_COLORS
@@ -70,7 +68,6 @@ class AboutCodeDashboard {
7068
columns: [],
7169
type: "pie",
7270
order: 'desc',
73-
hide: 'No Value Detected'
7471
},
7572
color: {
7673
pattern: LEGEND_COLORS
@@ -83,7 +80,6 @@ class AboutCodeDashboard {
8380
columns: [],
8481
type: "bar",
8582
order: 'desc',
86-
hide: 'No Value Detected'
8783
},
8884
color: {
8985
pattern: LEGEND_COLORS
@@ -93,9 +89,7 @@ class AboutCodeDashboard {
9389

9490
database(aboutCodeDB) {
9591
this.aboutCodeDB = aboutCodeDB;
96-
}
9792

98-
reload() {
9993
// Get total files scanned
10094
this.aboutCodeDB.db.then(() => {
10195
return this.aboutCodeDB.ScanCode
@@ -123,37 +117,59 @@ class AboutCodeDashboard {
123117
.then(count => this.totalPackages.text(count ? count : "0"));
124118
});
125119

126-
this.sourceLanguageChart.unload({
127-
done: () => {
128-
// Get unique programming languages detected
129-
this._loadData("programming_language")
130-
.then(data => this.sourceLanguageChart.load({columns: data}));
131-
}
132-
});
120+
// Get unique programming languages detected
121+
this.sourceLanguageData = this._loadData("programming_language");
133122

134-
this.licenseCategoryChart.unload({
135-
done: () => {
136-
// Get license categories detected
137-
this._loadData("license_category")
138-
.then(data => this.licenseCategoryChart.load({columns: data}));
139-
}
140-
});
123+
// Get license categories detected
124+
this.licenseCategoryData = this._loadData("license_category");
141125

142-
this.licenseKeyChart.unload({
143-
done: () => {
144-
// Get license keys detected
145-
this._loadData("license_key")
146-
.then(data => this.licenseKeyChart.load({columns: data}));
147-
}
148-
});
126+
// Get license keys detected
127+
this.licenseKeyData = this._loadData("license_key");
149128

150-
this.packagesTypeChart.unload({
151-
done: () => {
152-
// Get package types detected
153-
this._loadData("packages_type")
154-
.then(data => this.packagesTypeChart.load({columns: data}));
155-
}
156-
});
129+
// Get package types detected
130+
this.packagesTypeData = this._loadData("packages_type");
131+
}
132+
133+
reload() {
134+
this.sourceLanguageData
135+
.then(data => this.sourceLanguageChart.load({
136+
columns: data,
137+
unload: true,
138+
done: () => {
139+
this.sourceLanguageChart.legend.show();
140+
this.sourceLanguageChart.hide('No Value Detected');
141+
}
142+
}));
143+
144+
this.licenseCategoryData
145+
.then(data => this.licenseCategoryChart.load({
146+
columns: data,
147+
unload: true,
148+
done: () => {
149+
this.licenseCategoryChart.legend.show();
150+
this.licenseCategoryChart.hide('No Value Detected');
151+
}
152+
}));
153+
154+
this.licenseKeyData
155+
.then(data => this.licenseKeyChart.load({
156+
columns: data,
157+
unload:true,
158+
done: () => {
159+
this.licenseKeyChart.legend.show();
160+
this.licenseKeyChart.hide('No Value Detected');
161+
}
162+
}));
163+
164+
this.packagesTypeData
165+
.then(data => this.packagesTypeChart.load({
166+
columns: data,
167+
unload: true,
168+
done: () => {
169+
this.packagesTypeChart.legend.show();
170+
this.packagesTypeChart.hide('No Value Detected');
171+
}
172+
}));
157173
}
158174

159175
_loadData(attribute, parentPath) {

0 commit comments

Comments
 (0)