Labels when hovering over bar chart

Posted by: sstephens on 21 March 2019, 10:42 am EST

  • Posted 21 March 2019, 10:42 am EST

    Hello,

    I am trying to create a bar graph that has a salesmen name when you hover over it with the mouse but says their territory number at the bottom. I can get it to say the territory just fine when I hover over Im just not sure how to pass the data for each of their names through to the individual bars. I have their names in the same format as the other data (x and y).

    Can i somehow pass it through like X and Y are passed through? or is there some other easier way.

    Also I know i might be on an older version but I am not sure what version this is, I am re-writing existing code.

    Thanks in advanced for any help!

    
      require(["wijmo.wijbarchart"], function () {
        $(document).ready(function () {
          chart1 = $("#bannerBySalesmen").wijbarchart({
    	  horizontal: false,
    	  axis: { y: { text: "Goal (Percent)", min: -100, max: 100, autoMin: false, autoMax: false },
    	    x: { textStyle: { "font-weight": "normal" } } },
    	  hint: { content: function() { return this.label + '\'s Progress\n ' + this.y + '%'; } },
    	  header: { text: "Banner Sales" },
    	  seriesList: [{ legendEntry: false, data: {
    		  
    	      x: [<? echo $salesPeople; ?>],
    	      y: [<? echo $salesPercent;?>] } }],
    		  
    	  seriesStyles: [ { fill: "rgb(136,189,230)", stroke: "none" } ],
    	  painted: function (args) {
    		<? 
    		$countArray = count($salesPercentArray);
    		for($i=0; $i <= $countArray; $i++)
    		{
    			//echos out green for positive red for negitive
    			if($salesPercentArray[$i] >= 0)
    			{
    				echo ('var bar = $(this).wijbarchart("getBar", '.$i.'); bar.attr({ fill: "#009900" });');
    			}
    			else
    			{
    				echo ('var bar = $(this).wijbarchart("getBar", '.$i.'); bar.attr({ fill: "#CE2522" });');	
    			}
    			
    		}
    				
    		?>
    		}
          });
        });
      });
    
    
  • Posted 26 March 2019, 9:11 am EST

    Hello,

    If you have an array of names of all the salesmen, you can use the index property to access the current salesman name from the array in the content method inside hint property.

    Please refer to the attached sample and let us know if you face any issues.

    ~Sharad

    LineChart_MarkerFill_issue.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels