You can zoom the chart using mousewheel by attaching wheel event to the chart. Please find the code snippet below.
document.getElementsByClassName("canvasjs-chart-canvas")[1].addEventListener("wheel", function(e){
e.preventDefault();
if(e.clientX < chart.plotArea.x1 || e.clientX > chart.plotArea.x2 || e.clientY < chart.plotArea.y1 || e.clientY > chart.plotArea.y2)
return;
var axisX = chart.axisX[0];
var viewportMin = axisX.get("viewportMinimum"),
viewportMax = axisX.get("viewportMaximum"),
interval = axisX.get("minimum");
var newViewportMin, newViewportMax;
if (e.deltaY < 0) {
newViewportMin = viewportMin + interval;
newViewportMax = viewportMax - interval;
}
else if (e.deltaY > 0) {
newViewportMin = viewportMin - interval;
newViewportMax = viewportMax + interval;
}
if(newViewportMin >= chart.axisX[0].get("minimum") && newViewportMax <= chart.axisX[0].get("maximum") && (newViewportMax - newViewportMin) > (2 * interval)){
chart.axisX[0].set("viewportMinimum", newViewportMin, false);
chart.axisX[0].set("viewportMaximum", newViewportMax);
}
});
Please take a look at this JSFiddle for a working example.
—
Thangaraj Raman
Team CanvasJS
Please check this documentation page for an example on using the yValueFormatString
property and the different formatting options supported. Also, please take a look at this gallery page example of a pie chart with percentage values in the tooltip as well as indexlabel.
In your case you can set yValueFormatString: "{y}%"
if you want to show the value in percentage or yValueFormatString: "{y}'%'"
if you want to add % symbol along with the current y-value.
—
Thangaraj Raman
Team CanvasJS
You seem to be using undocumented methods and properties. addTheme
is an internal property with certain functionality and might not apply font-size as defined across all the elements in the chart. We suggest you use chart.options
to set the labelFontSize in this case since it will apply the font-size based on the defined value.
—
Thangaraj Raman
Team CanvasJS
Only one label will be shown for a stripline, as of now. However, you can add 2 additional striplines, one at the startValue position and the other at the endValue position, and use their individual labels to achieve your requirement.
Please check this JSFiddle for a working example.
—
Thangaraj Raman
Team CanvasJS
The click event is fired only within the area of the marker as of now. However, you can set markerBorderThickness to a value greater than 0 and markerBorderColor to transparent to increase the area in which the click event is fired without changing the size of the marker.
Please check this JSFiddle for a working example.
—
Thangaraj Raman
Team CanvasJS
Showing fewer datapoints based on the screen size of the device is not available as an inbuilt feature as of now. However, you can achieve the same with a few lines of code. Please check the code snippet below.
var screenWidth = jQuery(window).width();
var dpsCount = 6; //no. of datapoints to be displayed on phone
var dps = [];
if(screenWidth <= 768 ) {
for(var i = 0; i < dpsCount; i++) {
dps.push(chart.options.data[0].dataPoints[i]);
}
chart.options.data[0].dataPoints = dps;
chart.render();
}
Please check this JSFiddle for a working example.
—
Thangaraj Raman
Team CanvasJS
Chart elements may look blurred on changing the zoom level within the display setting of the browser or windows. Resetting the zoom level to 100% should work fine in this case.
—
Thangaraj Raman
Team CanvasJS
We are unable to reproduce the issue at our end, the chart seems to be proper & not blurry. Can you kindly provide more information like the version of CanvasJS & the browser that you are using so that we can try reproducing with the same environment?
—
Thangaraj Raman
Team CanvasJS
Shashi,
For your case, we suggest you to use separate variables for each chart instance or to keep all the chart instances in an array as shown below.
var chartsArray = [];
chartsArray.push(new CanvasJS.Chart("chartContainer1", { //Chart 1 Options }));
chartsArray.push(new CanvasJS.Chart("chartContainer2", { //Chart 2 Options }));
for(var i = 0; i < chartsArray.length; i++) {
chartsArray[i].render();
}
—
Thangaraj Raman
Team CanvasJS.
@avb,
The JSFiddle that you have shared seems to be broken. Could you please share an updated JSFiddle with working code so that we can look into the code/chart options being used, understand the scenario better, and help you out?
Also, we are unable to understand what you mean by center the chart data with a blank space on the right instead of filling till the end. Could you please brief us further with a pictorial representation or an example with the steps to understand your requirement so that we can suggest an appropriate solution?
—
Thangaraj Raman
Team CanvasJS
Changing the cursor while hovering over the underlying area of an area chart is not possible as of now.
—
Thangaraj Raman
Team CanvasJS
You can bind mouse events to the chart container and get mouse coordinates in pixels, which can be converted to corresponding values along the axis using convertPixelToValue as shown in this documentation page. Please take a look at the code snippet below:
jQuery(".canvasjs-chart-canvas").last().on("click",
function(e){
var parentOffset = $(this).parent().offset();
var relX = e.pageX - parentOffset.left;
var xValue = Math.round(chart.axisX[0].convertPixelToValue(relX));
console.log(xValue);
});
—
Thangaraj Raman
Team CanvasJS