Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fermi level line and E-Ef (eV) to the band structure plot #44

Merged
merged 5 commits into from
Apr 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions js/lib/bandstructure.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,21 @@ BandPlot.prototype.initChart = function (ticksData) {

var bandPlotObject = this;

if (this.showFermi === false) {
annotations = {};
}
else {
annotations = {
type: 'line',
id: 'band-fermi',
scaleID: 'bandA',
mode: 'horizontal',
value: 0,
borderColor: 'red',
borderWidth: 2
}
}

var chartOptions = {
type: 'scatter',
data: {
Expand Down Expand Up @@ -244,6 +259,7 @@ BandPlot.prototype.initChart = function (ticksData) {
}
}],
yAxes: [{
id: 'bandA',
display: true,
ticks: {
// change the label of the ticks
Expand All @@ -261,6 +277,9 @@ BandPlot.prototype.initChart = function (ticksData) {
}
}]
},
annotation: {
annotations: [ annotations ]
},
zoom: {
enabled: true,
mode: "y",
Expand Down Expand Up @@ -333,8 +352,8 @@ BandPlot.prototype.initDosChart = function (orientation = 'vertical') {
display: this.showLegend,
position: 'right',
labels: {
filter: function(item, chart) {
// remove the label for the dumb dataset of the y axis
filter: function (item, chart) {
// remove the label for the dumb dataset of the y axis
return !item.text.includes('y axis');
}
}
Expand Down Expand Up @@ -450,8 +469,8 @@ BandPlot.prototype.initDosChart = function (orientation = 'vertical') {
display: true,
position: 'right',
labels: {
filter: function(item, chart) {
// remove the label for the dumb dataset of the y axis
filter: function (item, chart) {
// remove the label for the dumb dataset of the y axis
return !item.text.includes('y axis');
}
}
Expand Down Expand Up @@ -772,7 +791,7 @@ BandPlot.prototype.updateBandPlot = function (bandPath, forceRedraw) {

bandPlotObject.yLabel = bandPlotObject.allData[0].Y_label;
if (bandPlotObject.yLabel === undefined) {
bandPlotObject.yLabel = 'Electronic bands (eV)';
bandPlotObject.yLabel = 'E - Ef (eV)';
}

if (bandPlotObject.myChart === undefined) {
Expand Down Expand Up @@ -806,13 +825,13 @@ BandPlot.prototype.updateDosPlot = function (orientation = 'vertical') {
// So the color fill will up to the Fermi level
dosx.forEach(function (data, k) {
if (orientation === 'vertical') {
if (data <= bandPlotObject.dosFermiEnergy) {
curve.push({ x: 0, y: data - bandPlotObject.dosFermiEnergy });
};
if (data <= bandPlotObject.dosFermiEnergy) {
curve.push({ x: 0, y: data - bandPlotObject.dosFermiEnergy });
};
} else {
if (data <= bandPlotObject.dosFermiEnergy) {
curve.push({ x: data - bandPlotObject.dosFermiEnergy, y: 0 });
};
if (data <= bandPlotObject.dosFermiEnergy) {
curve.push({ x: data - bandPlotObject.dosFermiEnergy, y: 0 });
};
};
});

Expand Down