LightningWebChartJS icon indicating copy to clipboard operation
LightningWebChartJS copied to clipboard

Unable to use the ticks-labels attribute defined in the Documentation

Open 1quest opened this issue 2 months ago • 0 comments

What is affected by this bug?

Bar charts, when adding a secondary category-axis. Doesn't seem to follow the documentation (https://salesforcelabs.github.io/LightningWebChartJS/docs/api/axes/cartesian/category.html) as the ticks-labels aren't used?

Where on the platform does it happen?

On a ServiceMax page on the Installed Product, under IB Technical Attribute

How do we replicate the issue?

I have a LWC defined as below, first the html-part

<c-sample-app-item>
  <c-chart slot="chartExample" type="bar" responsive="true">
	<c-dataset labels='["21;-One","Two","23;-One","Two","24;-One","Two","22-One","Two"]'>
	  <c-data label="OK" detail="[17,17,16,16,17,17,16,17]" backgroundcolor='rgba(50, 150, 237, 1)' stack="1" categorypercentage=1></c-data>
	  <c-data label="Flagged" detail="[0,0,1,0,1,0,1,0]" backgroundcolor='rgba(119, 185, 242, 1)' stack="1" categorypercentage=1></c-data>
	  <c-data label="NOK" detail="[17,17,17,16,19,18,17,17]" backgroundcolor='rgba(157, 83, 242, 1)' stack="1" categorypercentage=1></c-data>
	</c-dataset>
	<c-cartesian-category-axis 
	  axis="x" 
	  stacked="true" 
	  position="bottom" 
	  type="category">
	</c-cartesian-category-axis> 
	<c-cartesian-category-axis 
	  axis="x"  
	  position="top"
// These aren't visible/used anywhere in the chart visualization as-is, but still pull the labels from the dataset
	  ticks-labels='["21","23","24","22"]'
	>
	</c-cartesian-category-axis>  
	<c-cartesian-axis 
	  axis="y" 
	  stacked="true">
	</c-cartesian-axis>
	<c-title 
	  text="Curve controls"></c-title>
	<c-legend 
	  position="right"></c-legend>
  </c-chart>
</c-sample-app-item>

The output looks like this

Expected behavior (i.e. solution)

What it looks like now: chart_current

The ticks-labels should allow a secondary axis to be included, with defined labels from the script. The end-goal is to remove the "21","23,"24","22" from the data labels of the stacks themselves and instead be grouped in four "overall stacks"

According to documentation (https://salesforcelabs.github.io/LightningWebChartJS/docs/api/axes/cartesian/category.html) the ticks-labels should do the trick, with some adjustments to offset, but currently its just showing the dataset labels for the second axis as well.

The goal is to have it look like this in the end chart_goal

Other Comments

1quest avatar Apr 10 '24 10:04 1quest