Set start and end dates for timeline chart

Forums SPJS Charts for SharePoint Set start and end dates for timeline chart

Tagged: ,

This topic contains 3 replies, has 2 voices, and was last updated by  Phil Grant 3 months ago.

  • Author
    Posts
  • #21358

    Phil Grant
    Participant

    Hi,
    I have a couple of timeline charts showing similar data but would like to have a common start and end dates on both charts, I found a snippet on stackOverflow that indicates a min/max date can be applied.
    How can I set this up in the SPJS options. I have tried a couple of combinations without success.

    var options = {
      hAxis: {
        minValue: new Date(2018, 1, 1),
        maxValue: new Date(2019, 1, 12)
      }
    };
    • This topic was modified 3 months, 1 week ago by  Phil Grant.
  • #21370

    Alexander Bautz
    Keymaster

    Hi,
    You cannot add a date value like this from within the normal configuration UI, but you can add a script editor web part to the page with this code:

    <script type="text/javascript">
    var spjs_chart_option_override = {
        hAxis: {
            minValue: new Date(2018, 1, 1),
            maxValue: new Date(2019, 1, 12)
        }
    };
    </script>

    This will add these options to all the charts in the current page.

    Hope this helps.

    Alexander

  • #21383

    Phil Grant
    Participant

    Great, thanks I’ll give that a try on Monday.

  • #21419

    Phil Grant
    Participant

    Thanks Alexander that worked fine

You must be logged in to reply to this topic.