Skip to content

Commit

Permalink
Merge pull request #919 from vegaprotocol/feat/grid-colors-zero-axis
Browse files Browse the repository at this point in the history
feat: amend grid color, display 0 label on vertical axis
  • Loading branch information
asiaznik committed Oct 24, 2023
2 parents dac7015 + f84b3ee commit 61a1bb1
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
5 changes: 3 additions & 2 deletions src/feature/area-chart/contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type ContentsColors = Pick<
| "accent5"
| "accent6"
| "backgroundSurface"
| "emphasis100"
| "positiveFill"
| "positiveStroke"
| "negativeFill"
Expand Down Expand Up @@ -50,8 +51,8 @@ export class Contents {

this.colors = options.colors;

this.horizontalGrid = new HorizontalGrid();
this.verticalgrid = new VerticalGrid();
this.horizontalGrid = new HorizontalGrid(this.colors.emphasis100);
this.verticalgrid = new VerticalGrid(this.colors.emphasis100);
this.series = range(0, 5).map(() => new AreaCurve());

this.stage.addChild(this.horizontalGrid);
Expand Down
5 changes: 3 additions & 2 deletions src/feature/line-chart/contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type ContentsColors = Pick<
| "accent4"
| "accent5"
| "accent6"
| "emphasis100"
| "backgroundSurface"
| "positiveFill"
| "positiveStroke"
Expand Down Expand Up @@ -48,8 +49,8 @@ export class Contents {

this.colors = options.colors;

this.horizontalGrid = new HorizontalGrid();
this.verticalgrid = new VerticalGrid();
this.horizontalGrid = new HorizontalGrid(this.colors.emphasis100);
this.verticalgrid = new VerticalGrid(this.colors.emphasis100);
this.series = range(0, 5).map(() => new LineCurve());

this.stage.addChild(this.horizontalGrid);
Expand Down
5 changes: 3 additions & 2 deletions src/feature/price-chart/contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type ContentsColors = Pick<
| "accent5"
| "accent6"
| "backgroundSurface"
| "emphasis100"
| "positiveFill"
| "positiveStroke"
| "negativeFill"
Expand Down Expand Up @@ -47,8 +48,8 @@ export class Contents {

this.colors = options.colors;

this.horizontalGrid = new HorizontalGrid();
this.verticalgrid = new VerticalGrid();
this.horizontalGrid = new HorizontalGrid(this.colors.emphasis100);
this.verticalgrid = new VerticalGrid(this.colors.emphasis100);
this.priceCurve = new Area(options.colors);

this.stage.addChild(this.horizontalGrid);
Expand Down
8 changes: 5 additions & 3 deletions src/ui/display-objects/horizontal-grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ export class HorizontalGrid extends Container {
* Cache ticks
*/
private nodeByKeyValue = new Map<number, Graphics>();
private color: number;

constructor() {
constructor(color = 0x3d3d3d) {
super();
this.color = color;
}

public update(
Expand Down Expand Up @@ -56,7 +58,7 @@ export class HorizontalGrid extends Container {
line.clear();
line.lineStyle({
width: 1,
color: 0x3d3d3d,
color: this.color,
lineDash: [],
});
line.moveTo(0.5, 0);
Expand All @@ -76,7 +78,7 @@ export class HorizontalGrid extends Container {
line.clear();
line.lineStyle({
width: 1,
color: 0x3d3d3d,
color: this.color,
lineDash: [],
});
line.moveTo(0.5, 0);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/display-objects/vertical-axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class VerticalAxis extends Container {
this.overlay.endFill();

const numTicks = height / resolution / 50;
const ticks = scale.ticks(numTicks).filter((tick) => tick !== 0);
const ticks = scale.ticks(numTicks);
const tickFormat = scale.tickFormat(numTicks);

const enter = ticks.filter(
Expand Down
9 changes: 6 additions & 3 deletions src/ui/display-objects/vertical-grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ export class VerticalGrid extends Container {
*/
private nodeByKeyValue = new Map<string, Graphics>();

constructor() {
private color: number;

constructor(color = 0x3d3d3d) {
super();
this.color = color;
}

public update(
Expand Down Expand Up @@ -42,7 +45,7 @@ export class VerticalGrid extends Container {
line.clear();
line.lineStyle({
width: 1,
color: 0x3d3d3d,
color: this.color,
lineDash: [],
});
line.moveTo(0, 0.5);
Expand All @@ -61,7 +64,7 @@ export class VerticalGrid extends Container {

line.lineStyle({
width: 1,
color: 0x3d3d3d,
color: this.color,
lineDash: [],
});

Expand Down

0 comments on commit 61a1bb1

Please sign in to comment.