Home forums Using CanvasJS Chart legendText for MySQL data

This topic contains 1 reply, has 2 voices, and was last updated by  Sunil Urs 3 years, 4 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4827

    d_man
    Participant

    Good morning,

    I was wondering since I can’t use an indexLabel as well as a Y label on a Pie chart, could I use an indexLabel with a Legend?

    My problem is that while I’m making great strides with CanvasJS and loving every moment of it, I’m not so great with Javascrip or especially JSON. I’m using the code that was mentioned in a previous post for using MySQL data for charting points through JSON encoding.

    How can I add legendText to the data points that consists of the “label” attribute in the datapoints?

    This is my code from the previous thread.

     $point = array("label" => $row['company'] , "y" => $row['ordercount']);
    
    array_push($data_points, $point);

    Can I repeat “company” in legendText somehow? I tried a few things that didn’t work.

    Thanks!

    #4828

    Sunil Urs
    Keymaster

    Yes, you can customize legend to show any text you want. Use legendText property of dataPoint/dataSeries for the same.

    http://canvasjs.com/docs/charts/basics-of-creating-html5-chart/legend/

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

You must be logged in to reply to this topic.