Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var source = new carto.source.SQL('select * from ticketspercounty_copy');
- var histogram = new carto.dataview.Histogram(source, 'ticketcount',{bins: 46});
- histogram.on('dataChanged', (data) => {
- //console.log(data)
- let chart = new Chart(histo, {
- type: "bar",
- data: {
- labels: ['Abbeville',
- 'Charleston',
- 'York',
- ],
- datasets: [
- {
- data: data.bins.map(element => element.freq)
- }
- ]
- }
- });
- });
- // Add the histogram to the client
- client.addDataview(histogram);
- const histogramDataview = new carto.dataview.Histogram(source, 'pop2005', {bins: 10});
- const histogramElement = document.getElementById('chart'); const histoChart = new Chart(histogramElement, {
- type: "bar",
- data: {
- datasets: [{
- label: 'Frequency',
- data: [],
- backgroundColor: [
- '#fcde9c','#faa476','#f0746e','#e34f6f','#dc3977','#b9257a','#7c1d6f'
- ]
- }]
- }
- });
- client.addDataview(histogramDataview);
- histogramDataview.on('dataChanged', (data) => {
- histoChart.data.labels = data.bins.map(x => `${x.start} to ${x.end}`);
- histoChart.data.datasets.forEach((dataset) => {
- dataset.data = data.bins.map(x => x.freq);
- });
- histoChart.update(); });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement