Lines points in the wrong location.

So I have been building a chart system for a while now for my client, and I am currently encountering a very odd situation, if I pass more than one data point into a stacked line then sometimes they will simply be in the same locations as one another, but if I use the legend to hide the one, the other will move to it's correct location, here's a gif to show:



And here is the code I am using to generate it.

  1.     function BuildChart(widgetID, data, Settings) {
  2.         ConvertDataTypes(data, Settings);

  3.         var newtype = chartTypeData[Settings.tableindex].Id;
  4.         if (Settings.xindexs.length > 1) {
  5.             newtype = 'Stacking' + newtype;
  6.         }

  7.         var newseries = [];
  8.         for (var i = 0; i < Settings.xindexs.length; i++) {
  9.             var colname = Settings.xindexs[i].column;
  10.             if (Settings.xindexs[i].columnType == 'number' && Settings.xindexs[i].aggregateoption != null) {
  11.                 colname = Settings.xindexs[i].displaytext;
  12.             }

  13.             var newdata = {
  14.                 dataSource: data, xName: Settings.yindex.column, yName: colname,
  15.                 //Series type as stacked column
  16.                 type: newtype,
  17.                 name: colname,
  18.             }

  19.             newseries.push(newdata);
  20.         }
  21.         
  22.         var xaxistype = Settings.yindex.columnType;

  23.         var primaryX = {
  24.             title: Settings.yindex.column,
  25.             rangePadding: 'Round'
  26.         };

  27.         switch (xaxistype) {
  28.             case ('date'):
  29.                 xaxistype = 'DateTime'
  30.                 primaryX.labelFormat = 'yyyy/MMM/dd'
  31.                 primaryX.rangePadding = 'Additional'
  32.                 break;
  33.             case ('number'):
  34.                 xaxistype = 'Double'
  35.                 break;
  36.             default:
  37.                 xaxistype = 'Category';
  38.                 break;
  39.         }
  40.         primaryX.valueType = xaxistype;
  41.         primaryX.edgeLabelPlacement = 'Shift';

  42.         var chart = new ej.charts.Chart({
  43.             width: 'inherit', height: 'inherit',
  44.             canResize: true,
  45.             primaryXAxis: primaryX,
  46.             primaryYAxis: {
  47.                 title: Settings.xindexs[0].column,
  48.                 labelFormat: '{value}'
  49.             },
  50.             commonSeriesOptions: {
  51.                 enableAnimation: false
  52.             },
  53.             series: newseries,
  54.             tooltip: { enable: true },
  55.         });

  56.         chart.appendTo('#' + widgetID);

  57.         var tempobject = {
  58.             width: 'inherit', height: 'inherit',
  59.             canResize: true,
  60.             primaryXAxis: primaryX,
  61.             primaryYAxis: {
  62.                 title: Settings.xindexs[0].column,
  63.                 labelFormat: '{value}'
  64.             },
  65.             commonSeriesOptions: {
  66.                 enableAnimation: false
  67.             },
  68.             series: newseries,
  69.             tooltip: { enable: true }
  70.         };
  71.         var debugoutput = JSON.stringify(tempobject);

  72.         return chart;
  73.         //console.log(chart);
  74.     }

The data is user supplied so it varies, however here is the json object of the debug object declared at the bottom: https://jsoneditoronline.org/#left=cloud.1450686424d847208b3608be4e18650e

Now there is also even more odd behaviour if I add three options:



I have no idea what is going on here, here is the debug json object: https://jsoneditoronline.org/#left=cloud.ef667a5f62634c1ab9b3f65641d52ac4

Also on the json objects, just click tree and it will show you the data I put into the tables. Thanks!

Edit: How do I post code in a better format? I see your official posts with clean code formatting and I'd like to be able to do that.

Edit 2: Found a solution, leaving this here for future users, 

Don't set lines to stacked.


1 Reply 1 reply marked as answer

DG Durga Gopalakrishnan Syncfusion Team March 22, 2021 01:06 PM UTC

Hi David, 
  
Greetings from Syncfusion. 
  
Edit 1: How do I post code in a better format? I see your official posts with clean code formatting, and I'd like to be able to do that. 
  
We currently don’t have the support for code snippet option in the forums RTE. We have already logged a feature request for the same and will rollout this changes in our upcoming website release. As a workaround, you can copy the code from your IDE to your outlook mail and paste that content from the outlook mail to the RTE to give the code snippet as formatted, refer the screenshot below. 

 

 
  
Edit 2: Found a solution, leaving this here for future users, don't set lines to stacked. 
  
Stacked charts are used to visualize the sum values of the points in different series. Please find the behavior of the stacked line series using the below sample provided in the link. The Y-axis range will be calculated based on the total values of the series available in the chart. 
  
If you wish the ranges should not change on legend click, you can set minimum and maximum values to the Y-axis. 
  
  
 
  
If visualizing the sum values is not your requirement you can use the line chart to visualize your data. 
  
Please get back to us if you need any further assistance related to chart. 
  
Regards, 
Durga G 


Marked as answer
Loader.
Up arrow icon