score:7
looks like your typescript compiler is complaining because the chart type
property is a specific type rather than a string.
option 1:
import charttype and cast type
as charttype
.
import { chart, charttype, ...} from 'chart.js';
...
function createchartconfig({labels, data, label, color}: chartconfig) {
return {
type: 'line' as charttype,
options: {
...
option 2: (the easier/hacky way)
cast the entire config as any.
new chart(gainctx, createchartconfig(gainconfig) as any);
in any case, you will need to import and register the needed controllers, elements, scales, etc. registering registerables
registers everything, but it is better to register only what you require for your specific chart. see the integration instructions for more information.
import { chart, registerables } from 'chart.js';
...
chart.register(...registerables);
Source: stackoverflow.com
Related Query
- Chart.js Types of property 'type' are incompatible. Type 'string' is not assignable to type '"line" | "bar" | "scatter"
- Property 'getContext' does not exist on type 'HTMLElement'
- Labels attribute of chartsjs not taking context variable of type string
- Alternating bars in bar chart in chart.js are not labelled
- Charts.js - Colors for stacked bar on multi-series line/bar chart are not working
- Chartjs with Typescript: The types of 'interaction.mode' are incompatible between these types
- colors are not updated when updating chart
- fill: 'origin' property does not work for my chart
- I am getting TS2339: Property 'chart' does not exist on type 'Window'?
- Chart won't draw. Returning a string value not a Number value - Meteor - Chartjs
- plugins.legend.align are incompatible types typescript chartjs
- ChartJS, updating chart type does not update xAxis properly
- I am using chart js to draw a chart. I did everything right but i don't know why the x axis and y axis label is not comming in chart. code below
- Property 'elements' does not exist on type 'typeof Chart'
- Is there any way to show a tooltip for points which are not visible on the chart in Chart.js?
- chartJS line chart not plotting values that are less than minY
- Chart JS ShowChart()bar" is not a chart type error
- angular chart js type line setting chart-options not working
- 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
- how to not repeat code while creating multiple charts in chart js
- How can labels/legends be added for all chart types in chart.js (chartjs.org)?
- ReferenceError: Chart is not defined - chartjs
- Chart Js Cannot read property 'length' of undefined
- Chart.js: bar chart first bar and last bar not displaying in full
- Chart.js: Dynamic Changing of Chart Type (Line to Bar as Example)
- react-chartjs-2 fill property not working?
- Chart.js responsive option - Chart not filling container
- show label in tooltip but not in x axis for chartjs line chart
- Using Chart.js - The X axis labels are not all showing
- Html chart does not fit a small Android WebView
More Query from same tag
- ng2-chart tooltip position change option?
- Is this graph possible using chart.js?
- Chart.js - Hide line using label string after load
- ChartJS Line chart causes browser crash
- Chart works uncorrectly chart.js
- Chartjs - Donut Chart label for small values not visible
- Update of options for PrimeNG Chart needs two calls instead of one
- Is there anyway add 2 or more chart with foreach loop
- How to show label at right side of Y axis same as left side of Y Axis ChartJS
- Small value in doughnut chart is not visible - Chartjs
- Chart.js: changing tooltip template
- how to remove odd number from yaxes in chartjs using angular?
- Node.js How to save data from pg database into variable
- undefined labels piechart - chartjs
- How do I group legend entries using Chartjs?
- chart.js doughnut legend in the chart
- Testing Chart.js Plugin with React and Jest/Enzyme
- Adding responsive text inside chart in Charts Js
- How to sort stacked bar chart on certain value of bar in charts.js
- ChartJS not work in .php loaded by jquery .load() (AJAX)
- How to change bar width individually in chartjs?
- Get data from SQLite as an array and generate charts with the data using Chart.js in an HTML
- Chartjs tick color different at zero
- pie chart not rendered properly in flask app
- how to show information of hidden bar graphs also in a Tooltip using chart.js in angular?
- How to create a histogram in charts.js with MYSQL data
- How to create pdf file in node js
- Chart JS tooltips diffrent colors for label
- Using Chart.js with Gatsby markdown
- how to use chart.js with angular-chart using requirejs