chart.js

Create IF to change chart.js bar color

佐手、 提交于 2020-01-17 05:28:04
问题 I'm new to JavaScript and i'm using chart.js to create some data visualizations, and i need to change the color of the entire bar for different values, the code i have so far is what follows, but i can't make it work, this isn't giving me any errors, so i don't know were to go. var dData1 = 90; ///////CARREGAR DADOS DE FACTURAÇÃO (for developer) var dData2 = 70; ///////CARREGAR DADOS DE FACTURAÇÃO (for developer) var barChartData = { labels: ["MÊS", "ANO"], datasets: [{ fillColor: "#f37c8a",

Chart.js Find intersection Point and Draw a Circle

倾然丶 夕夏残阳落幕 提交于 2020-01-17 04:27:05
问题 I am using chart.js for generating line chart. Its works me successfully. But I need to draw a circle or point at Intersection and draw a line towards "X" axis. Can you please any one help me to get this? Thanks in advance. 回答1: The main points to achieve this with chartjs (without being an chartjs expert by any means) would be: Method 1 - Math Step 1 Unless you can get a processed point array from chartjs' internals, you would have to, as chartjs uses Bezier curves to draw the graphs,

Chart JS: Donut/Doughnut Chart: Tooltip to be shown always for all the data. All tooltip is not shown when multiple data are with 0 data

我的梦境 提交于 2020-01-17 03:07:25
问题 I have created a donut chart. I want to display the tooltip always in the donut chart along with the legends. I have followed this stack overflow question. Question which explain the tooltip to be shown always I have followed the answer and created a doughnut chart and tried to show the tooltip always. it works fine, however it is not showing all the label, esp. when you have multiple data with 0 value.It just overwrite the label. my label and values are "Red" -0, "Green" -0 & "Yellow"-100

x-Axis not working because I'm not using correctly moment.js

天大地大妈咪最大 提交于 2020-01-16 11:59:34
问题 I'm trying to plot some info, and my x-axis are time. For this objective I'm using, chart.js and moment.js but I'm having some problems to convert this time to a label. My code is: var sData = { datasets: [{ label: 'Dataset1', data: [{ x: '09:00', y: 88 }, { x: '09:10', y: 89 }, { x: '09:13', y: 86 }, { x: '09:23', y: 86 }, { x: '09:26', y: 85}, { x: '09:29', y: 83 }] }, { label: 'Dataset2', data: [{ x: '09:02', y: 88 }, { x: '09:13', y: 89 }, { x: '09:14', y: 86 }, { x: '09:20', y: 86 }, { x

Canvas Emptied but Reappears

寵の児 提交于 2020-01-16 09:07:57
问题 I have seen several solutions on this issue but have not found one yet that works for my situation. I have a chart being made with chart.js which uses canvas to display. I have a function that is supposed to clear the canvas so that I can then redraw the chart with different x variables. The function works initially but as soon as I start to hover on my cleared canvas the old contents reappear. More specifically it seems to reappear if I am hovering over on of the previous data points. Here

Why are changing the time value of my axis (moment.js)?

我们两清 提交于 2020-01-16 08:37:16
问题 I am working with chart.js and moment.js to show a chart with x-axis as time. I had some problems with plotting this axis and I asked this question. @uminder solved it. This is his code, var sData = { datasets: [{ label: 'Dataset1', data: [{ x: '09:00', y: 88 }, { x: '09:10', y: 89 }, { x: '09:13', y: 86 }, { x: '09:23', y: 86 }, { x: '09:26', y: 85 }, { x: '09:29', y: 83 } ] }, { label: 'Dataset2', data: [{ x: '09:02', y: 88 }, { x: '09:13', y: 89 }, { x: '09:14', y: 86 }, { x: '09:20', y:

Chart Click Event - Clicking label of doughnut chart, doesn't return label ng2-charts

偶尔善良 提交于 2020-01-16 04:09:24
问题 I have a doughnut chart setup and I would like to use a click event on the label. Using the code from this answer (https://stackoverflow.com/a/49118430/4611941), I am able to trigger a click event when clicking on the chart to return the label and data: chartClicked (e: any): void { debugger; if (e.active.length > 0) { const chart = e.active[0]._chart; const activePoints = chart.getElementAtEvent(e.event); if ( activePoints.length > 0) { // get the internal index of slice in pie chart const

How to color legend in angular-chart.js

ぐ巨炮叔叔 提交于 2020-01-15 11:22:48
问题 the very last example in this section of angular-chart.js documentation shows a pie/polar chart example with a colored legend. Obviously, this should be my answer, but: I used this code for my frontend (which is pretty much the same as in the doc): <canvas id="base" class="chart-pie" chart-type="type" chart-data="data" chart-labels="labels" chart-legend="true"> </canvas> I did also use the same data and labels. But unfortunately the legend of the rendered plot consists out of list-bullet

How to color legend in angular-chart.js

送分小仙女□ 提交于 2020-01-15 11:22:04
问题 the very last example in this section of angular-chart.js documentation shows a pie/polar chart example with a colored legend. Obviously, this should be my answer, but: I used this code for my frontend (which is pretty much the same as in the doc): <canvas id="base" class="chart-pie" chart-type="type" chart-data="data" chart-labels="labels" chart-legend="true"> </canvas> I did also use the same data and labels. But unfortunately the legend of the rendered plot consists out of list-bullet

Values on Y-axis disappear (hide under labels)

喜你入骨 提交于 2020-01-15 09:17:32
问题 I use ChartJS library to create line chart. Somehow, the value on the Y values are almost hidden. I am wondering if I have set of data, how can I dynamically make y value so that it won't hide my y-value and still automatically scale base on my dataset selection. And here is the CodePen var ctx = document.getElementById("myChart"); var myChart = new Chart(ctx, { type: 'line', data: { labels: [1510001367000, 1510001379000, 1510001415000, 1510001427000], datasets: [ { label: 'dataset 1', fill: