Google Chart Line: How To Connect Dots Properly Using A Continuous Axes
I have a problem on a Google Chart line graph. I'm trying to use a continuous axis, but I obtain this: As you can see, I'm not able to connecting dots using the X (date), but the
Solution 1:
This is because line chart in Google chart doesnt order the data by itself based on the x axis values. If you want to have a continuous graph, you should sort the data based on x-axis value (timestamp in your case) and then pass it to Google charts.
Solution 2:
- You can use data.sort([{column: 0}]); for sorting it based on x-axis, Here column:0 indicates x-axis.https://developers.google.com/chart/interactive/docs/reference#DataTable_getSortedRows
- If the value you are trying to pass is through some xml or json and it has null values inside it will not plot properly and will be scattered or as dotted lines in line graph so to plot them, have a condition to remove all null values and then it will plot correctly.
Post a Comment for "Google Chart Line: How To Connect Dots Properly Using A Continuous Axes"