Area chart is shown wrongly, area is not being covered completely

1 Answer 71 Views
Charts
Christian
Top achievements
Rank 1
Iron
Christian asked on 02 Dec 2021, 02:47 PM

Ive been having a problem when using the area chart component, it is not filling all the area with the color, so it remains blank on some lines.

Attached is the result so far.

const ChartComponent = () => {   
     const firstSeries =    [
		{
			date: '2021-03-29T00:00:00+00:00',
			score: 573
		},
		{
			date: '2021-04-05T00:00:00+00:00',
			score: 630
		},
		{
			date: '2021-04-12T00:00:00+00:00',
			score: 643
		},
		{
			date: '2021-04-19T00:00:00+00:00',
			score: 589
		},
		{
			date: '2021-04-26T00:00:00+00:00',
			score: 589
		},
		{
			date: '2021-05-10T00:00:00+00:00',
			score: 544.25
		}]  
                const data = firstSeries.map(s => Math.round(s.score));
	        const labels = firstSeries.map(s =>s.date);

                return( <Chart>
				<ChartArea height={441} />
				<ChartCategoryAxis>
					<ChartCategoryAxisItem
						majorGridLines={{ visible: false }}
						justified={true}
						categories={labels}
						labels={{ rotation: 'auto' }}
						type="date"
					/>
				</ChartCategoryAxis>
				<ChartValueAxis>
					<ChartValueAxisItem
						min={Math.round(Math.min(...data) / 10) * 10}
						majorGridLines={{
							visible: false
						}}
						title={{
							text: 'Scaled Score'
						}}
					/>
				</ChartValueAxis>
				<ChartSeries>
					<ChartSeriesItem
						type="line"
						data={data}
						markers={{
							visible: true,
							type: 'circle'
						}}
						color="rgb(0 143 204)"
					/>
					<ChartSeriesItem type="area" data={data} color="rgb(214 237 247)" />
				</ChartSeries>
                        </Chart>
      )
}

Can someone possible tell me whats wrong here?

1 Answer, 1 is accepted

Sort by
1
Accepted
Filip
Telerik team
answered on 06 Dec 2021, 02:35 PM

Hi, Christian,

The current behavior occurs because, by default, line series and area series have different values that are set as missingValues, for example, the value for the line chart is "interpolate" and for the area chart the value is  "zero".  By changing the missingValues prop to "interpolate" the area will take the entire space, as shown in this example:

https://stackblitz.com/edit/react-n51kbm-w2xj8u?file=app/main.tsx

I hope this helps.

Regards, FilipProgress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Christian
Top achievements
Rank 1
Iron
commented on 06 Dec 2021, 07:15 PM

Thanks Filip for your help,

It solved the problem :)

Tags
Charts
Asked by
Christian
Top achievements
Rank 1
Iron
Answers by
Filip
Telerik team
Share this question
or