Skip to content

Commit

Permalink
Small tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmooney committed Oct 17, 2024
1 parent f4c7bf5 commit 7b11855
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ const CanvasSelectComponent = ({
nshades: 255,
format: 'rgbaString'
});
const ting = { name: name, colors: colorRamp };
colorMapList.push(ting);
const colorMap = { name: name, colors: colorRamp };
colorMapList.push(colorMap);

setColorMaps(colorMapList);
});
Expand Down Expand Up @@ -110,12 +110,12 @@ const CanvasSelectComponent = ({

const updateCanvas = (rampName: string) => {
// update canvas for displayed color ramp
const cv = document.getElementById('cv') as HTMLCanvasElement;
if (!cv) {
const canvas = document.getElementById('cv') as HTMLCanvasElement;
if (!canvas) {
return;
}
cv.style.visibility = 'hidden';
const ctx = cv.getContext('2d');
canvas.style.visibility = 'hidden';
const ctx = canvas.getContext('2d');

if (!ctx) {
return;
Expand All @@ -131,7 +131,7 @@ const CanvasSelectComponent = ({

ctx.fillRect(i * 2, 0, 2, 50);
}
cv.style.visibility = 'initial';
canvas.style.visibility = 'initial';
};

useEffect(() => {
Expand All @@ -147,7 +147,6 @@ const CanvasSelectComponent = ({
id="jp-gis-canvas-button"
onClick={toggleDropdown}
className="jp-Dialog-button jp-gis-canvas-button"
// style={{ visibility: 'hidden' }}
>
<canvas
id="cv"
Expand Down
11 changes: 6 additions & 5 deletions packages/base/src/dialogs/components/symbology/ColorRamp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ const ColorRamp = ({ layerId, modeOptions, classifyFunc }: IColorRampProps) => {
const populateOptions = async () => {
const stateDb = GlobalStateDbManager.getInstance().getStateDb();

const layerState = await stateDb?.fetch(`jupytergis:${layerId}`);
const layerState = (await stateDb?.fetch(
`jupytergis:${layerId}`
)) as ReadonlyJSONObject;

let nClasses, singleBandMode, colorRamp;

if (layerState) {
nClasses = (layerState as ReadonlyJSONObject).numberOfShades as string;
singleBandMode = (layerState as ReadonlyJSONObject)
.selectedMode as string;
colorRamp = (layerState as ReadonlyJSONObject).selectedRamp as string;
nClasses = layerState.numberOfShades as string;
singleBandMode = layerState.selectedMode as string;
colorRamp = layerState.selectedRamp as string;
}

setNumberOfShades(nClasses ? nClasses : '9');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ interface IColorRampEntryProps {
}

const ColorRampEntry = ({ index, colorMap, onClick }: IColorRampEntryProps) => {
// const canvasWidth = 345;
const canvasHeight = 30;

useEffect(() => {
const cv = document.getElementById(`cv-${index}`) as HTMLCanvasElement;
if (!cv) {
const canvas = document.getElementById(`cv-${index}`) as HTMLCanvasElement;
if (!canvas) {
return;
}
const ctx = cv.getContext('2d');
const ctx = canvas.getContext('2d');

if (!ctx) {
return;
Expand All @@ -41,7 +40,6 @@ const ColorRampEntry = ({ index, colorMap, onClick }: IColorRampEntryProps) => {
<span className="jp-gis-color-label">{colorMap.name}</span>
<canvas
id={`cv-${index}`}
// width={canvasWidth}
height={canvasHeight}
className="jp-gis-color-canvas"
></canvas>
Expand Down
7 changes: 0 additions & 7 deletions packages/base/src/dialogs/components/symbology/Graduated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ const Graduated = ({

const valueColorPairs: IStopRow[] = [];

// assume stops and colors are same length
for (let i = 0; i < +numberOfShades; i++) {
valueColorPairs.push({ stop: stops[i], output: colorMap[i] });
}
Expand Down Expand Up @@ -364,12 +363,6 @@ const Graduated = ({
>
Add Stop
</Button>
{/* <Button
className="jp-Dialog-button jp-mod-accept jp-mod-styled"
onClick={buildColorInfoFromClassification}
>
Classify
</Button> */}
</div>
</div>
);
Expand Down

0 comments on commit 7b11855

Please sign in to comment.