You must be logged in to post your query.
Home › Forums › Chart Support › Xaxis data
Using column chart: How to set string data on x axis ? I use labels for that but then again on plotting multiple data series it doesn’t group data according to the labels… I want the data to be grouped according to labels….
i mean try this: https://canvasjs.com/docs/charts/basics-of-creating-html5-chart/ in the first chart editor create another data series:
{
type: “column”, dataPoints: [
{ label: “orange”, y: 15 }, { label: “apple”, y: 10 },// i switched apples and oranges { label: “banana”, y: 25 }, { label: “mango”, y: 30 }, { label: “grape”, y: 28 } ] }
this plots apples with oranges and x axis labels are according to the last data series entered i.e. it only respects the order of data entry, not grouping according to labels. also i can’t use x for grouping since it doesn’t allow string data type
@akshay30498,
You can use x-values along with labels to achieve this. You can group same labels by having same x-values to them. Please take a look at this jsfiddle.
__ Priyanka M S Team CanvasJS
yeah… i had this workaround in my mind… but actually i am fetching data from database so it is such that:- there are centers and there are courses…. now, some centers may not have all the courses and i want to plot the enrollments… so.. it would’ve been easier if i could give custom string values to “x” attribute directly and then it would group them together according to that :( Anyways… i’ll go for the workaround.. thanx
Akshay,
Chart doesn’t automatically group dataPoints by its label. In fact whenever only label is given (without x), internally it assigns x values to dataPoints in an order. So, there can be different dataPoints with same x value but different label.
So, only way to achieve this is to set x value to each dataPoint as required.
— Sunil Urs
You must be logged in to reply to this topic. Login/Register