Forum Replies Created by Vishwas R

Viewing 15 posts - 886 through 900 (of 1,615 total)
  • in reply to: Hover on hidded bar #22794

    @as3script,

    I need the same hover effect on Canvas js bar graph.
    https://jsfiddle.net/alidingling/30763kr7/

    You can achieve this either using stripLines as shown in this JSFiddle or crosshair as shown in this JSFiddle.

    -> initially bars will be hidden
    -> on hover bars, it will display the hovered bar only.

    Please take a look at this JSFiddle.


    Vishwas R
    Team CanvasJS

    in reply to: Draw a line over canvas chart #22790

    @prem123,

    You can attach mouse events to chart-container and draw line on top of chart-canvas based on mouse events. Please take a look at this JSFiddle where line will be drawn from the coordinates of mousedown and mouseup events.


    Vishwas R
    Team CanvasJS

    in reply to: Draw a line over canvas chart #22785

    @prem123,
    Are you looking for something like this.

    Also take a look at gallery example on draggable column chart.


    Vishwas R
    Team CanvasJS

    in reply to: Stripline value from database #22784

    @stella,

    Please take a look at this sample. You can download PHP samples from our download page, which you can try running on local machine.


    Vishwas R
    Team CanvasJS

    in reply to: Remove suffix on indexLabel #22751

    @nessler,

    Glad that you figured it out and made it work according to your requirement :)

    yValueFormatString formats the values to be displayed in indexLabel and toolTip.


    Vishwas R
    Team CanvasJS

    in reply to: How to add Carousel to Column Charts #22748

    @jaydeep1998,

    Instead of setting chart-height within chart-options, you can set the height of chart-container as per your requirements and render chart on slid.bs.carousel event. Please take a look at this updated JSFiddle.


    Vishwas R
    Team CanvasJS

    in reply to: Set fixed width for the label axis #22747

    @khanhle,

    Fixing the width of label is not available as of now. However with the help of labelFormatter you can fix the number of characters to be shown in the label. Please take a look at this updated JSFiddle.


    Vishwas R
    Team CanvasJS

    in reply to: using database data to draw charts #22735

    @mikehellen,

    You can retrieve the data points from the database and pass it on chart options as shown in below code snippet.

    <?php
    $dataPoints = array();
    
    $con=mysqli_connect("localhost","root","","test"); //mysqli_connect("host","username","password","db"); - Refer https://www.w3schools.com/php/func_mysqli_connect.asp for more info
    
    if (mysqli_connect_errno()) {
    	echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
    $sql="SELECT xval,yval FROM datapoints";
    
    if ($result=mysqli_query($con,$sql)){	  
    	foreach($result as $row){
    		array_push($dataPoints, array("x"=> $row["xval"], "y"=> $row["yval"]));
    	}
    }
    
    mysqli_close($con);
    ?>
    
    <!DOCTYPE HTML>
    <html>
    <head>
    <script>
    window.onload = function () { 
    	var chart = new CanvasJS.Chart("chartContainer", {
    		animationEnabled: true,
    		exportEnabled: true,
    		theme: "light1", // "light1", "light2", "dark1", "dark2"
            exportEnabled: true,
    		title:{
    			text: "PHP Column Chart from Database - MySQLi"
    		},
    		data: [{
    			type: "column", //change type to bar, line, area, pie, etc  
    			dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?>
    		}]
    	});
    	chart.render(); 
    }
    </script>
    </head>
    <body>
    	<div id="chartContainer" style="height: 360px; width: 50%; margin: auto;"></div>
    	<script src="https://cdn.canvasjs.com/canvasjs.min.js"></script>
    </body>
    </html>

    Please take a look at this Sample Project for complete working sample.

    PHP Column Chart from Database - MySQLi


    Vishwas R
    Team CanvasJS

    in reply to: Remove suffix on indexLabel #22732

    @nessler,

    Setting indexLabel: "{y}" seems to be working fine i.e. it shows only y-value in indexLabel and not suffix. Please take a look at this JSFiddle.

    Can you kindly create JSFiddle reproducing the issue you are facing so that we can look into your code, understand your scenario better and help you out?


    Vishwas R
    Team CanvasJS

    in reply to: Reset not working when chart is rendered already zoomed-in #22719

    @leandrocosta,

    Yes, its better to call e.chart.render() only on triggering reset instead of calling it everytime the range is changed :)


    Vishwas R
    Team CanvasJS

    in reply to: Reset not working when chart is rendered already zoomed-in #22704

    @leandrocosta,

    viewportMinimum and viewportMaximum are used to programmatically zoom to a region. In this scenario, if you try to reset the range by clicking reset button it will fallback to the range that you have set (viewportMinimum and viewportMaximum). Removing viewportMinimum and viewportMaximum should work fine in this case. Or if you are trying to zoom to a certain region on initial render and like to reset on clicking reset button, you can use rangeChanged event as shown in this updated JSFiddle.


    Vishwas R
    Team CanvasJS

    in reply to: sprint mvc pie chart #22655

    @dilrukshirajapakshe,

    I observe that the X-Value being passed in the view is a string, whereas X-Value can either be number or date-time. However you can use label to show names, which accepts string. Can you try changing map.put("x", xVal); to map.put("label", xVal); in Report.jsp (line no: 29) and check if it works?

    If this doesn’t solve your issue, I request you to export your project as war/archive along with database so that we can run the project locally, understand your issue better and help you out.


    Vishwas R
    Team CanvasJS

    in reply to: About datetime format in tooltip #22654

    @prasad,

    xValueFormatString defines the format of x-value to be displayed in toolTip and indexLabel. Setting xValueFormatString to ‘YYYY-DD-MM hh:mm:ss’ should show date in the format you are looking for. Checkout our documentation for more customization options available.


    Vishwas R
    Team CanvasJS

    in reply to: Show current time in X axis in stackedcolumn #22649

    @adjmpw,

    X-Value can either be numeric or a dateTime value. But in the pen that you have shared x-value seems to be string as curTime() returns a string. You can use labels instead of x-value in this case. Please take a look at this updated pen.


    Vishwas R
    Team CanvasJS

    @wonky,

    You can store JSON data the way you want. But before passing dataPoints to the chart, you need to parse it to the format accepted by CanvasJS. Please take a look at this JSFiddle where Open, High, Low, Close data are stored separately.


    Vishwas R
    Team CanvasJS

Viewing 15 posts - 886 through 900 (of 1,615 total)