5

I was wondering if there was any way to dynamically add scale-x markers AFTER the graph has been rendered, perhaps via a function like-so:

zingchart.exec('myChart', 'addscalexmarker', {
    type: "line",
    range: 14,
    label: {
        text: "label!! yay!"
    }
}

I can't seem to figure out any other way to get this to work... Thanks in advance!

Brian Corbin
  • 267
  • 1
  • 12

1 Answers1

7

While ZingChart does have a large range of API methods to allow users to modify different pieces of a chart, not every attribute is accessible through a named method.

My suggestion would be to use the setdata method which is a catch-all API method to modify the chart's JSON. The management of the chart's state would be external to ZingChart, but updates would be handled with a single setdata method call.

   zingchart.exec('myChart', 'setdata',{
     data : myConfig
   });

Working Demo : http://demos.zingchart.com/view/BG8SXI4W

I am on the ZingChart team -- let me know if you have any further questions.

mike-schultz
  • 2,354
  • 10
  • 13
  • hey @mike-shultz, thanks for the answer! In terms of "range", does that take in values based on the scaleX? I'm having an odd issue where the actual value does not plot the marker in the correct place. For clarification, I'm doing the following 'versionData.push({"type": "line", "range": [value.startDate], "label": { "text": value.version}}); });' startDate is a Number who's value is present on the scale. In this case it is 1441727046774 (a date). This does not work, though when I use '15' for the range, it shows up near the mid. – Brian Corbin Sep 08 '15 at 16:11
  • edit- I'm also doing a zingchart.exec('mainChart', 'setdata', { data: myConfig}); – Brian Corbin Sep 08 '15 at 16:12
  • Hi @BrianCorbin , would you be able to post an example of the issue? Possibly on JSFiddle? – mike-schultz Sep 08 '15 at 16:18
  • @BrianCorbin The "range" property accepts index values based off of the tick marks (visible and invisible) on the chart. The 15 is actually plotting on index 15. If you add the property "valueRange" : true to your scale-x marker object, it will plot where you expect it to. http://fiddle.jshell.net/g1upgLs4/ – mike-schultz Sep 09 '15 at 15:26
  • We have updated docs to include dynamic marker generation https://www.zingchart.com/docs/tutorials/chart-elements/markers/ – nardecky Nov 10 '16 at 18:11