ng2-charts

Trying to set size of charts in ng2-charts

随声附和 提交于 2020-06-24 22:23:09
问题 I am trying to set the size of my charts. I have copy and pasted the ng2-chart example of the bar chart into my typescript file. If I play around with the canvas : <canvas baseChart width="100" height="100"> Nothing seems to happen with the size. It is always strechted to MAX. If I add some stylings : canvas { width: 50px; height: 50px; } It is also stretched to MAX. It seems that the chart is being displayed in some kind of iFrame which is confusing me more. Any help in how to set the size

Trying to set size of charts in ng2-charts

拈花ヽ惹草 提交于 2020-06-24 22:22:51
问题 I am trying to set the size of my charts. I have copy and pasted the ng2-chart example of the bar chart into my typescript file. If I play around with the canvas : <canvas baseChart width="100" height="100"> Nothing seems to happen with the size. It is always strechted to MAX. If I add some stylings : canvas { width: 50px; height: 50px; } It is also stretched to MAX. It seems that the chart is being displayed in some kind of iFrame which is confusing me more. Any help in how to set the size

ng2-charts: How to set fixed range for y axis

試著忘記壹切 提交于 2020-06-14 10:28:25
问题 I have a chart.js chart using ng2-charts module. The chart shows Percentage on y axis and time on x axis. Is it possible to set y axis to show 0 to 100 instead of dynamic range based on data? 回答1: Try adding the following to your chart options: scales : { yAxes: [{ ticks: { steps : 10, stepValue : 10, max : 100, min: 0 } }] } https://github.com/valor-software/ng2-charts/issues/853 回答2: In my name.component.html: <div style="display: block"> <canvas baseChart height="100" [datasets]=

ng2-charts: How to set fixed range for y axis

假装没事ソ 提交于 2020-06-14 10:25:51
问题 I have a chart.js chart using ng2-charts module. The chart shows Percentage on y axis and time on x axis. Is it possible to set y axis to show 0 to 100 instead of dynamic range based on data? 回答1: Try adding the following to your chart options: scales : { yAxes: [{ ticks: { steps : 10, stepValue : 10, max : 100, min: 0 } }] } https://github.com/valor-software/ng2-charts/issues/853 回答2: In my name.component.html: <div style="display: block"> <canvas baseChart height="100" [datasets]=

ng2-charts: How to set fixed range for y axis

痴心易碎 提交于 2020-06-14 10:25:21
问题 I have a chart.js chart using ng2-charts module. The chart shows Percentage on y axis and time on x axis. Is it possible to set y axis to show 0 to 100 instead of dynamic range based on data? 回答1: Try adding the following to your chart options: scales : { yAxes: [{ ticks: { steps : 10, stepValue : 10, max : 100, min: 0 } }] } https://github.com/valor-software/ng2-charts/issues/853 回答2: In my name.component.html: <div style="display: block"> <canvas baseChart height="100" [datasets]=

Chartjs / ng2-charts line on hover does not work

非 Y 不嫁゛ 提交于 2020-01-24 20:31:05
问题 I'm trying to optimize my chart using ng2-charts on Angular cli app. In general, everything works just fine, the only thing does not is the line on hover to track the data point. This is the ideal chart model I try to make and I also tried to follow its code: https://stackblitz.com/edit/line-chart?file=app%2Fapp.component.ts However, when I hover on my chart, only the tooltip is shown. Here are my codes: plugin-hoverline.ts: (copy & paste from the link below, credit by @GRUNT) https://istack

NotYetImplemented error ng2-charts

旧城冷巷雨未停 提交于 2020-01-24 08:54:44
问题 Getting an error with message "NotYetImplemented" from utils.js . I get the error while using nodejs server, what this exact error means? When I'm using "ng serve" there is no such error. I'm using line chart from ng2-charts module. Full Stack Trace: ERROR Error: NotYetImplemented at HTMLCanvasElement.exports.nyi (/home/project15/web/node_modules/domino/lib/utils.js:41:9) at BaseChartDirective.ngOnInit (/home/project15/web/node_modules/ng2-charts/charts/charts.js:24:47) at

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

ng2-charts - Can't bind to 'datasets' since it isn't a known property of 'base-chart'

只谈情不闲聊 提交于 2020-01-11 08:34:11
问题 Versions: Cordova: 6.3.1, Gulp CLI: 1.2.2, Ionic framework: 2.0.0-rc.0, Ionic CLI Version: 2.1.0 I'm using ng2-charts in my ionic2 application. Import not import {ChartsModule} from "ng2-charts"; but import {ChartsModule} from "ng2-charts/components/charts/charts;" because of this (issue #440) My entire app.module.ts import { NgModule } from '@angular/core'; import { IonicApp, IonicModule } from 'ionic-angular'; import { ChartsModule } from 'ng2-charts/components/charts/charts'; import {

Change bar color depending on value

一个人想着一个人 提交于 2020-01-07 04:41:05
问题 I'm using chart-js/ng2-charts for an angular 2 app. I can display a bar graph, but at the moment, all the bars are the same color. I'd like to have a different color depending on the value. Can that be done? 回答1: After you create your chart, you can use the following function to loop through the dataset and change the color depending on the data value. In this example, if the value is above a 50, the color changes to red. var colorChangeValue = 50; //set this to whatever is the deciding color