Home forums Using CanvasJS Dynamic name Option

This topic contains 4 replies, has 2 voices, and was last updated by  Chetnath 4 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #21183

    Chetnath
    Member

    Hello,

    i sent a custom value from array and in data i just want to show that custom value in name which is dynamic.
    ie – data: [{name: “Year2005”,}]
    and just want to show like this ‘Profit OR Loss’ : value

    Thanks

    #21194

    Vishwas R
    Keymaster

    @chetnath,

    You can assign any valid string as dataSeries name either directly or by passing a variable that’s a string. Please take a look at this jsfiddle.

    If you are looking for something else, can kindly create a jsfiddle and brief further about your requirement so that we can understand it better and help you out?


    Vishwas R
    Team CanvasJS

    #21199

    Chetnath
    Member

    Thanks for the reply

    please check the tooltip in given url, in both images tooltip are showing “Growth” text while it should be show “Profit” when line goes positive and “Loss” when it goes down (Negative).

    https://prnt.sc/jxpgmu
    https://prnt.sc/jxphag

    my code

    $(function () {

    var chart = new CanvasJS.Chart(“PLBYMContainer”, {
    animationEnabled: true,
    exportEnabled: true,
    theme: “light2”, // “light1”, “light2”, “dark1”, “dark2”
    title:{
    text: “Profit & Loss (By month)”,
    fontSize: 25
    },
    axisX:{
    reversed: false,
    title: “Profit & loss”
    },
    axisY:{
    title: “Range (in %)”,
    suffix: “%”,
    includeZero: false
    },
    toolTip:{
    shared: true
    },
    data: [{
    type: “line”,
    showInLegend: false,
    indexLabelFormatter: function ( e ) {
    return “₹ “+e.dataPoint.value;
    },
    name: “Growth”,
    yValueFormatString: “#,##0.0#\”%\””,
    dataPoints: <?php echo json_encode($PLByMonth, JSON_NUMERIC_CHECK); ?>
    }]
    });

    #21203

    Vishwas R
    Keymaster

    @chetnath,

    You can use toolTip contentFormatter to format the content to the be displayed in toolTip. Please take a look at this JSFiddle.

    For further queries, kindly create JSFiddle along with sample data, so that we can look into working code, understand it better and help you out.


    Vishwas R
    Team CanvasJS

    #21221

    Chetnath
    Member

    Yes..it’s working

    Thanks

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.