Skip to content

Commit

Permalink
adjusted histogram for testing purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
obstjn committed Dec 6, 2023
1 parent 30f3b5d commit 3de3509
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
<div #plot></div>
<p>{{counts|json}}</p>

Hello World
<p>{{counts|json}}</p>
Original file line number Diff line number Diff line change
@@ -1,61 +1,73 @@
import { Component, OnChanges, ViewChild, Input } from '@angular/core';
import { Component, OnChanges, OnInit, ViewChild, Input } from '@angular/core';
import { Chart } from 'chart.js';


Check failure on line 4 in src/app/components/qunicorn-app/histogram-plot/histogram-plot.component.ts

View workflow job for this annotation

GitHub Actions / Run linters

Delete `⏎⏎`

@Component({
selector: 'app-histogram-plot',
templateUrl: './histogram-plot.component.html',
styleUrls: ['./histogram-plot.component.scss'],
styleUrls: ['./histogram-plot.component.scss']

Check failure on line 9 in src/app/components/qunicorn-app/histogram-plot/histogram-plot.component.ts

View workflow job for this annotation

GitHub Actions / Run linters

Insert `,`
})
export class HistogramPlotComponent implements OnChanges {
export class HistogramPlotComponent implements OnInit {

Check failure on line 12 in src/app/components/qunicorn-app/histogram-plot/histogram-plot.component.ts

View workflow job for this annotation

GitHub Actions / Run linters

Delete `⏎`
@ViewChild('plot', { static: true }) plotDiv;

@Input() counts: { [props: string]: number } | null = null;

constructor() {}
constructor() { }

Check failure on line 17 in src/app/components/qunicorn-app/histogram-plot/histogram-plot.component.ts

View workflow job for this annotation

GitHub Actions / Run linters

Delete `·`

ngOnInit(): void {

Check failure on line 19 in src/app/components/qunicorn-app/histogram-plot/histogram-plot.component.ts

View workflow job for this annotation

GitHub Actions / Run linters

Delete `⏎`

ngOnChanges(): void {
const labels = Object.keys(this.counts);

const countsData = [];
labels.forEach((label) => countsData.push(this.counts[label]));
labels.forEach(label => countsData.push(this.counts[label]));

Check failure on line 24 in src/app/components/qunicorn-app/histogram-plot/histogram-plot.component.ts

View workflow job for this annotation

GitHub Actions / Run linters

Replace `label` with `(label)`

console.log(labels, countsData);

const data = {
labels, // Object.keys(this.counts),
labels: labels,//Object.keys(this.counts),

Check failure on line 29 in src/app/components/qunicorn-app/histogram-plot/histogram-plot.component.ts

View workflow job for this annotation

GitHub Actions / Run linters

Expected property shorthand

Check failure on line 29 in src/app/components/qunicorn-app/histogram-plot/histogram-plot.component.ts

View workflow job for this annotation

GitHub Actions / Run linters

missing whitespace (tslint:whitespace)

Check failure on line 29 in src/app/components/qunicorn-app/histogram-plot/histogram-plot.component.ts

View workflow job for this annotation

GitHub Actions / Run linters

Insert `·`

Check failure on line 29 in src/app/components/qunicorn-app/histogram-plot/histogram-plot.component.ts

View workflow job for this annotation

GitHub Actions / Run linters

Expected space or tab after '//' in comment
datasets: [
{
label: 'Counts',
data: countsData, // Object.values(this.counts),
backgroundColor: '#0000ff',
data: countsData,// Object.values(this.counts),
backgroundColor: "#0000ff"
},
],
]
};

const config = {
type: 'line',
data: {},
options: {},
plugins: [],
};
type: 'bar',
data: data,
options: {
scales: {
x: {
grid: {
offset: true
}
},
y: {
beginAtZero: true,
min: 0,
max: 2010,
}
}
},
}

const div: HTMLDivElement = this.plotDiv.nativeElement;
div.innerHTML = '';
const canvas = document.createElement('canvas');
canvas.setAttribute('height', '50px');
canvas.setAttribute('width', '50px');
canvas.width = 500;
canvas.height = 500;
div.innerHTML = "";
const canvas = document.createElement("canvas");
canvas.setAttribute("height", "5px");
canvas.setAttribute("width", "50px");
canvas.width = 5;
canvas.height = 5;
const context = canvas.getContext('2d');
context.scale(0.5, 0.5);
// chartcontext.scale(50, 50);
//chartcontext.scale(50, 50);
div.appendChild(canvas);

// new Chart(canvas, config)

// new Chart(context, config);

const DATA_COUNT = 7;
const NUMBER_CFG = { count: DATA_COUNT, min: -100, max: 100 };
new Chart(context, config);
}

}

0 comments on commit 3de3509

Please sign in to comment.