Categories
Mastering Development

chart.js: issue with concatening two line charts

I am trying to change the color of a part of a line chart in chart.js. I followed these posts: How to change line segment color of a line graph in Chart.js? And Chartjs Line Color Between Two Points I am close to achieving the proper result, however, the second line does not want to […]

Categories
Mastering Development

Is it possible to create just header tip visible bar chart with chart js just like in image

I want to change bar graph to make it look like the image one, which has only header tip visible not the whole bar, the header has the detail like shown in the image and only the header visible as a line in graph var ctx = document.getElementById(“myChart”); var myChart = new Chart(ctx, { type: […]

Categories
Mastering Development

increase the label size of a line chart in chart.js

I am unable to change the font of my labels. As you can see below I have a label that says “# of votes” and another label that says “# of points”. I want to make the size bigger for them. So i even added the following: label: { fontSize: 50 }, But I have […]

Categories
Development

I’m trying to add a click event, using javascript, to each column of a barchart in Chart.js

I’ve been trying to add a click event to each column in a bar chart using Chart.js. What I’m trying to figure out is how to make a click event on each column execute the code I want. The goal for this is when a user clicks on a particular bar of the chart, it […]

Categories
Development

React chartjs – chart stays empty unless legend is clicked twice

I am trying to make a chart in react by first retrieving some data from axios requests, so I am able to show a chart but it stays empty. When I click the legend twice it does show the data, but I want to show the data immediately. Anyone able to have a look at […]

Categories
Development

How should I include javascript in a template in Phoenix 1.5

I’m trying to include a javascript file that uses chart.js in my phoenix 1.5 project that uses webpack. When I add something like <script>require(‘/js/graph’).Graph.draw()</script> in a template, I see the error Uncaught ReferenceError: require is not defined in browser console and the graph is not rendered. package.json { “repository”: {}, “license”: “MIT”, “scripts”: { “deploy”: […]

Categories
Development

How I create a dropdown for chartjs from mysql database?

I have a mysql database named players and with these columns id, name, attack, defence, speed, dribbling and shoot. I create a radar chart to show players data. My code is this: <!DOCTYPE html> <html> <head> <style> </style> </head> <body> <script src=”https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js”></script> <canvas id=”canvas”></canvas> <script type=”text/javascript”> let json = <?php include(“datas.php”);?>; let label = []; […]

Categories
Development

Array doesn’t populate first time

supplypayment and supplyBrand arrays has no values for the first time when this function is called this.getSupply().subscribe (list => { let array = list.map(item =>{ return { $key: item.key, …item.payload.val() }; }); array.forEach(element => { this.supplypayment.push(element.payment); this.supplyBrand.push(element.BrandName); }); } supplyPayment and supplyBrand is used in the chart in the console the supplyPayment and supplyBrand is […]

Categories
Development

Plot time on Y axis

I want to plot the time when the sun sets. Here is my code: var ctxIndex = document.getElementById(‘sunset’); var myChart = new Chart(ctxIndex, { type: ‘line’, data: { labels: [‘19.09.19’, ‘21.09.19’, ‘22.09.19’], datasets: [{ label: ‘Sunset’, data: [’20:18′, ’20:18′, ’20:15′], backgroundColor: [‘rgba(255, 99, 132, 0.2)’], borderColor: [‘rgba(255, 99, 132, 1)’], borderWidth: 1 }] }, options: […]

Categories
Development

How to show data in a chart?

Hey there actually I am retrieving some data from database The data is is like this format id: “5” p_amount: “120” p_date: “09/20/2019” p_id: “12345” p_method: “Bank” p_status: “OPEN” This is what i did in ajax response, I convert the month of date in its name success: function(response){ var obj=JSON.parse(response); if(obj!=””){ $.each(obj, function(i, item) { […]