Skip to content
Permalink
Browse files

More color fixing; removed logging messages; improved display.

  • Loading branch information...
emeryberger committed Mar 20, 2019
1 parent cd26e3d commit 79e817a8bc458d23d0714a5afa1b34e35851e10e
Showing with 67 additions and 55 deletions.
  1. BIN logos/ExceLint/ExceLint.png
  2. +1 −1 manifest.xml
  3. +14 −9 src/components/App.tsx
  4. +3 −5 src/components/Header.tsx
  5. +49 −40 src/components/colorize.ts
BIN -4.63 KB (70%) logos/ExceLint/ExceLint.png
Binary file not shown.
@@ -16,7 +16,7 @@
<ProviderName>Emery Berger</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<!-- The display name of your add-in. Used on the store and various places of the Office UI such as the add-ins dialog. -->
<DisplayName DefaultValue="ExceLint" />
<DisplayName DefaultValue="" /> <!-- was "ExceLint" -->
<Description DefaultValue="ExceLint is Excellent"/>

<!-- Icon for your add-in. Used on installation screens and the add-ins dialog. -->
@@ -89,25 +89,30 @@ export default class App extends React.Component<AppProps, AppState> {
formula_color[formula_vec.join(",")] = f[1];
}
// console.log(JSON.stringify(formula_color));
/*
console.log(formulas[5][7]);

/* console.log(formulas[5][7]);
let general_re = '\\$?[A-Z]+\\$?\\d+';
let cell_col_absolute = new RegExp('\\$([A-Z]+)[^\\$\\d]?(\\d+)');
let cell_both_relative = new RegExp('[^\\$]?([A-Z]+)(\\d+)');
let cbr = new RegExp('('+general_re+'):('+general_re+')', 'g'); // new RegExp('[^\\$]?([A-Z]+)(\\d+)');
// let cbr = new RegExp('([A-Z]+)(\\d+)');
console.log(cbr.exec("=AVERAGE(L4:L7)"));
*/
console.log(cell_col_absolute.exec("=AVERAGE($L4)"));
console.log(cell_both_relative.exec("=AVERAGE($L4)"));
*/

let refs = Colorize.generate_all_references(formulas, vec[0], vec[1]);
console.log(refs);
// console.log(refs);
let data_color = {};
let processed_data = [];

// Color all references based on the color of their referring formula.
for (let refvec of Object.keys(refs)) {
// console.log("refvec = "+refvec);
console.log("ref loop checking refvec = " + refvec);
// console.log("refvec = "+refvec);
// console.log("ref loop checking refvec = " + refvec);
for (let r of refs[refvec]) {
console.log("ref loop checking " + r);
// console.log("ref loop checking " + r);
let color = formula_color[r.join(",")];
if (!(color === undefined)) {
// console.log("color = " + color);
@@ -116,13 +121,13 @@ export default class App extends React.Component<AppProps, AppState> {
//console.log(parseInt(rv[1]));
let row = parseInt(rv[0]);
let col = parseInt(rv[1]);
console.log("Checking "+row+", "+col);
// console.log("Checking "+row+", "+col);
if (!([row,col].join(",") in formula_color)) {
if (!([row,col].join(",") in data_color)) {
processed_data.push([[row, col], Colorize.get_light_color_version(color)]);
// currentWorksheet.getCell(col-1, row-1).format.fill.color = Colorize.get_light_color_version(color);
data_color[[row,col].join(",")] = Colorize.get_light_color_version(color);
console.log("Added "+row+", "+col);
// console.log("Added "+row+", "+col);

}
}
@@ -11,11 +11,9 @@ export class Header extends React.Component<HeaderProps, any> {

render() {
return (
<div id='content-header'>
<div className='padding'>
<h1>{this.props.title}</h1>
</div>
</div>
<div className='padding'>
<img src='assets/ExceLint.png' height='70' />
</div>
);
}
}
@@ -12,15 +12,16 @@ export class Colorize {
private static cell_row_absolute = new RegExp('[^\\$]?([A-Z]+)\\$(\\d+)');
private static cell_both_absolute = new RegExp('\\$([A-Z]+)\\$(\\d+)');

private static color_list = ["pink", "blue", "seagreen", "green", "darkturquoise", "darkgray", "darksalmon" ];
private static light_color_list = ["LightPink", "LightBlue", "LightYellow", "LightGreen", "LightSkyBlue", "LightGray", "LightSalmon" ];
private static color_list = ["pink", "blue", "seagreen", "green", "darkturquoise", "darkgray", "darksalmon", "mediumvioletred" ];
private static light_color_list = ["LightPink", "LightBlue", "LightYellow", "LightGreen", "LightSkyBlue", "LightGray", "LightSalmon", "PaleVioletRed" ];
private static light_color_dict = { "pink" : "LightPink",
"blue" : "LightBlue",
"seagreen" : "LightSeaGreen",
"green" : "LightGreen",
"darkturquoise" : "PaleTurquoise",
"darkgray" : "LightGray",
"darksalmon" : "LightSalmon" };
"darksalmon" : "LightSalmon",
"mediumvioletred" : "PaleVioletRed" };

public static get_color(hashval: number) : string {
return Colorize.color_list[hashval % Colorize.color_list.length];
@@ -198,39 +199,47 @@ export class Colorize {

// Returns a vector (x, y) corresponding to the column and row of the computed dependency.
public static cell_dependency(cell: string, origin_col: number, origin_row: number) : [number, number] {
let r = Colorize.cell_both_relative.exec(cell);
if (r) {
// console.log("both_relative");
let col = Colorize.column_name_to_index(r[1]);
let row = parseInt(r[2]);
return [col - origin_col, row - origin_row];
{
let r = Colorize.cell_col_absolute.exec(cell);
if (r) {
// console.log(JSON.stringify(r));
let col = Colorize.column_name_to_index(r[1]);
let row = parseInt(r[2]);
// console.log("absolute col: " + col + ", row: " + row);
return [col, row - origin_row];
}
}

r = Colorize.cell_col_absolute.exec(cell);
if (r) {
// console.log(JSON.stringify(r));
let col = Colorize.column_name_to_index(r[1]);
let row = parseInt(r[2]);
// console.log("absolute col: " + col + ", row: " + row);
return [col, row - origin_row];
{
let r = Colorize.cell_both_relative.exec(cell);
if (r) {
// console.log("both_relative");
let col = Colorize.column_name_to_index(r[1]);
let row = parseInt(r[2]);
return [col - origin_col, row - origin_row];
}
}

r = Colorize.cell_row_absolute.exec(cell);
if (r) {
// console.log("row_absolute");
let col = Colorize.column_name_to_index(r[1]);
let row = parseInt(r[2]);
return [col - origin_col, row];
}

r = Colorize.cell_both_absolute.exec(cell);
if (r) {
// console.log("both_absolute");
let col = Colorize.column_name_to_index(r[1]);
let row = parseInt(r[2]);
return [col, row];
{
let r = Colorize.cell_row_absolute.exec(cell);
if (r) {
// console.log("row_absolute");
let col = Colorize.column_name_to_index(r[1]);
let row = parseInt(r[2]);
return [col - origin_col, row];
}
}

{
let r = Colorize.cell_both_absolute.exec(cell);
if (r) {
// console.log("both_absolute");
let col = Colorize.column_name_to_index(r[1]);
let row = parseInt(r[2]);
return [col, row];
}
}

throw new Error('We should never get here.');
return [0, 0];
}
@@ -246,15 +255,15 @@ export class Colorize {
// First, get all the range pairs out.
while (found_pair = Colorize.range_pair.exec(range)) {
if (found_pair) {
console.log("all_cell_dependencies --> " + found_pair);
// console.log("all_cell_dependencies --> " + found_pair);
let first_cell = found_pair[1];
console.log(" first_cell = " + first_cell);
// console.log(" first_cell = " + first_cell);
let first_vec = Colorize.cell_dependency(first_cell, 0, 0);
console.log(" first_vec = " + JSON.stringify(first_vec));
// console.log(" first_vec = " + JSON.stringify(first_vec));
let last_cell = found_pair[2];
console.log(" last_cell = " + last_cell);
// console.log(" last_cell = " + last_cell);
let last_vec = Colorize.cell_dependency(last_cell, 0, 0);
console.log(" last_vec = " + JSON.stringify(last_vec));
// console.log(" last_vec = " + JSON.stringify(last_vec));

// First_vec is the upper-left hand side of a rectangle.
// Last_vec is the lower-right hand side of a rectangle.
@@ -264,8 +273,8 @@ export class Colorize {
let width = last_vec[1] - first_vec[1] + 1;
for (let x = 0; x < length; x++) {
for (let y = 0; y < width; y++) {
console.log(" pushing " + (x + first_vec[0]) + ", " + (y + first_vec[1]));
console.log(" (x = " + x + ", y = " + y);
// console.log(" pushing " + (x + first_vec[0]) + ", " + (y + first_vec[1]));
// console.log(" (x = " + x + ", y = " + y);
all_vectors.push([x + first_vec[0], y + first_vec[1]]);
}
}
@@ -370,12 +379,12 @@ export class Colorize {
for (let i = 0; i < formulas.length; i++) {
let row = formulas[i];
for (let j = 0; j < row.length; j++) {
console.log("origin_col = "+origin_col+", origin_row = " + origin_row);
// console.log("origin_col = "+origin_col+", origin_row = " + origin_row);
let all_deps = Colorize.all_cell_dependencies(row[j]); // , origin_col + j, origin_row + i);
if (all_deps.length > 0) {
console.log(all_deps);
// console.log(all_deps);
let src = [origin_col+j, origin_row+i];
console.log("src = " + src);
// console.log("src = " + src);
for (let dep of all_deps) {
let dep2 = dep; // [dep[0]+origin_col, dep[1]+origin_row];
// console.log("dep type = " + typeof(dep));

0 comments on commit 79e817a

Please sign in to comment.
You can’t perform that action at this time.