In order to change the background color of the chart using CSS, you will have to first set the chart backgroundColor property to transparent. You can then, apply CSS styles to the chart container using the chart id.
Please check this JSFiddle for a working example similar to your requirement, which shows how to set gradient as chart background using CSS.
—
Thangaraj Raman
Team CanvasJS
Sorry, it is not possible to display a tooltip for stripline labels as of now. However, as a workaround, you can position the stripline label to the center of the plot area using the labelAlign property and add a scatter point for displaying the tooltip content. Please take a look at the code snippet below:
chart.addTo("data", {
type: "scatter",
markerSize: 0,
highlightEnabled: false,
toolTipContent: "Content to be displayed on hover",
dataPoints: [{
x: (chart.axisX[0].viewportMaximum + chart.axisX[0].viewportMinimum) / 2 ,
y: chart.axisY[0].stripLines[0].value
}]
})
Please check this JSFiddle for a working example.
—
Thangaraj Raman
Team CanvasJS
It looks like you are setting the axisX interval manually due to which the extra labels -1 and 1 are shown. Based on the interval & other factors, the axis range is calculated & hence the extra labels are added in this case. You can overcome this behavior by either not setting interval when there are fewer datapoints or by manually setting the axis range.
Please take a look at this JSFiddle for a working example.
—
Thangaraj Raman
Team CanvasJS
You can update the position of the scatter datapoints on resizing the window by calculating the width of the index labels and using convertPixeltoValue. Please check the code snippet below:
window.onresize = function() {
indexLabelOffset = (chart.width < 700) ? 5 : 2 ;
for(var i = 0; i < customLinesData.length; i++) {
for(var j = 0; j < scatterDps.length; j++) {
if( scatterDps[j].indexLabel === "\u25C0 " + customLinesData[i].label) {
indexLabelWidth = getWidth(customLinesData[i].label);
scatterDps[j].x = customLinesData[i].x + chart.axisX[0].convertPixelToValue(indexLabelWidth) / 2 + indexLabelOffset;
}
}
}
chart.render();
};
Please take a look at this updated JSFiddle for a working example.
—
Thangaraj Raman
Team CanvasJS
Striplines are drawn from end to end across the full width/height of the plot-area. However, in your case, you can use a multi-series line chart with interactivity disabled and 2 datapoints each to represent the start and end coordinates of the line. To display text representing each line, you can use a scatter chart with indexlabels.
Please take a look at this JSFiddle for a working example.
—
Thangaraj Raman
Team CanvasJS
To update the y value of a datapoint using a dropdown menu you need to update the chart options / data based on the options selected from the dropdown list. Please check the code snippet below.
var country = document.getElementById("country");
country.addEventListener( "change", function(){
for(var i = 0; i < chart.options.data[0].dataPoints.length; i++) {
if(country.options[country.selectedIndex].text === chart.options.data[0].dataPoints[i].label)
chart.options.data[0].dataPoints[i].y = Number(country.options[country.selectedIndex].value);
}
chart.render();
});
Please take a look at this JSFiddle for a working example.
—
Thangaraj Raman
Team CanvasJS
It seems to be working fine. Can you kindly create a sample project reproducing the issue you are facing and share it with us over Google Drive or OneDrive so that we can look into your code, run it locally at our end to understand the scenario better, and help you out?
—
Thangaraj Raman
Team CanvasJS
Striplines are drawn from end to end across the full width/height of the plot-area. You can use rangeArea chart with interactivity disabled for the corresponding dataseries to achieve your requirement.
Please take a look at this JSFiddle for a working example.
—
Thangaraj Raman
Team CanvasJS
You can pass x-value in date-time format and use valueFormatString to define how axis labels must be formatted before they appear on the x-axis.
—
Thangaraj Raman
Team CanvasJS
Please refer to this page for step by step tutorial on Creating Chart with data from JSON. The data from the JSON has to be parsed in the format accepted by CanvasJS.
—
Thangaraj Raman
Team CanvasJS
It looks like the sample provided by you is restricted and requires permission. Can you please make the image / sample public so that we can access it?
If the Google Drive link shared contains an image, can you kindly create JSFiddle reproducing the issue you are facing & share it with us so that we can look into the code / chart-options being used, understand the scenario better and help you out?
—
Thangaraj Raman
Team CanvasJS
It is not possible to position the axis to the center of the chart as of now. However, you can work around this by using multiple charts to achieve your requirement.
Please check this JSFiddle for a working example.
—
Thangaraj Raman
Team CanvasJS
You can use the indexLabelFormatter function to display custom index labels as per your requirement. Please take a look at the code-snippet given below.
indexLabelFormatter: function(e) {
var s = e.dataPoint.y % 1; s *= 60;
var m = e.dataPoint.y % 60;
var h = (e.dataPoint.y - m) / 60;
return (h < 10 ? "0" : "") + h.toString() + ":" + (m < 10 ? "0" : "") + Math.trunc(m).toString() + ":" + (s < 10 ? "0" : "") + s.toString();
},
—
Thangaraj Raman
Team CanvasJS
The trial version is meant for evaluation purposes for 30 days. You will need a license to use it in commercial applications, please check out License page for more information. One of our sales representatives will get in touch with you soon for further assistance on licensing. For further queries related to sales please contact sales[at]canvasjs[dot]com.
—
Thangaraj Raman
Team CanvasJS
The chart’s X-axis and Y-axis lines and labels will be positioned to the bottom and left in the case of primary axis and to the top and right in the case of secondary axis. If you are looking to draw a horizontal or vertical line in the middle of the chart, you can use stripLines.
—
Thangaraj Raman
Team CanvasJS