Chart.js start value (v2021)

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
dcxaspmaker
User
Posts: 35

Chart.js start value (v2021)

Post by dcxaspmaker »

ASP.NET Maker 2021.0.9
Extension Chart.js V18.0.0

How to set the start value always from "0" in chartjs eg. in Multi-series 2D Single Y Combination Chart (Column/Line/Area) ?

Gracias for support.


MichaelG
User
Posts: 1095

Post by MichaelG »

Please enable Tools -> Advanced Settings -> Chart scale begin with zero


dcxaspmaker
User
Posts: 35

Post by dcxaspmaker »

I have already seen and activated this parameter.
Unfortunately it doesn't work.


MichaelG
User
Posts: 1095

Post by MichaelG »

Please enable debug (Tools -> Advanced Settings -> Debug) and show the Chart JSON.


dcxaspmaker
User
Posts: 35

Post by dcxaspmaker »

5.250: (Chart JSON):

{
"type": "bar",
"data": {
"labels": [
"data1",
"data2",
"data3"
],
"datasets": [
{
"showLine": false,
"spanGaps": false,
"steppedLine": false,
"data": [
713.0,
603.0,
389.0
],
"backgroundColor": "rgba(189,183,107,0.5)",
"borderWidth": 1,
"borderColor": "rgba(189,183,107,1.0)",
"links": [
null,
null,
null
],
"label": "dummy0",
"type": "bar"
},
{
"showLine": false,
"spanGaps": false,
"steppedLine": false,
"data": [
713.0,
587.0,
389.0
],
"backgroundColor": "rgba(240,230,140,0.5)",
"borderWidth": 1,
"borderColor": "rgba(240,230,140,1.0)",
"links": [
null,
null,
null
],
"label": "dummy1",
"type": "bar"
},
{
"showLine": false,
"spanGaps": false,
"steppedLine": false,
"data": [
713.0,
603.0,
389.0
],
"backgroundColor": "rgba(255,255,0,0.5)",
"borderWidth": 1,
"borderColor": "rgba(255,255,0,1.0)",
"links": [
null,
null,
null
],
"label": "dummy2",
"type": "bar"
},
{
"showLine": false,
"spanGaps": false,
"steppedLine": false,
"data": [
713.0,
587.0,
389.0
],
"backgroundColor": "rgba(255,165,0,0.5)",
"borderWidth": 1,
"borderColor": "rgba(255,165,0,1.0)",
"links": [
null,
null,
null
],
"label": "dummy3",
"type": "bar"
},
{
"showLine": false,
"spanGaps": false,
"steppedLine": false,
"data": [
713.0,
581.0,
389.0
],
"backgroundColor": "rgba(255,99,71,0.5)",
"borderWidth": 1,
"borderColor": "rgba(255,99,71,1.0)",
"links": [
null,
null,
null
],
"label": "dummy4",
"type": "bar"
},
{
"showLine": false,
"spanGaps": false,
"steppedLine": false,
"data": [
713.0,
580.0,
388.0
],
"backgroundColor": "rgba(255,0,0,0.5)",
"borderWidth": 1,
"borderColor": "rgba(255,0,0,1.0)",
"links": [
null,
null,
null
],
"label": "dummy5",
"type": "bar"
},
{
"showLine": false,
"spanGaps": false,
"steppedLine": false,
"data": [
656.0,
436.0,
215.0
],
"backgroundColor": "rgba(192,192,192,0.5)",
"borderWidth": 1,
"borderColor": "rgba(192,192,192,1.0)",
"links": [
null,
null,
null
],
"label": "dummy6",
"type": "bar"
},
{
"showLine": false,
"spanGaps": false,
"steppedLine": false,
"data": [
448.0,
361.0,
203.0
],
"backgroundColor": "rgba(65,105,225,0.5)",
"borderWidth": 1,
"borderColor": "rgba(65,105,225,1.0)",
"links": [
null,
null,
null
],
"label": "dummy7",
"type": "bar"
},
{
"showLine": false,
"spanGaps": false,
"steppedLine": false,
"data": [
448.0,
361.0,
203.0
],
"backgroundColor": "rgba(30,144,255,0.5)",
"borderWidth": 1,
"borderColor": "rgba(30,144,255,1.0)",
"links": [
null,
null,
null
],
"label": "dummy8",
"type": "bar"
}
]
},
"options": {
"legend": {
"display": true,
"position": "bottom",
"fullWidth": false,
"reverse": false,
"labels": {
"usePointStyle": false
}
},
"title": {
"display": true,
"position": "top",
"text": "My Title"
},
"tooltips": {
"enabled": true,
"intersect": false,
"displayColors": false
},
"plugins": {
"filler": {
"propagate": false
},
"datalabels": {
"clamp": true
}
},
"animation": {
"animateRotate": false,
"animateScale": false
},
"responsive": false,
"scales": {
"xAxes": [
{
"gridLines": {
"offsetGridLines": false
}
}
],
"yAxes": [
{
"id": "P",
"position": "left"
}
]
}
}
}


MichaelG
User
Posts: 1095

Post by MichaelG »

Your Chart JSON is incorrect. Please make sure that you have generated all files (especially the config file).


dcxaspmaker
User
Posts: 35

Post by dcxaspmaker »

I do not understand anything. Can you please explain that in more detail.
ASP.Net Maker generates the files, what's the problem?


MichaelG
User
Posts: 1095

Post by MichaelG »

If you have re-generated all your files, you should have in "Models/src/Config.php":

public static bool ChartScaleBeginWithZero { get; set; } = true; // Chart scale begin with zero

The Chart JSON should look like:

"options": {
//...
"scales": {
"xAxes": [
{
"ticks": {
"beginAtZero": true
}
}
],


Post Reply