{"_id":"5445c719bfa07c0800f3a12e","category":{"_id":"5445a098c3eb3808000c76b3","project":"53844557a43e08da4677be0e","version":"53844558a43e08da4677be12","__v":3,"pages":["5432e4d15b5b950800f4edc9","5445c719bfa07c0800f3a12e","5447ea9c0319802200fc06e6","54512f34a66f020800dbab10"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-20T23:54:00.481Z","from_sync":false,"order":5,"slug":"additional-functionality","title":"Additional functionality"},"is_link":false,"editedParams":true,"editedParams2":true,"user":"5432d74e8780d4080074d772","version":{"_id":"53844558a43e08da4677be12","__v":8,"project":"53844557a43e08da4677be0e","createdAt":"2014-05-27T07:57:12.136Z","releaseDate":"2014-05-27T07:57:12.136Z","categories":["53844558a43e08da4677be13","538619e1ef91f96d49aa1a0b","541e82877eb16bb64f83c0ca","5445a073c3eb3808000c76b2","5445a098c3eb3808000c76b3","54bb05ab522f03150054d9e8","54bb05cf9741c81500078f73","55b7d0e5568be2230092bb92"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"false","version_clean":"1.0.0","version":"1.0"},"__v":0,"project":"53844557a43e08da4677be0e","updates":[],"next":{"pages":[],"description":""},"createdAt":"2014-10-21T02:38:17.591Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"basic_auth":false,"method":"post","results":{"codes":[{"name":"Success","code":"{\"chart_url\":\"https://s3.amazonaws.com/knowtify-charts/XXXXXXXXXX.png\"}","language":"json"}]},"try":false,"auth":"never","params":[{"_id":"5445c719bfa07c0800f3a13c","ref":"","in":"body","required":true,"desc":"Please prefix file names with your Public Token.","default":"","type":"string","name":"filename"},{"_id":"5445c719bfa07c0800f3a13b","ref":"","in":"body","required":false,"desc":"","default":"800","type":"string","name":"width"},{"_id":"5445c719bfa07c0800f3a13a","ref":"","in":"body","required":false,"desc":"","default":"500","type":"string","name":"height"},{"_id":"5445c719bfa07c0800f3a139","ref":"","in":"body","required":false,"desc":"","default":"false","type":"boolean","name":"curved_lines"},{"_id":"5445c719bfa07c0800f3a138","ref":"","in":"body","required":false,"desc":"","default":"true","type":"boolean","name":"show_y_axis"},{"_id":"5445c719bfa07c0800f3a137","ref":"","in":"body","required":false,"desc":"","default":"#999","type":"string","name":"y_axis_color"},{"_id":"5445c719bfa07c0800f3a136","ref":"","in":"body","required":false,"desc":"Add any number of labels in an array i.e. [\"Jan 1\",\"Jan 10\"]","default":"","type":"array_mixed","name":"x_axis_labels"},{"_id":"5445c719bfa07c0800f3a135","ref":"","in":"body","required":false,"desc":"","default":"#999","type":"string","name":"x_axis_color"},{"_id":"5445c719bfa07c0800f3a134","ref":"","in":"body","required":false,"desc":"","default":"80","type":"int","name":"margin_top"},{"_id":"5445c719bfa07c0800f3a133","ref":"","in":"body","required":false,"desc":"","default":"80","type":"int","name":"margin_right"},{"_id":"5445c719bfa07c0800f3a132","ref":"","in":"body","required":false,"desc":"","default":"80","type":"int","name":"margin_bottom"},{"_id":"5445c719bfa07c0800f3a131","ref":"","in":"body","required":false,"desc":"","default":"80","type":"int","name":"margin_left"},{"_id":"5445c719bfa07c0800f3a130","ref":"","in":"body","required":false,"desc":"","default":"#fff","type":"string","name":"background_color"},{"_id":"5445c719bfa07c0800f3a12f","ref":"","in":"body","required":true,"desc":"*Important* - See details below.","default":"","type":"array_mixed","name":"lines"}],"url":"http://charts.knowtify.io/line"},"isReference":false,"order":1,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Lines Array\"\n}\n[/block]\nThis is the data structure required to add one or more lines to your chart.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\\"lines\\\":[\\n  {\\n    \\\"name\\\":\\\"Average\\\", //label for the legend\\n    \\\"color\\\":\\\"#fff\\\", //line color\\n    \\\"line_thickness\\\":4, //line thickness in pixels\\n    \\\"type\\\":\\\"dashed\\\", //dashed or solid\\n    \\\"data\\\":[1,2,3,3,4,2] //array of data points\\n  },\\n  {\\n    \\\"name\\\":\\\"You\\\",\\n    \\\"color\\\":\\\"#e24a25\\\",\\n    \\\"line_thickness\\\":5,\\n    \\\"type\\\":\\\"solid\\\",\\n    \\\"data\\\":[3,4,25,6,8,33,5,4,4]\\n  }\\n]\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Example request JSON\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\t\\\"width\\\":800,\\n  \\t\\\"height\\\":400,\\n  \\t\\\"filename\\\":\\\"{PUBLIC_TOKEN}_{USER_ID}\\\",\\n  \\t\\\"curved_lines\\\":false,\\n  \\t\\\"show_y_axis\\\":true,\\n  \\t\\\"x_axis_labels\\\":[\\\"Mon\\\",\\\"Tues\\\",\\\"Wed\\\",\\\"Thu\\\",\\\"Fri\\\"],\\n  \\t\\\"x_axis_color\\\":\\\"#999\\\",\\n  \\t\\\"y_axis_color\\\":\\\"#999\\\",\\n  \\t\\\"margin_top\\\":60,\\n  \\t\\\"margin_right\\\":100,\\n  \\t\\\"margin_bottom\\\":60,\\n  \\t\\\"margin_left\\\":100,\\n  \\t\\\"background_color\\\":\\\"#444\\\",\\n  \\t\\\"lines\\\":[\\n      \\t{\\n          \\\"name\\\":\\\"Average\\\",\\n          \\\"color\\\":\\\"rgba(255,255,255,.3)\\\",\\n          \\\"line_thickness\\\":4,\\n          \\\"type\\\":\\\"dashed\\\",\\n          \\\"data\\\":[1,2,3,3,4,2]\\n        },\\n      \\t{\\n          \\\"name\\\":\\\"Top\\\",\\n          \\\"color\\\":\\\"rgba(255,255,255,.75)\\\",\\n          \\\"line_thickness\\\":4,\\n          \\\"type\\\":\\\"dashed\\\",\\n          \\\"data\\\":[23,41,52,21]\\n        },\\n      \\t{\\n          \\\"name\\\":\\\"You\\\",\\n          \\\"color\\\":\\\"#e24a25\\\",\\n          \\\"line_thickness\\\":5,\\n          \\\"type\\\":\\\"solid\\\",\\n          \\\"data\\\":[3,4,25,20,34,18,8,5,20,4,6]\\n        }\\n    ]\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Filenames\"\n}\n[/block]\nTo make our API as easy as possible to use, we don't require any authentication. The downside is all our chart images will live in the same S3 bucket. So if you use a generic filename then it's possible for someone to overwrite it! To avoid that, please use your Knowtify Public Token found in http://www.knowtify.io/settings as a prefix to your filenames. Alternatively, you could use a unique randomly generated string as a prefix.\n\nExample filenames with user ids...\n- 362496ce22c4284348691388a099f391_1\n- 362496ce22c4284348691388a099f391_2\n- 362496ce22c4284348691388a099f391_3\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Charts get deleted after 7 days\"\n}\n[/block]\nIn order for us to provide this service for free, charts automatically get deleted after 7 days. You are free to download charts and host them on your own servers if it's important that they  are available for longer than a week.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"This is beta!\"\n}\n[/block]\nThis feature is still in beta so errors happen. We plan to introduce things like better error handling, batch requests, authentication and more in the future. If you plan to use this for production emails I'd just recommend taking a few precautions.\n\n- Don't send a large number of requests at once. Generating these charts is fairly resource intensive and we haven't load tested our servers yet so if you send us too many concurrent requests, we may drop some of them.\n- Because errors happen, look for a 200 response with a chart_url before assuming your request properly generated a chart.\n- Start slow. Instead of generating 1,000 charts at once, start with 10 and ramp up.\n- Verify that your lines are being plotted as expected. If not please email me at dane:::at:::knowtify.io to report a bug.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Sample line charts\"\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/pIrnU5kR8ewkQH2gHNYX_chart1.png\",\n        \"chart1.png\",\n        \"800\",\n        \"405\",\n        \"#dc4b25\",\n        \"\"\n      ],\n      \"caption\": \"Show a users progress vs average and top performers.\"\n    }\n  ]\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/lUOy9pDhS1GujkeuopMQ_chart4.png\",\n        \"chart4.png\",\n        \"800\",\n        \"405\",\n        \"#0ed4b4\",\n        \"\"\n      ],\n      \"caption\": \"Bare bones chart without labels or an x or y axis.\"\n    }\n  ]\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/FbNrNuYGQGKAAUToOkok_chart3.png\",\n        \"chart3.png\",\n        \"800\",\n        \"405\",\n        \"#0c9cec\",\n        \"\"\n      ],\n      \"caption\": \"Chart for a quarterly report.\"\n    }\n  ]\n}\n[/block]","excerpt":"Generate dynamic line charts that get converted to PNG images that can be inserted into emails. (scroll down for examples)","slug":"httpchartsknowtifyioline","type":"endpoint","title":"Line charts for your email"}

postLine charts for your email

Generate dynamic line charts that get converted to PNG images that can be inserted into emails. (scroll down for examples)

Definition

{{ api_url }}{{ page_api_url }}

Parameters

Body Params

filename:
required
string
Please prefix file names with your Public Token.
width:
string800
height:
string500
curved_lines:
booleanfalse
show_y_axis:
booleantrue
y_axis_color:
string#999
x_axis_labels:
array of mixed
Add any number of labels in an array i.e. ["Jan 1","Jan 10"]
x_axis_color:
string#999
margin_top:
integer80
margin_right:
integer80
margin_bottom:
integer80
margin_left:
integer80
background_color:
string#fff
lines:
required
array of mixed
*Important* - See details below.

Result Format


Documentation

[block:api-header] { "type": "basic", "title": "Lines Array" } [/block] This is the data structure required to add one or more lines to your chart. [block:code] { "codes": [ { "code": "\"lines\":[\n {\n \"name\":\"Average\", //label for the legend\n \"color\":\"#fff\", //line color\n \"line_thickness\":4, //line thickness in pixels\n \"type\":\"dashed\", //dashed or solid\n \"data\":[1,2,3,3,4,2] //array of data points\n },\n {\n \"name\":\"You\",\n \"color\":\"#e24a25\",\n \"line_thickness\":5,\n \"type\":\"solid\",\n \"data\":[3,4,25,6,8,33,5,4,4]\n }\n]", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "Example request JSON" } [/block] [block:code] { "codes": [ { "code": "{\n \t\"width\":800,\n \t\"height\":400,\n \t\"filename\":\"{PUBLIC_TOKEN}_{USER_ID}\",\n \t\"curved_lines\":false,\n \t\"show_y_axis\":true,\n \t\"x_axis_labels\":[\"Mon\",\"Tues\",\"Wed\",\"Thu\",\"Fri\"],\n \t\"x_axis_color\":\"#999\",\n \t\"y_axis_color\":\"#999\",\n \t\"margin_top\":60,\n \t\"margin_right\":100,\n \t\"margin_bottom\":60,\n \t\"margin_left\":100,\n \t\"background_color\":\"#444\",\n \t\"lines\":[\n \t{\n \"name\":\"Average\",\n \"color\":\"rgba(255,255,255,.3)\",\n \"line_thickness\":4,\n \"type\":\"dashed\",\n \"data\":[1,2,3,3,4,2]\n },\n \t{\n \"name\":\"Top\",\n \"color\":\"rgba(255,255,255,.75)\",\n \"line_thickness\":4,\n \"type\":\"dashed\",\n \"data\":[23,41,52,21]\n },\n \t{\n \"name\":\"You\",\n \"color\":\"#e24a25\",\n \"line_thickness\":5,\n \"type\":\"solid\",\n \"data\":[3,4,25,20,34,18,8,5,20,4,6]\n }\n ]\n}", "language": "json" } ] } [/block] [block:api-header] { "type": "basic", "title": "Filenames" } [/block] To make our API as easy as possible to use, we don't require any authentication. The downside is all our chart images will live in the same S3 bucket. So if you use a generic filename then it's possible for someone to overwrite it! To avoid that, please use your Knowtify Public Token found in http://www.knowtify.io/settings as a prefix to your filenames. Alternatively, you could use a unique randomly generated string as a prefix. Example filenames with user ids... - 362496ce22c4284348691388a099f391_1 - 362496ce22c4284348691388a099f391_2 - 362496ce22c4284348691388a099f391_3 [block:api-header] { "type": "basic", "title": "Charts get deleted after 7 days" } [/block] In order for us to provide this service for free, charts automatically get deleted after 7 days. You are free to download charts and host them on your own servers if it's important that they are available for longer than a week. [block:api-header] { "type": "basic", "title": "This is beta!" } [/block] This feature is still in beta so errors happen. We plan to introduce things like better error handling, batch requests, authentication and more in the future. If you plan to use this for production emails I'd just recommend taking a few precautions. - Don't send a large number of requests at once. Generating these charts is fairly resource intensive and we haven't load tested our servers yet so if you send us too many concurrent requests, we may drop some of them. - Because errors happen, look for a 200 response with a chart_url before assuming your request properly generated a chart. - Start slow. Instead of generating 1,000 charts at once, start with 10 and ramp up. - Verify that your lines are being plotted as expected. If not please email me at dane@knowtify.io to report a bug. [block:api-header] { "type": "basic", "title": "Sample line charts" } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/pIrnU5kR8ewkQH2gHNYX_chart1.png", "chart1.png", "800", "405", "#dc4b25", "" ], "caption": "Show a users progress vs average and top performers." } ] } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/lUOy9pDhS1GujkeuopMQ_chart4.png", "chart4.png", "800", "405", "#0ed4b4", "" ], "caption": "Bare bones chart without labels or an x or y axis." } ] } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/FbNrNuYGQGKAAUToOkok_chart3.png", "chart3.png", "800", "405", "#0c9cec", "" ], "caption": "Chart for a quarterly report." } ] } [/block]

User Information

Try It Out

post
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}