diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 8635369..0da887b 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -1,10 +1,34 @@ * Getting started + * [Quick start](getting_started/quick_start.md) - * [Quick start](chap1/test1.md) +* Axis charts + * [A basic chart](basic/basic_chart.md) + * [Adding more datasets](basic/multiple_datasets.md) + * [Trends and Region Charts](basic/trends_regions.md) -* Customization +* Aggregation Charts + * []() + * []() - * [Configuration](test2.md) +* Update data + * [Single Points]() + * [Entire Data]() +* Events + * [Navigation]() + * [Event hooks]() -* [Changelog](test.md) +* Heatmap + * []() + * []() + +* Exporting + * []() + +* API + * [Configuration]() + * [Methods]() + +* [ChangeLog]() +* [Wrappers]() +* [Contributing]() diff --git a/docs/assets/css/index.css b/docs/assets/css/index.css index 3b30fd7..9fdef0d 100755 --- a/docs/assets/css/index.css +++ b/docs/assets/css/index.css @@ -3,7 +3,6 @@ body { /* max-width: 720px; margin: auto; */ - font-family: "proxima-nova", sans-serif; font-size: 15px; color: #6c7680; text-rendering: optimizeLegibility !important; @@ -12,6 +11,10 @@ body { -webkit-font-smoothing: antialiased; } +#home-page { + font-family: "proxima-nova", sans-serif; +} + h1, h2, h3, diff --git a/docs/assets/js/docsConfig.js b/docs/assets/js/docsConfig.js deleted file mode 100644 index a426041..0000000 --- a/docs/assets/js/docsConfig.js +++ /dev/null @@ -1,279 +0,0 @@ -import { sampleData, trendsData } from './data'; - -export const docSections = [ - { - name: "start", - contentBlocks: [ - // Intro - { - type: "text", - content: `A chart is generally a 2D rendition of data. For example, - for a set of values across items, the data could look like:` - }, - { - type: "code", - content: ` data = { - labels: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], - datasets: [ - { values: [18, 40, 30, 35, 8, 52, 17, -4] } - ] - }` - }, - - // type: 'bar' - { - type: "text", - content: `Plug that in with a type bar, a color and height:` - }, - { - type: "code", - content: ` new frappe.Chart( "#chart", { - data: data, - type: 'bar', - height: 140, - colors: ['red'] - });` - }, - { - type: "demo", - config: { - data: sampleData[0], - type: 'bar', - height: 140, - colors: ['red'], - }, - }, - - // type: 'line' - { - type: "text", - content: `And similarly, a line chart:` - }, - { - type: "code", - content: ` ... - type: 'line', - ...` - }, - { - type: "demo", - config: { - data: sampleData[0], - type: 'line', - height: 140, - colors: ['red'], - }, - }, - - // Axes lines: - { - type: "text", - content: `Axes lines are configurable. By default they are long - spanning lines, but can also be short ticks:` - }, - { - type: "code", - content: ` ... - axisOptions: { - xAxisMode: 'tick' // default: 'span' - }, - ...` - }, - { - type: "demo", - config: { - data: sampleData[2], - type: 'bar', - height: 140, - colors: ['blue'], - axisOptions: { - xAxisMode: "tick", - }, - }, - }, - - // Bar width: - { - type: "text", - content: `The bar width can be set by defining the ratio of the space - between bars to the bar width.` - }, - { - type: "code", - content: ` ... - barOptions: { - spaceRatio: 0.2 // default: 1 - }, - ...` - }, - { - type: "demo", - config: { - data: sampleData[3], - type: 'bar', - height: 140, - colors: ['orange'], - axisOptions: { - xAxisMode: "tick" - }, - barOptions: { - spaceRatio: 0.2 - }, - }, - options: [ - { - name: "barOptions", - path: ["barOptions"], - type: "map", - mapKeys: ['spaceRatio'], - states: { - "0.2": [0.2], - "0.5": [0.5], - "1": [1], - "1.5": [1.5] - }, - activeState: "0.2" - } - ] - }, - - // Dot radius: - { - type: "text", - content: 'So can the dot size on a line graph, with the `dotSize` property in `lineOptions`.' - }, - { - type: "code", - content: ` ... - lineOptions: { - dotRadius: 8 // default: 4 - }, - ...` - }, - { - type: "demo", - config: { - data: sampleData[2], - type: 'line', - height: 140, - colors: ['orange'], - axisOptions: { - xAxisMode: "tick" - }, - lineOptions: { - dotSize: 8 - } - }, - options: [ - { - name: "lineOptions", - path: ["lineOptions"], - type: "map", - mapKeys: ['dotSize'], - states: { - "3": [3], - "4": [4], - "8": [8], - "10": [10], - }, - activeState: "8" - } - ] - }, - ] - }, - { - title: "Trends and region charts", - name: "trends-and-region", - contentBlocks: [ - { - type: "text", - content: 'lineOptions` have a bunch of other properties too. Region charts are' - }, - { - type: "code", - content: ` ... - data: { - labels: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], - datasets: [ - { name: "Dataset 1", values: [18, 40, 30, 35, 8, 52, 17, -4] }, - { name: "Dataset 2", values: [30, 50, -10, 15, 18, 32, 27, 14] } - ] - }, - ...` - }, - { - type: "demo", - config: { - data: trendsData, - type: 'line', - height: 180, - colors: ['violet'], - axisOptions: { - xAxisMode: 'tick', - yAxisMode: 'span', - xIsSeries: 1 - } - }, - options: [ - { - name: "lineOptions", - path: ["lineOptions"], - type: "map", - mapKeys: ['hideLine', 'hideDots', 'heatline', 'regionFill'], - states: { - "Line": [0, 1, 0, 0], - "Dots": [1, 0, 0, 0], - "HeatLine": [0, 1, 1, 0], - "Region": [0, 1, 0, 1] - }, - activeState: "HeatLine" - } - ] - } - ] - }, - { - title: "Adding more datasets", - name: "multi-dataset", - contentBlocks: [ - { - type: "text", - content: `A chart can have multiple datasets. In an axis chart, every dataset is represented individually.` - }, - { - type: "code", - content: ` ... - data: { - labels: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], - datasets: [ - { name: "Dataset 1", values: [18, 40, 30, 35, 8, 52, 17, -4] }, - { name: "Dataset 2", values: [30, 50, -10, 15, 18, 32, 27, 14] } - ] - }, - ...` - }, - { - type: "demo", - config: { - data: sampleData[1], - type: 'line', - height: 200, - colors: ['green', 'light-green'], - }, - options: [ - { - name: "type", - path: ["type"], - type: "string", - states: { - "Line": 'line', - "Bar": 'bar', - }, - activeState: "Mixed" - } - ], - } - ] - } -] \ No newline at end of file diff --git a/docs/basic/basic_chart.md b/docs/basic/basic_chart.md new file mode 100644 index 0000000..908027e --- /dev/null +++ b/docs/basic/basic_chart.md @@ -0,0 +1,62 @@ +## What is it + +A chart is generally a 2D rendition of data. For example, for a set of values across items, the data could look like: +```js + +data = { + labels: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], + datasets: [ + { values: [18, 40, 30, 35, 8, 52, 17, -4] } + ] +} +``` + +Plug that in with a type `bar`, a color and height, + +```js +new frappe.Chart( "#chart", { + data: data, + type: 'bar', + height: 140, + colors: ['red'] +}); +``` +
+ +And similarly, a `line` chart: + +```js +type:'line' +``` + + +## Tweaks + +Axes lines are configurable. By default they are long `span`ning lines, but can also be short `tick`s:` + +```js +axisOptions: { + xAxisMode: 'tick' // default: 'span' +}, +``` + + +The bar width can be set by defining the ratio of the space between bars to the bar width. + +```js +barOptions: { + spaceRatio: 0.2 // default: 1 +}, +``` + + +So can the dot size on a line graph, with the `dotSize` property in `lineOptions`. + +```js +lineOptions: { + dotSize: 8 // default: 4 +}, +``` + + +Next up, we'll discover how multiple datasets can behave in different charts. diff --git a/docs/basic/multiple_datasets.md b/docs/basic/multiple_datasets.md new file mode 100644 index 0000000..fb32b42 --- /dev/null +++ b/docs/basic/multiple_datasets.md @@ -0,0 +1,14 @@ +## Multiple datasets + +A chart can have multiple datasets. In an axis chart, every dataset is represented individually. + +```js +data: { + labels: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], + datasets: [ + { name: "Dataset 1", values: [18, 40, 30, 35, 8, 52, 17, -4] }, + { name: "Dataset 2", values: [30, 50, -10, 15, 18, 32, 27, 14] } + ] +}, +``` + diff --git a/docs/basic/trends_regions.md b/docs/basic/trends_regions.md new file mode 100644 index 0000000..477e544 --- /dev/null +++ b/docs/basic/trends_regions.md @@ -0,0 +1,9 @@ +`lineOptions` have a bunch of other properties too. Region charts are ... + +```js +lineOptions: { + dotSize: 8 // default: 4 +}, +``` + + \ No newline at end of file diff --git a/docs/demoRegistry.js b/docs/demoRegistry.js index 43df45a..41a980d 100644 --- a/docs/demoRegistry.js +++ b/docs/demoRegistry.js @@ -1,18 +1,37 @@ import { sampleData, trendsData } from './assets/js/data'; export const demoRegistry = { - demo1: { - type: "demo", + 'bar-basic-1': { config: { data: sampleData[0], type: 'bar', height: 140, colors: ['red'], + } + }, + + 'line-basic-1': { + config: { + data: sampleData[0], + type: 'line', + height: 140, + colors: ['red'], + } + }, + + 'bar-axis-tick': { + config: { + data: sampleData[2], + type: 'bar', + height: 140, + colors: ['blue'], + axisOptions: { + xAxisMode: "tick", + }, }, }, - demo2: { - type: "demo", + 'bar-barwidth': { config: { data: sampleData[3], type: 'bar', @@ -41,4 +60,86 @@ export const demoRegistry = { } ] }, + + 'line-dotsize': { + config: { + data: sampleData[2], + type: 'line', + height: 140, + colors: ['orange'], + axisOptions: { + xAxisMode: "tick" + }, + lineOptions: { + dotSize: 8 + } + }, + options: [ + { + name: "lineOptions", + path: ["lineOptions"], + type: "map", + mapKeys: ['dotSize'], + states: { + "3": [3], + "4": [4], + "8": [8], + "10": [10], + }, + activeState: "8" + } + ] + }, + + 'line-trends-region-toggle': { + config: { + data: trendsData, + type: 'line', + height: 180, + colors: ['violet'], + axisOptions: { + xAxisMode: 'tick', + yAxisMode: 'span', + xIsSeries: 1 + } + }, + options: [ + { + name: "lineOptions", + path: ["lineOptions"], + type: "map", + mapKeys: ['hideLine', 'hideDots', 'heatline', 'regionFill'], + states: { + "Line": [0, 1, 0, 0], + "Dots": [1, 0, 0, 0], + "HeatLine": [0, 1, 1, 0], + "Region": [0, 1, 0, 1] + }, + activeState: "HeatLine" + } + ] + }, + + 'multi-dataset-line-bar': { + config: { + data: sampleData[1], + type: 'line', + height: 200, + colors: ['green', 'light-green'], + }, + options: [ + { + name: "type", + path: ["type"], + type: "string", + states: { + "Line": 'line', + "Bar": 'bar', + }, + activeState: "Mixed" + } + ], + }, + + // '': {}, }; \ No newline at end of file diff --git a/docs/chap1/test1.md b/docs/getting_started/quick_start.md similarity index 97% rename from docs/chap1/test1.md rename to docs/getting_started/quick_start.md index b0851ca..1848fec 100644 --- a/docs/chap1/test1.md +++ b/docs/getting_started/quick_start.md @@ -1,4 +1,4 @@ -#### Installation +## Installation * Install via [`npm`](https://www.npmjs.com/get-npm): ```console @@ -18,7 +18,7 @@ ``` -#### Usage +## Usage ```js const data = { labels: ["12am-3am", "3am-6pm", "6am-9am", "9am-12am", diff --git a/docs/index.html b/docs/index.html index 444dc31..cb9508f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -9,14 +9,15 @@ - + - + + @@ -29,7 +30,7 @@ -