chart.js

Make time series show last date in axis?

僤鯓⒐⒋嵵緔 提交于 2021-02-17 06:54:49
问题 So in Chart.js i have a time series based on a range of dates. The chart can't show all the dates as axis label so it shows a reasonable selection. It always shows the first date on the left but not always the last date at the right end of the axis. For example my date range could be every day from 01-jan to 30-jul. The axis will start at 01-jan but the end date might be 27 28 or 29 jul. To me the end date is more important than the start date. Is there a way to show the last date reliably

Chart.js : How I change the x axes ticks labels alignment in any sizes?

廉价感情. 提交于 2021-02-17 05:52:24
问题 How can I move my labels on my x axes in between another x axes label. Nothing seems to work and I was unable to find anything on the docs. Is there a workaround? I'm using line chart time series. https://www.chartjs.org/samples/latest/scales/time/financial.html Currently, with the code I have its generating the figure below: var cfg = { elements:{ point: { radius: 4 } }, data: { datasets: [ { label: 'vsy', backgroundColor: color(window.chartColors.red).alpha(0.5).rgbString(), borderColor:

Chart.js what is the new syntax for extending?

强颜欢笑 提交于 2021-02-17 05:43:10
问题 So while looking at some code samples for Chart.js I came across the following JSFiddle ( http://jsfiddle.net/dbyze2ga/14/ ). When I coped it over to my IDE (brackets.io) it did not work until I realized that this jsfiddle uses chart.js 1.x.x. What is the current syntax for extending Charts using v2.0? I tried checking the documentation; but it honestly left me even more confused. Doesn't help that, at least in the case of Brackets, it won't show any real useful dot completion for the chart.

How to display final point value in charts.js

折月煮酒 提交于 2021-02-15 07:54:46
问题 I'm using Charts.js library to display a line graph from data which is constantly updated. Is there a way to display only the final point value at all times? I want it to do this to monitor the added values at all times. javascript code: var config2 = { type: 'line', data: { labels: 0, datasets: [{ label: "No selection", lineTension: 0, borderColor: "rgba(222, 44, 31)", pointBackgroundColor: "#fff675", fill: false, data: 0, } ] }, options: { responsive: true, title: { display: false, text:

Using data saved as a variable in HTML from Python

醉酒当歌 提交于 2021-02-15 07:50:37
问题 Is it possible to have a variable that is defined in a python file be passed through to a html file in the same directory and used in a 'script' tag? Synopsis: Im producing a flask website that pulls data from a database and uses it to create a line chart in chartjs. Flask uses jijna to manage templates. The data in the databse has been normalised so that it can be read by the chart script (label is in a list, data as a tuple). So far I have produced routes so that each page can be accessed

How can I position tooltip caret above and middle of bar?

谁都会走 提交于 2021-02-11 16:49:35
问题 The goal is to adjust the caret tooltip to be positioned above my horizontal stacked bar graph. oddly it works by setting yAlign to bottom and not to top. However it does not place the tooltip in the middle of the bar and it throws a TS ERROR saying Object literal may only specify known properties, and 'yAlign' does not exist in type 'ChartTooltipOptions'. Is there a correct way to do this besides setting the ts to ignore. options: { tooltips: { yAlign: 'bottom', displayColors: false,

How to get Data from API to display chart using chartjs in Vuejs

心不动则不痛 提交于 2021-02-11 16:35:41
问题 I am new to Vuejs and i wanna know how to fetch data from my API to display chart. Below is my code, where i have used data as "date and challenge" and have fed data directly to it, but now i want to call my API and feed the data from it to "date and challenge". Code that i have used it to display chart without API: <template> <canvas id="mychart" width="550" height="300"></canvas> </template> <script> export default { name: 'Chart', data: () => ({ date: [ 1600934100.0, 1602009600.0,

Php Array to line chart in ChartJs

流过昼夜 提交于 2021-02-11 15:46:39
问题 $days = ["Monday","Tuesday","Wednesday"]; $rates = [40,60,80]; $profit = []; foreach($days as $day => $value){ foreach($rates as $rate){ $netprofit = $rate* 20; $profit[$value] = [$rate=> $netprofit]; } } $usersChart = new UserChart; $usersChart->labels($days); foreach($profit as $key => $value){ $data = array(); foreach ($value as $values){ $data[] = $values; } $usersChart->dataset($key, 'line', collect($data)); } I want to show this array into Chartjs Line Graph. I want the x axis to be the

Php Array to line chart in ChartJs

人走茶凉 提交于 2021-02-11 15:46:37
问题 $days = ["Monday","Tuesday","Wednesday"]; $rates = [40,60,80]; $profit = []; foreach($days as $day => $value){ foreach($rates as $rate){ $netprofit = $rate* 20; $profit[$value] = [$rate=> $netprofit]; } } $usersChart = new UserChart; $usersChart->labels($days); foreach($profit as $key => $value){ $data = array(); foreach ($value as $values){ $data[] = $values; } $usersChart->dataset($key, 'line', collect($data)); } I want to show this array into Chartjs Line Graph. I want the x axis to be the

Chart JS - To Set Font Size and Color for the values Displayed on top Bubble Chart

ε祈祈猫儿з 提交于 2021-02-11 15:21:11
问题 I would need help in setting the Font Size and Font Color for the Bubble Chart. Currently, i'm adding values on top using the Animation Block's OnComplete property. Please find the below Code for the same: animation:{ "oncomplete": function(){ var chartInstance = this.chart, ctx = chartInstance.ctx; ctx.font = Chart.helpers.fontString(Chart.defaults.global.defaultFontSize, Chart.defaults.global.defaultFontStyle, Chart.defaults.global.defaultFontFamily); ctx.textAlign = 'center'; ctx