Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label X Axis? #23

Open
MarcGodard opened this issue Apr 30, 2016 · 3 comments
Open

Label X Axis? #23

MarcGodard opened this issue Apr 30, 2016 · 3 comments
Assignees

Comments

@MarcGodard
Copy link

MarcGodard commented Apr 30, 2016

Is there a way (in line/area/bar charts) to label the X axis something other than 1,2,3,...?

@MarcGodard
Copy link
Author

MarcGodard commented May 2, 2016

The following isn't working. What am I doing wrong? I am following the examples perfectly?

<can-component tag="securities-performance-area">
  <style type="less">
    display: block;
    p { font-weight: bold; }
  </style>
  <template>
    <bit-c3>
          <bit-c3-data type="area">
            {{#each dataColumns}}
              <bit-c3-data-column value="{.}" />
            {{/each}}
            <c3-x value="{xKey}" />
          </bit-c3-data>
          <c3-x-axis type="{xType}">
        <c3-tick format="{xTickFormat}" />
      </c3-x-axis>
    </bit-c3>
  </template>
  <script type="view-model" language="text/ecmascript-6">
    import Map from 'can/map/';
    import 'can/map/define/';

    let data1 = new can.List(["data1", 300, 350, 300, 90, 30, 100]),
        data2 = new can.List(["data2", 130, 100, 140, 200, 150, 50]),
        xKey = 'x',
        x = new can.List([xKey, '2013-01-01', '2013-01-02', '2013-01-03', '2013-01-04', '2013-01-05', '2013-01-06']),
        xType = 'timeseries',
        xTickFormat = '%Y-%m-%d';

    export default Map.extend({
          dataColumns: new can.List([x, data1, data2]),
          xKey: xKey,
          xType: xType,
          xTickFormat: xTickFormat
    });
  </script>
</can-component>

@ilyavf ilyavf self-assigned this May 5, 2016
ilyavf added a commit that referenced this issue May 5, 2016
@ilyavf
Copy link
Contributor

ilyavf commented May 5, 2016

To use axis data you can now:

<bit-c3 axis-x-type="category">
    <bit-c3-data>
        <bit-c3-data-column key="dataSet1" value="[1, 2, 3]" axis-x="['x','cat 1','cat 2','cat 3']" />
    </bit-c3-data>
</bit-c3>

This will be translated into:

chart.generate({
    data: { ..., x: 'x'},
    axis: {x: {type: "category"}}
})

Note: "[1,2,3]" is just for illustration. You have to bind a can.List property there as well as for axis-x

@ilyavf
Copy link
Contributor

ilyavf commented May 5, 2016

The above API is just an experiment, you can use it if you you urgently need the feature (just point your package.json to that particular commit).

For the updates on API please watch #19.

@kylegifford kylegifford added ready and removed ready labels May 13, 2016
ilyavf added a commit that referenced this issue May 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants